Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Partitioning Error Expand / Collapse
Author
Message
Posted Tuesday, February 25, 2014 5:05 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 11:20 AM
Points: 554, Visits: 1,624
Using SQL 2008 R2 Enterprise

I am trying to partition a pair of existing 200 million row tables to improve reporting performance. As I understand it, I need to drop the existing clustered index and create a new one on the date stamp the partition funciton and scheme is based on. I don't want to dump the data into a new table because I want the existing reports to work without modification.

Here's my code:
CREATE PARTITION FUNCTION ByCreatedWhen_fn (DATETIME)
AS RANGE RIGHT FOR VALUES
('2011-01-01',
'2012-01-01',
'2012-07-01',
'2013-01-01',
'2013-07-01',
'2014-01-01',
'2014-07-01');

CREATE PARTITION SCHEME ByCreatedWhen_scm
AS PARTITION ByCreatedWhen_fn
ALL TO (ESP); -- existing filegroup that contains the tables

ALTER TABLE [dbo].[SXEvent] DROP CONSTRAINT [SXEventPK]
GO

CREATE CLUSTERED INDEX [ByCreatedWhen_idx] ON [dbo].[SXEvent]
([CreatedWhenUTC] ASC )
On ByCreatedWhen_scm

When I go to create the index I get the error:

Msg 2726, Level 16, State 1, Line 3
Partition function 'ByCreatedWhen_fn' uses 1 columns which does not match with the number of partition columns used to partition the table or index.

But I'm only using one column to partition the table & index. What does this mean?
Post #1545173
Posted Tuesday, February 25, 2014 5:14 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, May 5, 2014 6:31 AM
Points: 288, Visits: 519
I believe you need to reference the column again on in the partition scheme. Seems redundant, but it does not need to match 100%.


CREATE CLUSTERED INDEX [ByCreatedWhen_idx] ON [dbo].[SXEvent]
([CreatedWhenUTC] ASC )
On ByCreatedWhen_scm (CreatedWhenUTC)

Post #1545176
Posted Wednesday, February 26, 2014 3:51 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 11:20 AM
Points: 554, Visits: 1,624
Yes, not obvious why the column needs to be specified again, but it seems to be working.

Dan
Post #1545623
Posted Wednesday, February 26, 2014 4:05 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, May 5, 2014 6:31 AM
Points: 288, Visits: 519
dan-572483 (2/26/2014)
Yes, not obvious why the column needs to be specified again, but it seems to be working.

Dan


You can, and we do, create multi-column PK on a table, but only use one of the columns for partitioning. The only requirement for this example is that the partitioning column(s) are part of clustered index, which is usually the PK as well.
Post #1545629
Posted Thursday, February 27, 2014 1:05 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 2:24 AM
Points: 40,178, Visits: 36,581
dan-572483 (2/25/2014)
I am trying to partition a pair of existing 200 million row tables to improve reporting performance.


Don't waste your time. Partitioning is not a performance tuning technique. While it is possible to get performance improvements out of partitioning, they don't necessarily come by default, queries usually have to be written to take advantage of partitioning.

https://www.simple-talk.com/sql/database-administration/gail-shaws-sql-server-howlers/



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1545742
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse