Question Sergey Madiev · Oct 30, 2019

Hi guys,
I ran into a strange (for me) situation, when I run same query but change the WHERE clause the plan is different and is not connected to the additional condition.
Query that doesn't use the necessary index:

SELECT * FROM Portal.ProductStats ps  left JOIN  Portal.ProductCacheUpdates pcu ON (pcu.Item=ps.Item) WHERE ps.Item=?
Takes 0.4 sec,  doesn't use index on item from Portal.ProductCacheUpdates table
SELECT * FROM Portal.ProductStats ps  left JOIN  Portal.ProductCacheUpdates pcu ON (pcu.Item=ps.Item) WHERE ps.Item=? AND  ps.dateImported<pcu.dateEdited
Takes 0.

9
0 700