简体   繁体   English

SQL Server 性能优化

[英]SQL Server performance optimization

I have table to store files.我有表来存储文件。 I store SHA256 hash in a column to uniquely identify a file.我将 SHA256 哈希存储在一列中以唯一标识文件。 Before inserting new file I check for duplicate file using the hash and if it exists already I don't insert.在插入新文件之前,我使用哈希检查重复文件,如果它已经存在,我不插入。

For example my query can be:例如我的查询可以是:

select filename 
from filetable 
where filehash = 'xyz'

Right now there are only a few hundred files.现在只有几百个文件。

When this number grows to a few hundred thousand next year, how do I optimize the performance?当这个数字明年增长到几十万时,我该如何优化性能?

For that specific query just add the index:对于该特定查询,只需添加索引:

create index ix1 on filetable (filehash);

If you want to make it even faster (probably not needed) you can create a covering index instead:如果你想让它更快(可能不需要),你可以创建一个覆盖索引

create index ix1 on filetable (filehash, filename);

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

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