Search code examples
sqlperformancewildcardsql-execution-planoverhead

Sql wildcard: performance overhead?


I've Googled this question and can't seem to find a consistent opinion, or many opinions that are based on solid data. I simply would like to know if using the wildcard in a SQL SELECT statement incurs additional overhead than calling each item out individually. I have compared the execution plans of both in several different test queries, and it seems that the estimates always read the same. Is it possible that some overhead is incurred elsewhere, or are they truly handled identically?

What I am referring to specifically:

SELECT *

vs.

SELECT item1, item2, etc.

Solution

  • SELECT * FROM...
    

    and

    SELECT every, column, list, ... FROM...
    

    will perform the same because both are an unoptimised scan

    The difference is:

    • the extra lookup in sys.columns to resolve *
    • the contract/signature change when the table schema changes
    • inability to create a covering index. In fact, no tuning options at all, really
    • have to refresh views needed if non schemabound
    • can not index or schemabind a view using *
    • ...and other stuff

    Other SO questions on the same subject...