Years ago, it was common to write

where exists (Select * from some_table where some_condition)

Last year I noticed that many t-sql scripts switched to using the number 1 instead of the star

where exists (Select 1 from some_table where some_condition)

just on SO I saw this Oracle example


Is this a common pattern with Oracle? And which are the performance arguments to use something like this.


2 Answers 2


Short answer: I would hope not!

Even the SELECT 1 idiom may have outlived its usefulness, as database engines have advanced enough to recognize that you don't really want the rows, you just want to know if the rows exist. I've looked at execution plans in SQL 2005, and have generally seen these re-written as joins, even where SELECT * is used.


In Oracle it doesn't matter performance wise. You can even put 1/0 there and the statement won't return a divide by zero error because the expression isn't evaluated.

  • 1
    Does this need to be closed in favor of relying on the SO question? Is this one of those "migrate the SO to dba.SE"?
    – jcolebrand
    Commented Jan 6, 2011 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.