Home  >  Article  >  Database  >  SQL Server Insert 操作效率(堆表 VS 聚集索引表)

SQL Server Insert 操作效率(堆表 VS 聚集索引表)

WBOY
WBOYOriginal
2016-06-07 17:43:161010browse

SQL Server的Insert操作在堆表或者聚集索引表的时候,哪个效率更高?为什么高? 之前有同事问过我这个问题,为了确保日志库的记录效率,于是我做了简单测试了,首先要先强调几点概念: 堆表:没有聚集索引的表,记录通过IAM页以及PFS页来确定哪页有空闲空间

  “SQL Server的Insert操作在堆表或者聚集索引表的时候,哪个效率更高?为什么高?”

  之前有同事问过我这个问题,虚拟主机,为了确保日志库的记录效率,于是我做了简单测试了,首先要先强调几点概念:

 

  堆表:没有聚集索引的表,香港服务器,记录通过IAM页以及PFS页来确定哪页有空闲空间。

  聚集索引表:有聚集索引的表,记录是根据聚集键值所在页的键值逻辑顺序维护的

 

Demo:如下

  分别对堆表和聚集表进行5个并发线程,网站空间,每个线程各10000次循环插入

 1.  堆表测试

Insert_Test (id int identity, name char(200)) go

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn