From: | "culley harrelson" <culley(at)fastmail(dot)fm> |
---|---|
To: | "pg-general" <pgsql-general(at)postgresql(dot)org> |
Subject: | any benefit to preparing a sql function? |
Date: | 2004-07-22 21:58:05 |
Message-ID: | 1090533485.23982.200903694@webmail.messagingengine.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Is there any benefit to preparing a call to a pre-defined sql function
or is the sql function already optimized?
create temp table foo(col1 integer);
insert into foo(col1) values(1);
insert into foo(col1) values(2);
insert into foo(col1) values(3);
insert into foo(col1) values(4);
create or replace function testfunc(integer) returns foo as 'select *
from foo where col1 = $1;' language sql;
prepare myplan(integer) as select * from testfunc($1);
execute myplan(2);
They look exactly the same:
testdb=# explain execute myplan(2);
QUERY PLAN
-----------------------------------------------------------------
Function Scan on testfunc (cost=0.00..12.50 rows=1000 width=4)
(1 row)
testdb=# explain select * from testfunc(2);
QUERY PLAN
-----------------------------------------------------------------
Function Scan on testfunc (cost=0.00..12.50 rows=1000 width=4)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-07-22 22:37:21 | Re: [ADMIN] how to find transaction associated with a lock |
Previous Message | Si Chen | 2004-07-22 21:44:29 | Re: [ADMIN] how to find transaction associated with a lock |