Home Forums SQL Server 2008 SQL Server 2008 - General “SELECT 1″ rather than a “SELECT *” when using an EXISTS or a NOT EXISTS clause”. RE: “SELECT 1? rather than a “SELECT *” when using an EXISTS or a NOT EXISTS clause”.

  • deepak.a (2/10/2011)


    Thanks for reply,if we use columns or * will it make any performance difference? and also

    Like ex : if exists(Select 1 ... ) or if exists(select Top 1 1 ....)

    No and no

    using a SELECT 1, avoids having to look at any of the meta-data that is not even needed to check the existancee of the records form the table?

    Got nothing to do with metadata. EXISTS only cares about whether there is a row or not, it doesn't look at columns, it doesn't care.

    Don't waste your time trying to do micro-optimisations. Silly tricks like this do not make major performance differences.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass