Question

I have read tips about sql server database on http://www.sql-server-performance.com/2007/clustered-indexes

In conclusion section author mentioned: "Since you can only create one clustered index per table, take extra time to carefully consider how it will be used."

My question is:

*Why only one clustered index per table should be created in sql server? *

Was it helpful?

Solution

Clustered Index:
Clustered index defines the way in which data is ordered physically on the disk. And there can only be one way in which you can order the data physically. Hence there can only be one clustered index per table.

Why care about clustered index?
If we put clustered index on the table then the data is retrieved much faster because sql server doesn't have to read the whole data -- Depends on query. But data retrieval is much faster.

NOTE: Although you can create more than one Non-Clustered index on a single table.

OTHER TIPS

This is simply SQL Server's implementation decision. Theoretically, there are can be any number of clustering indexes. MongoDB and MyISAM have no clustering indexes and store data in a flat file. InnoDB for MySQL has one clustering index, the primary key, which may be hidden if a primary key is not declared. TokuDB for MySQL and TokuMX (both of which I work on) allow users to have multiple clustering indexes, with the implicit tradeoff being more disk space used for faster queries.

Because the clustered index is the way that the data in the table is ordered when it is written to disk. In other words, the clustered index is the table.

This is also why you cannot specify included columns on a clustered index - because by its nature all of the columns are already included.

A clustered index sorts and stores the data rows in the table based on the index key values. Therefore only one clustered index can be created on each table because the data rows themselves can only be sorted in one order.

To create a different clustered index on the same table, change the Create as Clustered property setting on the existing clustered index before creating the second index.

YOU CAN! (indirectly)

If you need multiple clustered index on a table, you could create indexed view on that table. But at the same time, you should be aware that clustered index always has its cost.

A clustered index determine the physical order of the data in the table , is like a home address that is why we should have only one home address , if not the postman get confused.

http://msdn.microsoft.com/en-us/library/aa933131.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top