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

2007-09-24 Thread Alvaro Herrera
Ow Mun Heng wrote: > On Mon, 2007-09-24 at 02:31 -0400, Alvaro Herrera wrote: > > > it ERRORs w/ could not determine data type of parameter $3 > > > > Cast it to the correct type. > > how do I cast a NULL? Is it Varchar? I didn't say "pick a random datatype", I said "the correct type", which in

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

2007-09-23 Thread Ow Mun Heng
On Mon, 2007-09-24 at 02:31 -0400, Alvaro Herrera wrote: > Ow Mun Heng wrote: > > > Okay.. I tried that, but it seems like there's an issue w/ the CASE > > statements. > > > > When I tried the prepare w/ > > > > AND (CASE WHEN $3 IS NULL THEN true else d.code = any ($3) END) > > AND (CASE WHEN $

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

2007-09-23 Thread Alvaro Herrera
Ow Mun Heng wrote: > Okay.. I tried that, but it seems like there's an issue w/ the CASE > statements. > > When I tried the prepare w/ > > AND (CASE WHEN $3 IS NULL THEN true else d.code = any ($3) END) > AND (CASE WHEN $4 IS NULL THEN TRUE else D.id = any($4) END) > > > it ERRORs w/ could not

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

2007-09-23 Thread Ow Mun Heng
On Mon, 2007-09-24 at 00:18 -0400, Alvaro Herrera wrote: > 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

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

2007-09-23 Thread Alvaro Herrera
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 somet

[GENERAL] SRF called with optional NULL input runs 7x slower

2007-09-23 Thread Ow Mun Heng
I've got 2 nearly identical SRFs to retrieve data from the DB(pg 8.2.4) which goes something like this = Function 1 == CREATE OR REPLACE FUNCTION hot(fromdate timestamp without time zone, todate timestamp without time zone, code text[]) RETURNS SETOF trh_hot