问题
when we create a clustered index CIX_FirstNames on a column , say, FirstNames, then what actually happens internally in SQL Server?
i have read that clustered indexes create copy of the data.
so, does sql server creates a new index table, IndexTable , and copies all the FirstNames from the table into IndexTable, and when a firstname is searched, then it displays it from the index table?
is this the actual working of clustered indexes ?
回答1:
This is way too big a topic to handle here in a quick answer - you need to get yourself:
Microsoft SQL Server 2008 Internals
which covers this all in great detail.
But just briefly: NO! creating a clustered index does NOT duplicate data! Where did you get that from??
What a clustered index does is reorder the data (according to the key), and the leaf-level nodes of the clustered index are the data pages - but those exist only once.
Some more resources of interest:
- Kimberly Tripp on Index Internals
- Kalen Delaney Workshop on Index Internals
- SQL Server Indexes: AN Introduction
- Introduction to Indexes
- Stairway to SQL Server Indexes: an Introduction
回答2:
Indexing views will duplicate data.
"The downside to this is that the indexed view is a full copy of the data from the underlying tables[...]"
http://strangenut.com/blogs/dacrowlah/archive/2008/11/26/creating-an-indexed-view-in-sql-server-2005-and-2008.aspx
来源:https://stackoverflow.com/questions/5402112/indexes-in-sql-server-internal-working-and-structure-of-indexes