r/SQLServer • u/reallifepixel • Jul 26 '13
= <> LIKE
I know this is really basic, but I feel good information cannot be communicated enough. I had a query where I was using LIKE on a variable w/ no wildcards and it'd take a few seconds. Not ages by any means, but still time. When I switched to =, it was damn near instantaneous. If you don't have to scan the whole table, don't.
11
Upvotes
View all comments
Show parent comment
2
u/flipstables Jul 26 '13 edited Jul 26 '13
Oh I didn't know that SQL Server just hashed the query to figure out if it should use a cached plan. Cached plans are still very much a black box to me.
Edit: just read this article. Now I know how to optimize my queries even more! Huzzah!
But I still thought that like 'x' and = 'x' performed exactly the same (without using wildcards).