Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for indexing foreign keys on a large table

I have a large table (SQL Server 2008) with almost 3 million rows. It currently has a clustered index on it's primary key, and a non-clustered index on its foreign key.

Almost all the queries on the table are reads based on the foreign key.

  1. Should I change the index on the table to be against the foreign key?
  2. What is the best process for doing this?

Thanks

like image 490
cman77 Avatar asked Nov 05 '22 00:11

cman77


1 Answers

Without knowing more about your situation, I think that changing the non-clustered index to be a non-clustered, covering index would be the best solution.

http://www.simple-talk.com/sql/learn-sql-server/using-covering-indexes-to-improve-query-performance/

like image 148
ta.speot.is Avatar answered Nov 09 '22 04:11

ta.speot.is