Unanswered: NOT IN slows query down the first time but subsequent times
I have an UPDATE query with several restrictions including a huge NOT IN containing about two hundred two-character strings. My query is taking about a minute to run the first time it is called from my ODBC application then runs in no time at all subsequent times. If I comment out the NOT IN clause then it runs quickly the first time as well as in subsequent calls. On Oracle the same query performs just as fast the first time as it does subsequent times. This is suggesting to me that SQL Server is perhaps creating a temporary table with all the two-character strings and caching it for all successive calls. My customers typically only run the query once so would prefer if it ran quickly first time. Is there a faster way to perform the NOT IN restriction? My app allows for one query to be run if the user is running SQL Server and another one on Oracle. TIA.
a = b
x = y
AND z NOT IN ('AA', 'AB' ... 'QG', 'ZZ')