user1843640
user1843640

Reputation: 3929

What is the best choice for clustered index when the primary key can't be used?

Given an application where the primary key for most tables is uuid, what is the best choice for a clustered index on these tables?

Considering the following data types:

Looking for comments on which is best, things to consider, or alternative ideas.

Upvotes: 1

Views: 102

Answers (2)

Jan Engelsberg
Jan Engelsberg

Reputation: 1087

If you don't want to create an index you can consider to upgrade/move to a V12 Azure SQL Database. These don't have the requirement for a clustered index.

On the index itself: You should create it on the columns that you query on. If you do lookups on the UUIDs + a date for example, you should create the index on the two to supported your queries.

Upvotes: 0

benjamin moskovits
benjamin moskovits

Reputation: 5458

I am not sure why you dismiss auto incrementing int. Anything that is widely used, works very well and as long as you are not planning on merging the table (via a Union) with other versions of the table why wouldn't you want to use it? It will provide a very good key (not too wide) for a balanced B Tree that clustered indexes are behind the curtain. Remember that in a table, that has a clustered index, all the other indexes will use the clustered index column to get to the desired page and row so you want to make it as small as possible.

Upvotes: 1

Related Questions