Reasons not to have a clustered index in SQL Server 2005

前端 未结 5 1472
孤城傲影
孤城傲影 2020-12-09 06:21

I\'ve inherited some database creation scripts for a SQL SERVER 2005 database.

One thing I\'ve noticed is that all primary keys are created as NON CLUSTERED

5条回答
  •  温柔的废话
    2020-12-09 07:09

    Clustered Tables vs Heap Tables

    (Good article on subject at www.mssqltips.com)

    HEAP Table (Without clustered index)

    • Data is not stored in any particular order

    • Specific data can not be retrieved quickly, unless there are also non-clustered indexes

    • Data pages are not linked, so sequential access needs to refer back to the index allocation map (IAM) pages

    • Since there is no clustered index, additional time is not needed to maintain the index

    • Since there is no clustered index, there is not the need for additional space to store the clustered index tree

    • These tables have a index_id value of 0 in the sys.indexes catalog view

    Clustered Table

    • Data is stored in order based on the clustered index key

    • Data can be retrieved quickly based on the clustered index key, if the query uses the indexed columns

    • Data pages are linked for faster sequential access Additional time is needed to maintain clustered index based on INSERTS, UPDATES and DELETES

    • Additional space is needed to store clustered index tree These tables have a index_id value of 1 in the sys.indexes catalog view

提交回复
热议问题