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”.

  • GilaMonster (2/10/2011)


    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.

    Thanks a lot Gail Shaw for your reply