开发者

Creating index on group of columns or separate index for each column, which is better?

I've used Database engine tuning advisor to generate Index recommendations for multiple queries separately. After doing so i got separate recommendation for each query. As a result i noticed that the column used in one 开发者_StackOverflow社区recommendation is used for another since the queries depends on the same table.

Can i create one effective recommendation after running the multiple queries together?


Yes. It is recommended that you run an entire workload through the database engine tuning advisor. See this similar question: Indexing by Database engine tuning advisor


It depends - fewer, but wider indices are typically better - if your queries actually do use those columns in the wide index!

If you have five queries, and each of them uses a different column in the WHERE clause, then a single, wide index won't be much help.

But if you have queries that all use some or the same columns (two, three columns), then a single, wide index on those three columns is better to use.

But be aware: the order of your columns in the index is important!

If you create an index on (col1, col2, col3) it can help with queries that have WHERE col1 = value1 or WHERE col1 = value1 AND col2 = value2 conditions.

It cannot however be used for a query with a WHERE clause like WHERE col3 = value3

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜