SQL Server – Is It Bad to Index Every Possible Column Combination?

index-tuningsql serversql-server-2017t-sql

I am working on a reporting system that will require large select queries, but is based on a database that is only filled once. The database management system is Microsoft SQL Server 2017. There is probably a better way to design a system like this, but let's approach this theoretically.

Theoretically speaking:

  1. If we have a very large database (150M+ rows on several tables)
  2. And we can assume the database will only be populated once.

Could indexing every possible column combination have a negative performance impact on a select query?

Best Answer

Yes, it will influence initial plan compile time as the optimizer will have many extra access paths to the data to consider.

Since you're on SQL Server 2017, loading once, and running reports, why not just use a clustered column store index instead?

That seems to be the ideal solution to your need to index every possible column combination.

Columnstore indexes - Overview