Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
195 views
in Technique[技术] by (71.8m points)

sql server - Multiple composite index vs single non-clustered column store index

We have a OLTP system and we have got a grid, which is containing close to 20 columns, coming from multiple tables. The grid loaded based on search parameters involving around 6 columns. The data is huge with 100M rows coming from background tables.

To improve the performance of the grid loading, we have created indexed view with single unique clustered index. We are currently want to see how we can improve the performance of search parameters: a,b,c,d,e,f

The search can be based on any of the combination: (a), (a,c),(d,e), (a,b,c) ... (a,b,c,d,e,f)

We are thinking of either going for one of the below options:

  • Multiple composite indexes on indexed view with specific access patterns like (a,b), (b,d), (a,b,c) etc.
  • Single non-clustered columnstore index on indexed view, which will be helpful to satisfy all different access patterns like (a,b), (b,d), (a,b,c) etc. with included column of 20 columns

Can you please suggest, which is better approach ?

UPDATE: Just read that, non-clustered column store index does not support include columns. Will try further and update the answer, either by comments, if question is closed or by answering it.

question from:https://stackoverflow.com/questions/65913023/multiple-composite-index-vs-single-non-clustered-column-store-index

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since there are so many combinations to consider, you would need a lot of indexes.

So, at the most, I would do single or two column indexes (depending how selective the first column is) for a few popular columns. Anything wider is a waste of time, because the index will be selective either way.

You most definitely can do INCLUDE columns on non-clustered indexes. In this instance, it's only worth it if there are just those columns brought back, otherwise key lookups will be necessary in any case.

You should also consider something like OPTION (RECOMPILE) on your query. See #BackToBasics: An Updated Kitchen Sink Example by Aaron Bertrand.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...