pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ron Johnson <ronljohnsonjr@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re:
Date: Thu, 25 Jan 2024 12:29:43 -0500
Message-ID: <413806.1706203783@sss.pgh.pa.us> (raw)
In-Reply-To: <CANzqJaAf+h+Fn=-4n__-MxWcZ6Vp-KYe6UvqL930wBSXCkn21g@mail.gmail.com>
References: <CANzqJaAf+h+Fn=-4n__-MxWcZ6Vp-KYe6UvqL930wBSXCkn21g@mail.gmail.com>

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





view thread (4+ messages)  latest in thread

Message-ID: <413806.1706203783@sss.pgh.pa.us>
Permalink:  ../413806.1706203783@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/413806.1706203783@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ronljohnsonjr@gmail.com
  Subject: Re: 
  In-Reply-To: <413806.1706203783@sss.pgh.pa.us>
  References: <CANzqJaAf+h+Fn=-4n__-MxWcZ6Vp-KYe6UvqL930wBSXCkn21g@mail.gmail.com> <413806.1706203783@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox