Re: [SQL] Simple Optimization Problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: secret <secret(at)kearneydev(dot)com>, PG-SQL <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: [SQL] Simple Optimization Problem
Date: 1999-05-10 16:29:26
Message-ID: 7551.926353766@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> writes:
> I have added this to our TODO list as:
> process const=const parts of OR clause first

I think that would be quite the wrong way to approach it. What we
need is a general-purpose rewriter phase that tries to evaluate
constant subexpressions, and is applied after the rest of rewrite
but before planner/optimizer. In this case

select * from po where (po_id=8888 or 0=8888);

would be reduced to

select * from po where (po_id=8888 or FALSE);

and then

select * from po where (po_id=8888);

which the optimizer knows what to do with. (cnfify() does some of this
but not enough.)

>> Is there any hope in 6.5 of the optimizer
>> handling this better?

Not for 6.5. 6.6 or 6.7 maybe...

regards, tom lane

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 1999-05-10 16:33:00 Re: [SQL] Strange behavior
Previous Message Bruce Momjian 1999-05-10 16:25:06 Re: [SQL] Confusion about DISTINCT.