简体   繁体   English

非聚集索引候选

[英]Candidate for Non-Clustered index

I have a table structure like below : 我有一个如下表结构:

FeatureList 功能列表

ID  - BIGINT - Primary Key  - Clustered Index
VIN - VARCHAR(50)
Text - VARCHAR(50)
Value - VARCHAR(50)

Most of the query I execute on this are like : 我对此执行的大多数查询如下:

SELECT * FROM FeatureList WHERE VIN = 'ABCD'    --- Will give multiple records

OR 

DELETE FROM FeatureList WHERE VIN = 'ABCD'

I want to know, is VIN column is a good candidate for nonclustered index? 我想知道, VIN列是否适合非聚集索引? Or it might degrade the performance? 否则可能会降低性能?

Not declaring an index on VIN absolutely will drastically degrade performance. 声明VIN绝对严重降低性能。 You take a small performance hit on each insert, delete, or update involving VIN. 您对涉及VIN的每个插入,删除或更新的性能影响不大。 Reads (especially once you get into millions of records) will run orders of magnitude faster. 读取(尤其是一旦进入数百万条记录时)将使运行速度提高几个数量级。

As for BIGINT versus INT, I generally go for BIGINT. 至于BIGINT与INT,我通常会选择BIGINT。 Yes, it takes up a bit more disk space. 是的,它占用了更多的磁盘空间。 Yes, it takes up a bit more memory. 是的,它占用了更多的内存。 The plus side for me, though, is that I never, ever have to worry about migrating the table (and every other table that takes ID as a foreign key) to BIGINT. 不过,对我来说,好的一面是,我永远不必担心将表(以及其他所有将ID作为外键的表)迁移到BIGINT。 Been there. 到过那里。 Done that. 做到了。 The extra space is worth it. 额外的空间是值得的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM