Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Does "WHERE 0=1" require a full table scan?

Re: Does "WHERE 0=1" require a full table scan?

From: Hari Vetsa <hvetsa_at_yahoo.com>
Date: 30 Jan 2004 14:44:06 -0800
Message-ID: <e1e4fa1e.0401301444.6f7d31c0@posting.google.com>


Looks like you are already aware in your C++ program that you have an empty list. By definition no records will be retrieved from RDBMS if you have an empty list on the right hand side of "IN" operator.

why bother asking Oracle RDBMS what you already know. just skip DB query and progress along.

Makes sense?

Wolfram Roesler <wr_at_grp.de> wrote in message news:<Xns94807C6718D20wrgrpde_at_130.133.1.4>...
> Hi,
>
> a simple question: For a query like "SELECT * FROM table WHERE 0=1",
> does Oracle do a full table scan, or does it optimize the query away
> and return nothing without accessing the table?
>
> The background for this question is, I'm writing a C++ function that
> takes a column name and a list of strings and creates a WHERE clause
> to search for these strings, like "column IN ('string 1','string 2',...).
> In case of an empty list I want to create a WHERE clause that matches
> nothing, and I'm pondering whether "WHERE 0=1" or "WHERE column!=column"
> would be better.
>
> Thanks for your help
> Wolfram Roesler
Received on Fri Jan 30 2004 - 16:44:06 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US