func() & select func()

From: "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp>
To: "pgsql-hackers" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: func() & select func()
Date: 2000-08-31 08:10:18
Message-ID: 000901c01322$e6bf81e0$2801007e@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I have seen discussions about iscachable attribute of
functions. Now I'm confused to see a solution in 6.5
(by Shigeru Matsumoto).

=# explain select * from pg_class where oid=1259;

Index Scan using pg_class_oid_index on pg_class (cost=0.00..2.01
rows=1 width=92)

1) Using non-cachable function f()
=# create function f(oid) returns oid as
'
select $1;
' language 'sql';
=# explain select * from pg_class where oid=f(1259);

Seq Scan on pg_class (cost=0.00..3.17 rows=1 width=92)

Seems reasonable.

2) Using select f()
=# explain select * from pg_class where oid=(select f(1259));

Index Scan using pg_class_oid_index on pg_class (cost=0.00..2.01
rows=1 width=92)
InitPlan
-> Result (cost=0.00..0.00 rows=0 width=0)

This is the result in my current environment.
Hmm,what's the difference between 1) and 2) ?

Regards.

Hiroshi Inoue

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jules Bean 2000-08-31 11:40:42 Re: Performance on inserts
Previous Message Thomas Lockhart 2000-08-31 05:32:51 Re: Patch for TNS services