本文介绍了sql server中的索引,内部工作和索引结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们在列上创建聚簇索引 CIX_FirstNames 时,比如 FirstNames ,那么SQL Server内部实际发生了什么?



我已经读过聚集索引创建数据的副本。



所以,sql server是否创建了一个新的索引表, IndexTable ,并将表中的所有FirstNames复制到 IndexTable ,当搜索到firstname时,它会从索引表中显示它吗?



这是聚集索引的实际工作吗?

解决方案

这是一个太大的主题,无法在这里快速回答 - 你需要自己动手:









  • 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 ?

    解决方案

    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:

    这篇关于sql server中的索引,内部工作和索引结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    07-24 13:35