Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA35611 for ; Wed, 7 Jul 1999 14:11:35 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id OAA26593; Wed, 7 Jul 1999 14:10:48 -0400 (EDT) To: jwieck@debis.com (Jan Wieck) cc: secret@kearneydev.com (secret), pgsql-sql@postgreSQL.org, johnridout@ctasystems.co.uk Subject: Re: [SQL] Good Optimization In-reply-to: Your message of Wed, 7 Jul 1999 19:22:57 +0200 (MET DST) Date: Wed, 07 Jul 1999 14:10:48 -0400 Message-ID: <26591.931371048@sss.pgh.pa.us> From: Tom Lane 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