Re: Allow use of immutable functions operating on constants with constraint exclusion

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "Marshall, Steve" <smarshall(at)wsi(dot)com>
Cc: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Allow use of immutable functions operating on constants with constraint exclusion
Date: 2007-05-08 13:10:56
Message-ID: 20070508131056.GA17033@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2007-05-08 13:12:52 Re: [COMMITTERS] psqlodbc - psqlodbc: Put Autotools-generated files into subdirectory
Previous Message Heikki Linnakangas 2007-05-08 12:57:27 Re: Seq scans roadmap