indexing - Multiple column indexes optimization for multiple column queries on SQL Server -


i have 1 table [table] 2 columns needs filtered: [column1] , [column2].

in program execute query like:

select * [table] [column1] = 'foo' , [column2] = 'bar'; 

which faster:

  1. creating 2 indexes, 1 on each column. ([column1] , [column2])
  2. creating 1 index containing both columns. ([column1]+[column2])

this question have been bugging me while, have no idea how query optimization works , how sql server uses created indexes speed queries.

second 1 always faster this query - need put more selective 1 first (in order of indexes) benefit more. exception if performance reasons, sql decides use clustered index ignores non-clustered.

the combination of 2 values create more selective criteria. helps performance since there no bookmark lookup required on covering index.

bookmark lookups source of major performance degradation , why covering index better 2 indexes.

update

bear in mind, if have index column1+coulmn2, searches on column2 cannot use index need separate index on column2 well.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -