in a query, is there any performance hit by doing a where clause like so
select bunchofstuff from sometable where column like '%'
vs
select bunchofstuff from sometable
Building some dynamic queries, just curious. Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
On SQL 2005, SP3 running the following
suggests that the cost will be almost identical, since both return the same result set:
Switching on the query plans and/or statistics IO shows that
select * from sys.columns where name like '%'is marginally more expensive (51% of query cost vs. 49% forselect * from sys.columns), since it appears that the filter is parsed and applied even though it has no effect.