Re: Semantic optimization is posible?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Sebastián Ávila <gsebas27(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Semantic optimization is posible?
Date: 2005-10-24 10:54:52
Message-ID: 20051024105452.GB27589@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 24, 2005 at 12:11:55PM +0200, Sebastián Ávila wrote:
> Hello people,
>
> I'm thinking to add a stage before the optimizer and after the parser
> with a basic rewriter in order to flatten all nested queries using a
> pattern and table statistics, here I also can use assetions the
> database have. Another and complementary possibility is that I can
> make annotations on the query's data structure so that a later stage
> can use the semantic info to either prune the search space or to pick
> a specific query execution strategy.
> Summarizing, I want to add semantic optimization into the query
> processing execution.
>
> I need to hear your opinion and your ideas about this, because I have
> to choose between this project about semantic optimization and other
> about software analysis. My problem is that I don't know how much
> dificult can be to do semantic optimization and to do it well. What is
> your opinion about? I have to implement the project in 5 months.

Why does it need to be a seperate stage? It is "optimising" right, so
why wouldn't it be part of the "optimizer"?

Currently things like pulling up subqueries, expanding immutable
functions, flattening and reordering joins are all done in the
optimiser. Looks like your stuff should be too...

AIUI, mosts parts of the optimiser deal with questions like: give me
the best plan to evaluate <expression>. So if you're dealingwith say an
EXCEPT node, you can add your special checks to see if it can work a
better way. If it can, evaluate the cost of the plan and compare it
with other possibilites. Eventually you return the best plans.

Note, generally you return sets of plans because which plan is best may
depend on what uses it. A "LIMIT 1" plan may require a completely
different strategy to a full scan plan, but you don't generally know
that down at the lower levels.

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-10-24 12:20:07 Re: Question about Ctrl-C and less
Previous Message Sebastián Ávila 2005-10-24 10:11:55 Semantic optimization is posible?