Re: [HACKERS] Early evaluation of constant expresions (with PATCH) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Early evaluation of constant expresions (with PATCH)
Date
Msg-id 24796.937964075@sss.pgh.pa.us
Whole thread Raw
In response to Early evaluation of constant expresions (with PATCH)  (Bernard Frankpitt <frankpit@pop.dn.net>)
Responses Re: [HACKERS] Early evaluation of constant expresions (with PATCH)
List pgsql-hackers
Bernard Frankpitt <frankpit@pop.dn.net> writes:
> The solution that I propose is to include code in the optimizer that
> picks functions with constant arguments out of a qualification
> clause, and evaluates them.

This is something I had on my own to-do list, and I'm glad to see
someone beat me to it.  But you've only done half the job: you
should also be folding operators with constant arguments.

Also, you need to be wary of functions like now() and random().
There probably isn't any other way to handle these than to add a
column to pg_proc flagging functions that can't be constant-folded.

> Finally, there is the question of where in the planner should the
> early evaluation occur.  It is not obvious to me where the best point
> is, I chose to put it in
> plan/initsplan.c:add_restrict_and_join_to_rels().

I believe it would be best to do it considerably earlier, specifically,
before cnfify().  It might even be worth running the code twice,
once before and once after cnfify.

Also, probably we should apply it to the targetlist as well as the qual.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Problems with src/pl/tcl/mkMakefile.tcldefs.sh.in in 6.5
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Early evaluation of constant expresions (with PATCH)