Re: [SQL] Good Optimization - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] Good Optimization
Date
Msg-id 26591.931371048@sss.pgh.pa.us
Whole thread Raw
In response to Re: [SQL] Good Optimization  (wieck@debis.com (Jan Wieck))
Responses Re: [SQL] Good Optimization  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-sql
wieck@debis.com (Jan Wieck) writes:
>     I think the best place for it will  be  at  the  top  of  the
>     optimizer.    It's   more   an  optimization  issue  even  if
>     implemented in rewriting technique.

I have thought for some time that we need an additional phase in between
the rewriter and the planner/optimizer proper.  This phase would be the
right place to do constant-subexpression folding, cnfify(), and any
other rearrangements of the parse tree that would be likely to help the
planning process.  So far, the only specific example I had in mind was
the index restriction clauses that are added for LIKE and ~ matches with
a constant initial pattern --- those are currently done by gram.y but
I think they need to happen much later.  If this idea of propagating
restriction clauses across a join is really worthwhile, then this new
optimization phase would be the right place for that too.

The reason I'd prefer to keep it separate from the rewriter is that the
rewriter is mostly concerned with functionality (implementing views etc)
whereas this new module would be concerned with optimization.  Obviously
you do not want to start worrying about optimization until you've got
the fully expanded query available.
        regards, tom lane


pgsql-sql by date:

Previous
From: Steven Bradley
Date:
Subject: Index on TIMESTAMP
Next
From: Bruce Momjian
Date:
Subject: Re: [SQL] Oddities with NULL and GROUP BY