Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Partitioning Error


Partitioning Error

Author
Message
dan-572483
dan-572483
SSChasing Mays
SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)

Group: General Forum Members
Points: 641 Visits: 1958
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?
EricEyster
EricEyster
SSC Veteran
SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)

Group: General Forum Members
Points: 296 Visits: 520
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)
dan-572483
dan-572483
SSChasing Mays
SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)

Group: General Forum Members
Points: 641 Visits: 1958
Yes, not obvious why the column needs to be specified again, but it seems to be working.

Dan
EricEyster
EricEyster
SSC Veteran
SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)

Group: General Forum Members
Points: 296 Visits: 520
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.
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47183 Visits: 44356
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, MVP, M.Sc (Comp Sci)
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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search