我的表格(Products
)包含列(barcode PK
,name
)我希望通过name
进行有效的搜索方式,我读取了搜索的聚集索引速度?但是我如何使用它,任何人都可以解释聚集索引吗?
答案 0 :(得分:0)
A clustered index directs SQL to physically store the data in the ordinal position of the index value. So if you have 5 rows with the same clustered value, they are all store sequentially (a heap table) next to one another. SQL does not need to scan an entire table to find matching values. You may lose minor INSERT performance, but certain SELECT queries that use the clustered index field will be dramatically faster.
If you ran this query
SELECT * FROM MyTable WHERE ClusteredIndexField = 'A'
SQL knows that all rows with an "A" value in the clustered field are all together. Once it finds the first matching row, it iterates the next rows. SQL can reliably know not to search any longer as it knows no more rows can possibly match the condition.
http://www.sqlpassion.at/archive/2016/03/29/clustered-indexes-advantages-disadvantages/
,请删除Li