0

我有一个基本的分区问题。

我有一个看起来像这样的表:

CREATE TABLE [dbo].[WeatherStationData](
    [Time] [smalldatetime] NOT NULL,
    [pk_WS] [int] NOT NULL,
    [TemperatureF] [decimal](5, 1) NULL,
            ....
 CONSTRAINT [PK_WeatherStationData] PRIMARY KEY CLUSTERED 
(
    [Time] ASC,
    [pk_WS] ASC
) [PRIMARY]
) ON [PRIMARY]

我创建了这个分区函数:

CREATE PARTITION FUNCTION pfWSD (DATETIME) AS RANGE RIGHT
FOR
VALUES (
    '01/01/2007', 
    '01/01/2008',
    '01/01/2009',
    '01/01/2010',
    '01/01/2011',
    '01/01/2012'
    );

而这个分区方案:

CREATE PARTITION SCHEME [psWSD] AS PARTITION [pfWSD] TO (
    [WSD0000]
    ,[WSD2007]
    ,[WSD2008]
    ,[WSD2009]
    ,[WSD2010]
    ,[WSD2011]
    ,[WSD2012]
    )

当我运行时:

SELECT $PARTITION.pfWSD([Time]) AS Partition, 
COUNT(*) AS [COUNT] FROM dbo.WeatherStationData
GROUP BY $PARTITION.pfWSD([Time])
ORDER BY Partition ;

结果如下所示:

Partition   COUNT
----------- -----------
2           3396337
3           5408747
4           6576450
5           9602069
6           12650615
7           5577064

然而,当我查看底层文件时,它们都是 99% 的可用空间(初始大小为 2048MB,2047MB 可用空间),并且主文件组仍然很大并且大部分都已满。该表是空的,我在设置分区后将数据加载到其中。我认为分区不起作用,我还需要检查什么?

4

1 回答 1

0

忘记在分区方案上创建表,应该是:

CREATE TABLE [dbo].[WeatherStationData](
    [Time] [smalldatetime] NOT NULL,
    [pk_WS] [int] NOT NULL,
    [TemperatureF] [decimal](5, 1) NULL,
        ....
 CONSTRAINT [PK_WeatherStationData] PRIMARY KEY CLUSTERED 
(
    [Time] ASC,
    [pk_WS] ASC
) **psWSD([Time])**
) ON **psWSD([Time])**
于 2012-08-13T01:12:09.837 回答