简体   繁体   中英

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? Or it might degrade the performance?

Not declaring an index on VIN absolutely will drastically degrade performance. You take a small performance hit on each insert, delete, or update involving 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. 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. Been there. Done that. The extra space is worth it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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