Difference between SELECTs

Author: Grigore Dolghin

Posted: 2010-07-29 at 11:03:50

Hi everyone

I’m pretty sure you already know that, but anyway:

I tested today if the MS SQL Server’s Query Optimizer is smart enough, so it seems it is. There is no difference in executions plans for these two queries:

Select * From table1 Where Name Like ‘%’ Order By Name

And

Select * From table1

It seems it figures I want all the records and simply removes the where from the query. The good thing is I can always write LIKE parameterized queries, and if I need some of the records, I send the parameter; if I need them all, I send ‘%’ and there will no performance penalty.

--- StripMime Report -- processed MIME parts ---

multipart/alternative

text/plain (text body -- kept)

text/html

---

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/profox

OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/000001cb2f2f$42346710$c69d3530$@gmail.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2010 Grigore Dolghin