I have a basic partitioning question.
I have a table that looks like this:
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]
I have created this partition function:
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'
);
And this partition scheme:
CREATE PARTITION SCHEME [psWSD] AS PARTITION [pfWSD] TO (
[WSD0000]
,[WSD2007]
,[WSD2008]
,[WSD2009]
,[WSD2010]
,[WSD2011]
,[WSD2012]
)
When i run:
SELECT $PARTITION.pfWSD([Time]) AS Partition,
COUNT(*) AS [COUNT] FROM dbo.WeatherStationData
GROUP BY $PARTITION.pfWSD([Time])
ORDER BY Partition ;
The results look like this:
Partition COUNT
----------- -----------
2 3396337
3 5408747
4 6576450
5 9602069
6 12650615
7 5577064
Yet, when I look at the underlying files, they are all 99% free (initial size was 2048MB, 2047MB free), and the primary file group is still large and mostly full. The table was empty and I loaded data into it after setting up the partitioning. I don’t think the partitioning worked, what else do I need to check?
Forgot to create the table on the partition scheme, should be: