Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[HACKERS] func() & select func()

0 views
Skip to first unread message

Hiroshi Inoue

unread,
Aug 31, 2000, 3:00:00 AM8/31/00
to
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

0 new messages