Re: Allow use of stable functions with constraint exclusion

From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: "Marshall, Steve" <smarshall(at)wsi(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Allow use of stable functions with constraint exclusion
Date: 2007-05-08 08:19:33
Message-ID: 20070508165000.6D3B.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> "Marshall, Steve" <smarshall(at)wsi(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2007-05-08 08:56:04 Re: psqlodbc - psqlodbc: Put Autotools-generated files into subdirectory
Previous Message Tom Lane 2007-05-08 05:29:23 Re: autovacuum starvation