I have table to store files. I store SHA256 hash in a column to uniquely identify a file. 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?
Advertisement
Answer
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);