In(..) and Like xxxx% performance Hi,
I am experiencing strange SQL server behavior,
The table has an index on (filed1, field2) - which is primary key.
if I do select where field1 = 'a' and field2 like '123%' runs fast.
if I do select where field1 = 'b' and field2 like '123%' runs fast
too.
if I do select where field1 in ('a','b') and field2 like '123%' the
damn thing runs forever.
What is interesting, the SQL plan is perfectly using primary index and
selection is translated into "good" ranges for field2. It fills like
server does not take in consideration that field2 is in index.
Any ideas what's going on? I'd hate to use two selects to avoid
problem.
Thank you.
M.Q. |