"Gavin M. Roy" <[EMAIL PROTECTED]> writes:
> After detailed examination of pg_stat_user_indexes usage, it's clear that
> the functions don't use the same indexes.  I've casted everything to match
> the indexes in the SQL function, to no success.  Any suggestions on next
> steps?  Maybe for 8.4 we could find a way to explain analyze function
> internals ;-)

Yeah, this could be easier, but it's certainly possible to examine the
plan generated for a function's parameterized statement.  For instance,
say you're wondering about the plan for

        create function foo(int, text) ... as
        $$ select * from bar where f1 = $1 and f2 = $2 $$
        language sql

What you do is

prepare p(int, text) as select * from bar where f1 = $1 and f2 = $2 ;

explain analyze execute p(42, 'hello world');

It works exactly the same for statements in plpgsql functions,
remembering that both parameters and local variables of the function
have to become $n placeholders.  Remember to make the parameters
of the prepared statement have the same declared types as the
function's parameters and variables.

                        regards, tom lane

-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Reply via email to