Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Does "WHERE 0=1" require a full table scan?
Hari Vetsa wrote:
> 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?
I've seen more than one application (including some DBMS vendor's JDBC driver)
do this with SQL queries they do not control, to get the result set metadata.
(I am not necessarily defending this, just reporting that it is done). Also
the general question is still apt, because the application/querier may not
know that an assembled query may include a qualifier which is easily detectable
in the DBMS at compiletime as like "where 1 = 0". All DBMSes I know do have
at least partially applicable capability of not searching/touching the real
data when the query search arguments are detectably unsatisfiable a priori.
The query will still be answered, and will include the metadata, even when
no rows satisfy.
Joe Weinstein at BEA
> > > Wolfram Roesler <wr_at_grp.de> wrote in message news:<Xns94807C6718D20wrgrpde_at_130.133.1.4>... >
![]() |
![]() |