Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> AND 1=1
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 - SwitzerlandReceived on Tue Oct 15 2002 - 01:45:59 CDT