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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SQL Index Question

Author  Topic 

tooba
Posting Yak Master

224 Posts

Posted - 2013-01-21 : 19:09:13
Hi guys,

I have question for you guys,

I have one table ABC (For Example) and Table ABC has few Indexes

First Index on Table ABC
COLUMN_NAME = ABC.COLUMN1
COLUMN_NAME = ABC.COLUMN2

Second Index
Column_Name = ABC.COlumn1

My question is Would it be same. I can understand if i have Query with both column COlumn1 & Column2
then First Index is good. What you think should i delete Second Index or Keep, if i keep second
index its not gonna slow down the performance?

Please guide me.

Thank You

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-01-21 : 19:10:47
For this simplified example, the second index is considered a duplicate and should be dropped.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tooba
Posting Yak Master

224 Posts

Posted - 2013-01-21 : 22:45:26
Thanks for reply tkizer, One question
First Query:-
Select * from ABC
Where Column1 = '123' and Column2 like '%jaz'

Second Query:-
Select * from ABC
Where Column1 = '123'

Question:- In First and second query what do you think, which Index SQL going to check (First Index or Second Index)?

Thank You.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-01-22 : 00:14:07
It can use either index. The second index is going to slow down DML, so get rid of it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -