Re: SRF called with optional NULL input runs 7x slower

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Ow Mun Heng <Ow(dot)Mun(dot)Heng(at)wdc(dot)com>
Cc: ML PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: SRF called with optional NULL input runs 7x slower
Date: 2007-09-24 04:18:12
Message-ID: 20070924041812.GG5679@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Derek E. Lewis 2007-09-24 05:22:53 Re: Is this good spec for a PostgreSQL server?
Previous Message Alvaro Herrera 2007-09-24 03:57:24 Re: Out of Memory - 8.2.4