Re: sql question
Posted in 1993
villy@uunet.uu.net (Will Hartung - Master Rallyeist) writes:
>Now on the other side of the coin, I've seen queries similiar to:
> select * from x,y
> where x.this=y.that and 1=1
>that have gone ballistic with the '1=1', when it should have been
>short circuited. Of course, there is nothing consistent as to WHICH
>queries take so long, as most uses of '1=1' are related to some kind
>of dynamic SQL built on the fly.
>It seems like the optimizer should be 'aware' that it is dealing with
>constants that are unaffected by the table data, and be able to make
>some assumptions about that data.
Try the above as:
select * from x,y
where 1=1 and x.this=y.that
The optimizer doesn't choke on this one (at least in 4.10 RDS).
Go figure.
----------------------------------------------------------------------------
Michael D Lemon J.L. Kisner & Co., Inc.
System Administrator mdl@world.std.com
Opinions will be prosecuted.
----------------------------------------------------------------------------
--
----------------------------------------------------------------------------
Michael D Lemon J.L. Kisner & Co., Inc.
System Administrator mdl@world.std.com
----------------------------------------------------------------------------