Skip site navigation (1) Skip section navigation (2)

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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] spurious function execution in prepared statements.
Date: 2004-09-30 14:54:50
Message-ID: 16573.1096556090@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-performance
"Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com> writes:
> 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?

Works for me.

regression=# create function f(int) returns int as '
regression'# begin
regression'#   raise notice ''f(%)'', $1;
regression'#   return $1;
regression'# end' language plpgsql;
CREATE FUNCTION
regression=# select f(unique2) from tenk1 where unique2%2 = 1 limit 2;
NOTICE:  f(1)
NOTICE:  f(3)
 f
---
 1
 3
(2 rows)

regression=# prepare ps as
regression-# select f(unique2) from tenk1 where unique2%2 = 1 limit 2;
PREPARE
regression=# execute ps;
NOTICE:  f(1)
NOTICE:  f(3)
 f
---
 1
 3
(2 rows)

regression=#

You sure you aren't using f() in the WHERE clause?

			regards, tom lane

In response to

pgsql-performance by date

Next:From: Merlin MoncureDate: 2004-09-30 14:58:34
Subject: Re: spurious function execution in prepared statements.
Previous:From: Scott DunnDate: 2004-09-30 14:46:27
Subject: Web server to Database Taking forever

pgsql-hackers by date

Next:From: Merlin MoncureDate: 2004-09-30 14:58:34
Subject: Re: spurious function execution in prepared statements.
Previous:From: Stephan SzaboDate: 2004-09-30 14:45:40
Subject: Re: spurious function execution in prepared statements.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group