据说索引增加了表行的检索速度,但是它们在插入/更新/删除上是开销。我想知道索引如何成为索引体系结构的开销? This链接对我来说并不明确-我在群集索引和非群集索引之间感到困惑。
答案 0 :(得分:1)
表上任何数据更改都会导致索引更改。例如,您要插入数据
没有索引的操作将是(大约)
1. insert data
使用索引操作将(大约)
1. insert data
2. update the index
因此,由于有索引,因此您可以看到还有其他操作(开销)。
答案 1 :(得分:0)
这个链接对我来说并不清晰-我在聚集索引和非聚集索引之间感到困惑。
所以,我愿意解释clusters and non-cluster indexes
(根据我的理解),
匹配
表格:书
行:页面
行地址:页码
对
非集群索引=图书,而集群索引=乳制品
非集群索引说明
集群索引说明
让我在Table的帮助下进行解释:
create table #nonCluster (i int, name varchar(10))
create table #Cluster (i int, name varchar(10))
CREATE NONCLUSTERED INDEX #nonCluster
ON #noncluster(i); -- Here Non-Cluster Index
CREATE CLUSTERED INDEX #Cluster
ON #cluster(i); -- Here Cluster Index
insert #nonCluster values(1,'one'),(9,'nine'),(5,'five') -- Random data are inserted.
insert #Cluster values(1,'one'),(9,'nine'),(5,'five') -- Random data are inserted.
select * from #nonCluster -- Here we see the order of rows. That is un-order.
select * from #Cluster -- Here we see the order of rows. That is order.
insert #nonCluster values(7,'seven') -- Random data are inserted.
insert #Cluster values(7,'seven') -- Random data are inserted.
select * from #nonCluster -- Here we see the no change on order of rows. Rows are in how we were inserted.
select * from #Cluster -- Here we see the sorted order of rows.
insert #nonCluster values(2,'two')
insert #Cluster values(2,'two')
select * from #nonCluster -- Hence explained With help of order of rows.
select * from #Cluster -- Hence explained With help of order of rows.