Re: Allow use of stable functions with constraint exclusion - Mailing list pgsql-hackers

From ITAGAKI Takahiro
Subject Re: Allow use of stable functions with constraint exclusion
Date
Msg-id 20070508165000.6D3B.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
Whole thread Raw
In response to Re: Allow use of stable functions with constraint exclusion  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Allow use of immutable functions operating on constants with constraint exclusion  ("Marshall, Steve" <smarshall@wsi.com>)
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "Marshall, Steve" <smarshall@wsi.com> writes:
> > I have developed a small patch to optimizer/util/plancat.c that 
> > eliminates one of hte caveats associated with constraint exclusions, 
> > namely the inability to avoid searching tables based on the results of 
> > stable functions.
> 
> Do you not understand why this is completely unsafe?

I think the proposal itself is very useful, because time-based
partitioning is commonly used and functions like now() or
CURRENT_TIMESTAMP are marked as stable.

I'm not clear why the optimization is unsafe. I'm confused to read the
definition of stable functions in our documentation. Which is required
for stable functions 'stable in a single table scan' or 'stable in a
SQL statements' ? If the latter definition is true, can we use them
in constraint exclusions?

| STABLE indicates that the function cannot modify the database, and
| that within a single table scan it will consistently return the same
| result for the same argument values, but that its result could change
| across SQL statements.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center




pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [COMMITTERS] psqlodbc - psqlodbc: Put Autotools-generated files into subdirectory
Next
From: Peter Eisentraut
Date:
Subject: Re: [COMMITTERS] psqlodbc - psqlodbc: Put Autotools-generated files into subdirectory