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/12/2011)


    amenjonathan (2/11/2011)


    I also use SELECT NULL.

    Personally if something is faster and there's virtually no complexity difference, I use the faster version. Why waste where there is no need is my motto.

    The point is, it's not significantly faster, it's a couple of nanoseconds at best. It's micro-optimisation, it's a waste of time for no value.

    Use EXISTS (Select *, EXISTS (Select 1, EXISTS (Select NULL, or any other form as they are not going to make anything resembling a noticeable difference.

    If I'm typing it out for the first time and I type SELECT NULL instead of SELECT *, I don't see how that wastes any time. Yes it does not provide a lot of value, but hey a tiny amount of value for free is still better than no value for free. Also, again this is just the way I do things, it helps me stay vigilant with optimization.

    Again my motto is why not do what's most optimal if it doesn't require any additional work?

    -------------------------------------------------------------------------------------------------
    My SQL Server Blog