Re: Allow use of immutable functions operating on constants with constraint exclusion - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Allow use of immutable functions operating on constants with constraint exclusion
Date
Msg-id 20070508131056.GA17033@svana.org
Whole thread Raw
In response to Re: Allow use of immutable functions operating on constants with constraint exclusion  ("Marshall, Steve" <smarshall@wsi.com>)
List pgsql-hackers
On Tue, May 08, 2007 at 08:08:28AM -0400, Marshall, Steve wrote:
> However, I think it would be possible to expand immutable functions
> operating on constants to optimize constraint exclusion.  Immutable
> functions will always return the same result given the same inputs, so
> this would be safe.  Currently, immutable functions are not expanded
> during planning such that the first query would be optimized using
> constraint exclusion, while the second query would not:

The problem with this is that at planning time you don't necessarily
have an active transaction snapshot. Prepared statements are the
obvious example, but I think even in one-off statements there's no
snapshot until after the planner has completed. This is also one of the
problems with type input/output functions looking up stuff in tables.

There was discussion about the handling type input/output functins and
casts as a sort off InitExpr that is executed once, then inserted into
the tree. However, that would still be too late to affect the planning.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Seq scans roadmap
Next
From: Hiroshi Inoue
Date:
Subject: Re: [COMMITTERS] psqlodbc - psqlodbc: Put Autotools-generated files into subdirectory