SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Help required while creating Index


Help required while creating Index

Author
Message
Zohaib Anwar
Zohaib Anwar
SSC Journeyman
SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)

Group: General Forum Members
Points: 98 Visits: 192
These index came from the query that reported missing indexes, but I’m just trying to get a better understanding and I have following questions: I would appreciate if anyone can help and provide guidance.


On the AddressLink indexes – do we need two separate indexes for AddressID, DefaultAddress where one includes CustomerID and one includes VendorID? The index on CustomerID includes AddressID, but the one on VendorID doesn’t include it?
CREATE INDEX [IX_New_index_AddressLink1] ON [dbo].[AddressLink] ([AddressID], [DefaultAddress]) INCLUDE ([CustomerID])
CREATE INDEX [IX_New_index_AddressLink2] ON [dbo].[AddressLink] ([AddressID], [DefaultAddress]) INCLUDE ([VendorID])
CREATE INDEX [IX_New_index_AddressLink3] ON [dbo].[AddressLink] ([CustomerID]) INCLUDE ([AddressID])
CREATE INDEX [IX_New_index_AddressLink4] ON [dbo].[AddressLink] ([VendorID])



On the AddressTaxLink indexes – both indexes are on AddressID, but one includes TaxID and the other doesn’t. Do we need two indexes here?
CREATE INDEX [IX_New_index_AddressTaxLink1] ON [dbo].[AddressTaxLink] ([AddressID])
CREATE INDEX [IX_New_index_AddressTaxLink2] ON [dbo].[AddressTaxLink] ([AddressID]) INCLUDE ([TaxID])

Similar questions for the indexes on ContactAddressLink – both are on ContactID, but one includes AddressID and the other doesn’t – are both needed?
CREATE INDEX [IX_New_index_ContactAddressLink1] ON [dbo].[ContactAddressLink] ([ContactID])
CREATE INDEX [IX_New_index_ContactAddressLink2] ON [dbo].[ContactAddressLink] ([ContactID]) INCLUDE ([AddressID])

On the ContactPhoneLink indexes – one of the indexes includes ID, PhoneID, PhoneTypeID, and DefaultPhone and one of the indexes includes three of those four fields – do we need both indexes or can we just create the one that has all four fields?
CREATE INDEX [IX_New_index_ContactPhoneLink2] ON [dbo].[ContactPhoneLink] ([ContactID]) INCLUDE ([ID], [PhoneID], [PhoneTypeID], [DefaultPhone])
CREATE INDEX [IX_New_index_ContactPhoneLink3] ON [dbo].[ContactPhoneLink] ([ContactID]) INCLUDE ([PhoneID], [PhoneTypeID], [DefaultPhone])

On the OrderCommission indexes – do we need both or could we create just the first one?
CREATE INDEX [IX_New_index_OrderCommission2] ON [dbo].[OrderCommission] ([OrderID], [PrimarySalesperson]) INCLUDE ([SalespersonID])
CREATE INDEX [IX_New_index_OrderCommission3] ON [dbo].[OrderCommission] ([PrimarySalesperson]) INCLUDE ([OrderID], [SalespersonID])

On the Orders indexes – do we need all three of these or could we create one that included ID, CustomerPO, OrderDate, OrderNumber?
CREATE INDEX [IX_New_index_Orders7] ON [dbo].[Orders] ([OrderTypeID]) INCLUDE ([ID], [CustomerPO])
CREATE INDEX [IX_New_index_Orders8] ON [dbo].[Orders] ([OrderTypeID]) INCLUDE ([ID], [OrderDate])
CREATE INDEX [IX_New_index_Orders9] ON [dbo].[Orders] ([OrderTypeID]) INCLUDE ([ID], [OrderNumber])
GilaMonster
GilaMonster
SSC Guru
SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)

Group: General Forum Members
Points: 88274 Visits: 45277
Please don't cross post. It just wastes people's time and fragments replies.

No replies to this thread please. Direct replies to http://www.sqlservercentral.com/Forums/Topic1567529-2799-1.aspx

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search