|
Tested on Oracle 11g and as I expected, I could no reproduce the stalling behavior. An interesting tidbit is that Oracle generates a SQL statement like the following:
WHERE (ITEM_ID,PLANT_ID) IN ((?,?),(?,?),(?,?),...)
which the equivalent SQL Server's clause is:
WHERE ((ITEM_ID=? AND PLANT_ID=?) OR (ITEM_ID=? AND PLANT_ID=?) OR ... (ITEM_ID=? AND PLANT_ID=?))
I am curious if the following might be a more efficient SQL Server equivalent on 2008 and up:
SELECT *
FROM EntityClass AS T
WHERE EXISTS (
SELECT *
FROM (VALUES (?,?), (?,?), (?,?), (?,?)) AS V(ITEM_ID,PLANT_ID)
WHERE T.ITEM_ID = V.ITEM_ID
AND T.PLANT_ID = V.PLANT_ID
)
This avoids the 'OR' operator and from what I have understood performs better but have yet to test it. I'm trying to see if there is any logical way to create such an EXISTS expression but so far I haven't found one yet.
|