in SQL server, select 1 is better than select *.
if you check the execution plan, you will find they have exactly same plan and performance. but during the stage of query plan, * is expanded to bind to all the columns in the underlying table. you can imagine this will have to retieve meta data from database that can be avoided in "select 1" syntax.
so the advantage of "select 1" is to avoid parsing uncessary information that will discarded during the execution.
No comments:
Post a Comment