Re: - Mailing list pgsql-general

From Tom Lane
Subject Re:
Date
Msg-id 413806.1706203783@sss.pgh.pa.us
Whole thread Raw
In response to  (Ron Johnson <ronljohnsonjr@gmail.com>)
Responses Re:  (Ron Johnson <ronljohnsonjr@gmail.com>)
List pgsql-general
Ron Johnson <ronljohnsonjr@gmail.com> writes:
> EXPLAIN SELECT works inside a FOR loop, but only the first line of the
> EXPLAIN output is stored.  What's the magic sauce for seeing the whole
> EXPLAIN output?

The usual way is to run a FOR loop over the lines of output.
Quick & dirty example:

regression=# do $$
declare ln text;
begin
  for ln in explain select * from int8_tbl join int4_tbl on q1=f1 loop
    raise notice '%', ln;
  end loop;
end $$;
NOTICE:  Hash Join  (cost=1.11..2.23 rows=5 width=20)
NOTICE:    Hash Cond: (int8_tbl.q1 = int4_tbl.f1)
NOTICE:    ->  Seq Scan on int8_tbl  (cost=0.00..1.05 rows=5 width=16)
NOTICE:    ->  Hash  (cost=1.05..1.05 rows=5 width=4)
NOTICE:          ->  Seq Scan on int4_tbl  (cost=0.00..1.05 rows=5 width=4)
DO

            regards, tom lane



pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject:
Next
From: Atul Kumar
Date:
Subject: permission denied on socket