From: Michael Adler <adler@pobox.com>
To: Merlin Moncure <merlin.moncure@rcsonline.com>
Cc: pgsql-performance@postgresql.org
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] spurious function execution in prepared statements.
Date: Thu, 30 Sep 2004 10:13:24 -0400
Message-ID: <20040930141324.GA9170@pobox.com> (raw)
In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A74DD@Herge.rcsinc.local>
References: <6EE64EF3AB31D5448D0007DD34EEB3412A74DD@Herge.rcsinc.local>
On Thu, Sep 30, 2004 at 09:45:51AM -0400, Merlin Moncure wrote:
> Now, if the same query is executed as a prepared statement,
> prepare ps(...) as select f(t.c) from t where [expr] limit 1;
> execute ps;
>
> now, if ps ends up using a index scan on t, everything is ok. However,
> if ps does a seqscan, f executes for every row on t examined until the
> [expr] criteria is met. Is this a bug? If necessary I should be able
> to set up a reproducible example. The easy workaround is to not use
> prepared statements in these situations, but I need to be able to
> guarantee that f only executes once (even if that means exploring
> subqueries).
Here's another workaround that may let you use a prepared statement:
prepare ps(...) as
select f(c) from (select c from t where [expr] limit 1) as t1
-Mike
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: adler@pobox.com, merlin.moncure@rcsonline.com, pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] spurious function execution in prepared statements.
In-Reply-To: <20040930141324.GA9170@pobox.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox