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 -> AND 1=1

AND 1=1

From: Patricia Rodriguez-Tomé <prtome_at_geneprot.com>
Date: Tue, 15 Oct 2002 08:45:59 +0200
Message-ID: <3DABB9A7.70905@geneprot.com>

Il y a une petite discussion dans les news, ou quelqu'un a regardé le code SQl generé par un soft (a pas dit lequel) et qui lui mettait une clause "AND 1=1"

il a demandé ŕ quoi cela pouvait bien servir. Et si cela intervenait dans l'execution plan. Voici la partie intéréssante des réponses

There are times when using 1=1 makes a significant difference in the
> execution plan selected by the CBO. And thus, it can dramatically improve
> performance of a query.
>
> As to why? I can't say. But I had a query once where dragging DUAL into it
> provided the same improvement.

Actually, I don't think anyone can say. For an interesting paper (especially if you read carefully with the idea of looking for an explanation of this DUAL effect) see the Milsap paper at hotsos.com about when to add an index.

In that context, the 1=1 becomes a way of saying there is low block-selectivity, a language that generates OCI calls might do it whenever a where clause on a small field in a large row is used.

>
> Go figure. Not doubt Howard, Jonathan, Tom, and other can. I can't.

-- 
Patricia Rodriguez-Tomé, Ph. D.
Senior DataBase Manager
GeneProt Inc.
Geneva - Switzerland
Received on Tue Oct 15 2002 - 01:45:59 CDT

Original text of this message

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