Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rT3Xw-0006eX-KQ for pgsql-general@arkaria.postgresql.org; Thu, 25 Jan 2024 17:29:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rT3Xv-001too-N1 for pgsql-general@arkaria.postgresql.org; Thu, 25 Jan 2024 17:29:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rT3Xv-001toD-Cd for pgsql-general@lists.postgresql.org; Thu, 25 Jan 2024 17:29:47 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rT3Xs-003Kzx-Vc for pgsql-general@postgresql.org; Thu, 25 Jan 2024 17:29:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 40PHThEQ413807; Thu, 25 Jan 2024 12:29:43 -0500 From: Tom Lane To: Ron Johnson cc: pgsql-general Subject: Re: In-reply-to: References: Comments: In-reply-to Ron Johnson message dated "Thu, 25 Jan 2024 12:18:08 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <413805.1706203783.1@sss.pgh.pa.us> Date: Thu, 25 Jan 2024 12:29:43 -0500 Message-ID: <413806.1706203783@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ron Johnson 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