A SQL Query (I know it uses * !)
SELECT Table1.*, Table2.* FROM Table1 LEFT JOIN Table2 ON Table1.Id = Table2.IdAdd an index hint e.g.
SELECT Table1.*, Table2.* FROM Table1 WITH(INDEX(IndexName)) LEFT JOIN Table2 ON Table1.Id = Table2.IdYou can still add NOLOCK to that hint too...
SELECT Table1.*, Table2.* FROM Table1 WITH(INDEX(IndexName),NOLOCK) LEFT JOIN Table2 ON Table1.Id = Table2.IdA hint could equally have been applied to the joined table or both.
Links :
Brent Ozar has some good reasons for NOT using index hints though so it's only for use as a last resort.
Andrew Chen's post on Index Hints
You can also force SQL's choice of Query Plan
No comments:
Post a Comment