Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL table indexing

Author  Topic 

sportsguy
Starting Member

39 Posts

Posted - 2013-12-01 : 15:54:39
I have created a SS warehouse, so perfect normalization is not a requirement. I have created non unique indexes of 5-7 columns
My question is:
for these 5-7 fields, should I create one index of 5-7 fields,
or 5-7 individual indexes?

thanks in advance. . .
sportsguy

MS Access 20 years, SQL hack

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-02 : 04:35:26
depends on how you use these columns in the queries. whats the frequency of using them together for filtering.selecting against using them separately?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-12-02 : 16:21:58
The thing to know for deciding on indexes is when the index will not be used. For instance:

index1234 (col1, col2, col3, col4)

this index will be used when filter and/or joining is done with:
- all four columns
- only these 3: col1, col2, col3
- only these 2: col1, col2
- only this: col1

this index will not be for any other combination of columns.
In other words look at the index columns from left to right.
To use an index for a query that only filters on col3 then you need an index that either is only on col3 or starts with col3


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -