Re: Functions and query analysis - EXPLAIN

Lists: pgsql-novice
From: Andy Halsall <halsall_andy(at)hotmail(dot)com>
To: "postgresql (dot)org novice list" <pgsql-novice(at)postgresql(dot)org>
Subject: Functions and query analysis - EXPLAIN
Date: 2012-02-10 17:07:21
Message-ID: BLU123-W6BE97326944EC920DF5E2F5780@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


Is it possible to use EXPLAIN from inside a function? Have seen this post http://archives.postgresql.org/pgsql-general/2011-04/msg00750.php but can't get it to work on even a simple query. Need it to work on a query in a function with a UNION.

Perhaps there's a better way of determining if my function is using the indexes I'd like it to use?

Thanks,
Andy


From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Functions and query analysis - EXPLAIN
Date: 2012-02-10 17:54:31
Message-ID: 20120210175431.GA13740@tux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Andy Halsall <halsall_andy(at)hotmail(dot)com> wrote:

> Is it possible to use EXPLAIN from inside a function? Have seen this post http:
> //archives.postgresql.org/pgsql-general/2011-04/msg00750.php but can't get it
> to work on even a simple query. Need it to work on a query in a function with a
> UNION.
>
> Perhaps there's a better way of determining if my function is using the indexes
> I'd like it to use?

Not sure if i understand you, but i think, you are looking for the
module AUTO_EXPLAIN. With this, and auto_explain.log_nested_statements =
on, you can see the explain-output in your log.

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°