We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Pros and Cons of Composite Clustered Indexes

Medium Priority
788 Views
Last Modified: 2012-06-22
We have a Datawarehouse table with the following Primary Key and associated Clustered Index:

ALTER TABLE [dbo].[PosSaleTransactionDerivedCategory] ADD  CONSTRAINT [PK_PosSaleTransactionDerivedCategory] PRIMARY KEY CLUSTERED
(
      [PK_PosSaleTransactionDerivedCategory] ASC,
      [OutletID] ASC,
      [CompanyID] ASC,
      [DateID] ASC,
      [DistrictID] ASC,
      [Shop1SupplierID] ASC,
      [Shop2SupplierID] ASC,
      [DesignID] ASC,
      [TypeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

1) Given that PK_PosSaleTransactionDerivedCategory is and IDENTITY field that auto-increments by 1, is there any point having all of these fields as part of the primary key?

2) Given that PK_PosSaleTransactionDerivedCategory is and IDENTITY field that auto-increments by 1, is there any point having all of these fields as part of the clustered index?

3) Does the sequence of the fields in the clustered index matter from a performance point of view? (Note that there is a significant difference in the cardinality of each of the fields above, with DateID having a very high cardinality and TypeID having fewer than 10 distinct values.)

Comment
Watch Question

Author

Commented:
Quick remarks:

The table has 20m rows.

DateID does currently have the highest cardinality (500 distinct values) but it is likely that OutletID will ultimately have a higher cardinality.

Often queries will be dealing with a DateID range while they will never deal with a range over any of the other fields.
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.