my test case:
drop table a;
create table a ();
DO
$$
DECLARE
i int;
BEGIN
for i in 1..20
loop
execute 'alter table a add column a'||i::text||' int';
end loop;
END
$$;
select pg_stat_statements_reset();
set pg_stat_statements.track='none';
DO
$$
DECLARE
i int;
j int;
BEGIN
for j in 1..20
loop
for i in 1..20
loop
execute 'select a'||i::text||',a'||j::text||' from a where 1=2';
end loop;
end loop;
END
$$;
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-hackers-f1928748.html