First thing, you say your primary concern is performance. Performance reading or performance writing?
Because in theory you could index a table to death which would make reads great, but they would need to be maintained and updated every time you inserted or updated a row.
Second select indicies should be based on which queries are frequently run against your table.
For example, imagine you have a table with columns ID, Type, TextValue
. In your application you have a GetByID()
method and a ListWithType()
method. Your indicies should be based on what SQL is trying to filter/join by. In this case ID (your PK obviously) and a non-unique index on Type.
- Decide which performance is important (read or write)
- Watch your code and observe the common and slow queries
- Create indicies based on the various filters/joins you're doing.
This is obviously a simplistic overview. I suggest you read up on how to read a SQL Execution Plan and change your indicies to improve it.
Finally, when you create indicies make sure you select an appropriate fill factor (this is based on how the table is used) or you'll be constantly rebuilding them.