Re: SRF called with optional NULL input runs 7x slower - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: SRF called with optional NULL input runs 7x slower
Date
Msg-id 20070924041812.GG5679@alvh.no-ip.org
Whole thread Raw
In response to SRF called with optional NULL input runs 7x slower  (Ow Mun Heng <Ow.Mun.Heng@wdc.com>)
Responses Re: SRF called with optional NULL input runs 7x slower
List pgsql-general
Ow Mun Heng wrote:

> how can I debug or diagnose where the issues lies? Explain analyse
> doesn't do much since this is a Function Scan anyway.

Take them out of the function and EXPLAIN ANALYZE them as plain SQL.
Note that you should take the parameters out of the literal, so you need
to do something like

PREPARE foo AS SELECT ...   replace code with $1, etc ...
EXPLAIN ANALYZE EXECUTE foo(code, ...)

Otherwise they would be treated as constants so the queries would be
planned differently.

(untested, so correct the syntax appropriately)

--
Alvaro Herrera                 http://www.amazon.com/gp/registry/DXLWNGRJD34J
"Before you were born your parents weren't as boring as they are now. They
got that way paying your bills, cleaning up your room and listening to you
tell them how idealistic you are."  -- Charles J. Sykes' advice to teenagers

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Out of Memory - 8.2.4
Next
From: "Derek E. Lewis"
Date:
Subject: Re: Is this good spec for a PostgreSQL server?