SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SQL Index Question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tooba
Posting Yak Master

143 Posts

Posted - 01/21/2013 :  19:09:13  Show Profile  Reply with Quote
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

USA
36636 Posts

Posted - 01/21/2013 :  19:10:47  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

143 Posts

Posted - 01/21/2013 :  22:45:26  Show Profile  Reply with Quote
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

USA
36636 Posts

Posted - 01/22/2013 :  00:14:07  Show Profile  Visit tkizer's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000