Help required while creating Index

  • 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])

  • 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

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply