Re: [PERFORM] spurious function execution in prepared statements.

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: [PERFORM] spurious function execution in prepared statements.
Дата
Msg-id 20040930074054.T8163@megazone.bigpanda.com
обсуждение исходный текст
Ответ на spurious function execution in prepared statements.  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
Список pgsql-hackers
On Thu, 30 Sep 2004, Merlin Moncure wrote:

> OK, I have a situation that might be a performance problem, a bug, or an
> unavoidable consequence of using prepared statements.  The short version
> is that I am getting function executions for rows not returned in a
> result set when they are in a prepared statement.
>
> In other words, I have a query:
> select f(t.c) from t where [boolean expr on t] limit 1;

An actual boolean expr on t? Or on a column in t?

> because of the limit phrase, obviously, at most one record is returned
> and f executes at most once regardless of the plan used (in practice,
> sometimes index, sometimes seq_scan.
>
> 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).

I think a reproducible example would be good. Simple attempts to duplicate
this on 8.0b2 have failed for me, unless I'm using order by.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Gaetano Mendola
Дата:
Сообщение: FlushRelationBuffers error
Следующее
От: Tom Lane
Дата:
Сообщение: Re: spurious function execution in prepared statements.