Ну, есть немного странный способ, как это сделать.См. «Подтверждение концепции» ниже - настройте его в соответствии с вашими потребностями ...
do $$
declare
_idlist int[] := '{10,20,30}';
i int;
_q text;
_t text;
begin
foreach i in array _idlist loop
_q := 'explain analyze select '||i;
raise notice 'query: %', _q;
for _t in execute _q loop
raise notice '%', _t;
end loop;
end loop;
end; $$ language plpgsql;
Выводит вывод в окне «сообщений» pgAdmin (или STDERR в командной строке) следующим образом:
NOTICE: query: explain analyze select 10
NOTICE: Result (cost=0.00..0.01 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=1)
NOTICE: Planning time: 0.003 ms
NOTICE: Execution time: 0.012 ms
NOTICE: query: explain analyze select 20
NOTICE: Result (cost=0.00..0.01 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=1)
NOTICE: Planning time: 0.004 ms
NOTICE: Execution time: 0.004 ms
NOTICE: query: explain analyze select 30
NOTICE: Result (cost=0.00..0.01 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1)
NOTICE: Planning time: 0.004 ms
NOTICE: Execution time: 0.003 ms
DO
Query returned successfully in 127 msec.