Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Usage of primary key in index
Message
From
19/03/2014 09:34:50
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Indexing
Title:
Usage of primary key in index
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01596859
Message ID:
01596859
Views:
37
I have a select command which has a table which is used in multiple joins. But, that table is not part of any WHERE clause, ORDER clause nor present in the field list. If you ask why I have multiple joins on that table, it is because sometimes user may enter search on those fields and they would then be needed in the WHERE clause. IAC, this is not related here.

So, knowing that, this table is used in four INNER JOINs. It is always the same syntax such as:

INNER JOIN Member ON Client.NoMember=Member.Numero
INNER JOIN Member AS Member2 ON Client.NoMember2=Member.Numero
INNER JOIN Member AS Member3 ON Client.NoMember3=Member.Numero
INNER JOIN Member AS Member4 ON Client.NoMember4=Member.Numero

However, when I look at the execution plan, on those four items, the plan is using an index which is totally not related instead of using the Member.Numero primary key index. It does indicate that Member.Numero is used in the Output. Yes, it is an output here but that would be much better optimized if it would use the Member.Numero primary key index instead.

Anyone has found a way around that?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform