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

From ITAGAKI Takahiro
Subject Re: Allow use of immutable functions operating on constants with constraint exclusion
Date
Msg-id 20070509173454.6742.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
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
"Marshall, Steve" <smarshall@wsi.com> wrote:

> the first query would be optimized using 
> constraint exclusion, while the second query would not:
> 
> SELECT * FROM test_bulletins WHERE created_at > '2006-09-09 
> 05:00:00+00'::timestamptz;
> SELECT * FROM test_bulletins WHERE created_at > '2006-09-09 
> 05:00:00+00'::timestamptz + '0 days'::interval;

Hmmm... CE seems to be still not enough to optimize complex expressions.
If I added the wrapper function, it worked.

CREATE FUNCTION timeadd(timestamptz, interval) RETURNS timestamptz   AS $$ SELECT $1 + $2; $$ LANGUAGE sql IMMUTABLE;

SELECT * FROM test_bulletins WHERE created_at >   timeadd('2006-09-09 05:00:00+00', '0 days');


I noticed that we should be careful about CE with prepared statements
and functions. Seamless partitioning requires more works.

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




pgsql-hackers by date:

Previous
From: "Zeugswetter Andreas ADI SD"
Date:
Subject: Re: Seq scans roadmap
Next
From: Michael Meskes
Date:
Subject: Re: Windows Vista support (Buildfarm Vaquita)