Re: Poor Performance for large queries in functions - Mailing list pgsql-hackers-win32

From Tom Lane
Subject Re: Poor Performance for large queries in functions
Date
Msg-id 22682.1096434647@sss.pgh.pa.us
Whole thread Raw
In response to Poor Performance for large queries in functions  (John Meinel <john@johnmeinel.com>)
List pgsql-hackers-win32
John Meinel <john@johnmeinel.com> writes:
> ... However, if I try to
> bundle this query up into a server side function, it runs very slow (10
> seconds). I'm trying to figure out why, but since I can't run EXPLAIN
> ANALYZE inside a function, I don't really know what else to do.

A parameterized query inside a function is basically the same as a
PREPARE'd query with parameters at the SQL level.  So you can
investigate what's happening here with

    PREPARE foo(int) AS
        SELECT * FROM object WHERE id in (
            SELECT id FROM data_t WHERE project_id = $1
        UNION SELECT ... ;

    EXPLAIN ANALYZE EXECUTE foo(48542);

I'm not sure where the problem is either, so please do send along the
results.

            regards, tom lane

PS: pgsql-performance would be a more appropriate venue for this
discussion.

pgsql-hackers-win32 by date:

Previous
From: John Meinel
Date:
Subject: Poor Performance for large queries in functions
Next
From: Oliver D.
Date:
Subject: Win32 libpq : Static Link ?