HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Advantages/Disadvantages of using a multicolumn clustering index

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
advantagesmulticolumnusingdisadvantagesclusteringindex

Problem

What are the advantage/ disadvantages of using a primary key that is a combination of multiple columns?

I have come across a table that has a unique non clustered index as a GUID but the clustering index is applied on the combination of 9 columns. In total the table has 29 columns.

Can anyone help me understand what might be the benefits of having such a clustering key? As per Kimberly Tripp || Index Debate by Kimberly Tripp the clustering Index should be narrow, unique and static, but this case is totally opposite to what Kimberly states:

  • the primary key is susceptible to changes so its not static



  • It is definitely not narrow as it spans multiple columns and other non clustering indexes refer to it for mapping. so it is definitely expensive for IAM/PFS.

Solution

A narrow, static, unique clustering key is better in situations like these:

  • The table is referenced by another table (because the referencing table needs to include the primary key which is usually the same as the clustering key)



  • The table has many non-clustered indexes (because non-clustered indexes include the clustering key)



  • No other field or combination of fields is guaranteed to be unique



  • Queries against the table usually retrieve one row and use a surrogate key to do so (e.g. because the query comes from an application that has learned the surrogate key, not a user who is searching by natural key)



A multi-column clustering key is better in situations like these:

  • No other table references this one (e.g. a fact table in a data warehouse)



  • Queries against this table usually refer to the natural key, or part of it, and not the surrogate key (e.g. queries that scan for a date range)



  • There are zero, or few, non-clustered indexes on this table (including a wide clustering key in these indexes would make them very large)



  • A unique, natural key exists



https://www.toadworld.com/platforms/sql-server/w/wiki/9547.data-warehousing-indexing-considerations

Context

StackExchange Database Administrators Q#154581, answer score: 3

Revisions (0)

No revisions yet.