Re: Get execution plan of dynamic query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Алексей Ш(dot) <savbr(at)rin(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Get execution plan of dynamic query
Date: 2005-01-09 17:05:58
Message-ID: 27765.1105290358@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"=?KOI8-R?Q?=E1=CC=C5=CB=D3=C5=CA =FB.?=" <savbr(at)rin(dot)ru> writes:
> How to get results of EXPLAIN of dynamic query maked up in PL/PGSQL function?

Pretend that it's a prepared statement.

For example, if your plpgsql function has

declare x int;
y int;
begin
...
select f1 into x from tab1 where f2 = y;

then this will show the same plan as plpgsql will be using:

prepare foo(int) as select f1 from tab1 where f2 = $1;

explain analyze execute foo(42);

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-01-09 17:09:18 Re: [PORTS] PostgreSQL 8.0.0 Release Candidate 4
Previous Message Peter Eisentraut 2005-01-09 16:45:39 Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4