Nested IMMUTABLE functions - Mailing list pgsql-general

From Peter
Subject Nested IMMUTABLE functions
Date
Msg-id g2rd38$1jko$1@news.hub.org
Whole thread Raw
Responses Re: Nested IMMUTABLE functions  (Joris Dobbelsteen <joris@familiedobbelsteen.nl>)
List pgsql-general
I have two immutable Pl/PG funcs - func A takes a parameter X, looks up
related value Y from a table and passes Y to func B. Now, if I do something
like

select A(field_x) from bigtable

it will, of course call A for every single row since paramater is changing.
However, it also calls func B for every row even though most (actually all)
related values Y are the same!

Is this by design, or flaw in optimizer? I thought immutable funcs with the
same arguments are only called once within a scope of single query, and that
'select A(...)' should have counted as single query, right?

This stuff is killing me... func B is small, all table lookups optimized to
the hilt but still I'm taking major performance hit as it's called
hundreds/thousands of times.

Any ideas?

Thx,
Peter




pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Heavily fragmented table and index data in 8.0.3
Next
From: Tom Lane
Date:
Subject: Re: Unable to dump database using pg_dump