Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3J8a-0008P0-DK for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jul 2021 14:11:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3J8Z-0006Ui-C3 for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jul 2021 14:11:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3J8Z-0006Ua-4S for pgsql-hackers@lists.postgresql.org; Tue, 13 Jul 2021 14:11:51 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3J8S-0007Wi-3A for pgsql-hackers@postgresql.org; Tue, 13 Jul 2021 14:11:50 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id D9B57605FD; Tue, 13 Jul 2021 23:11:37 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.2 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 13 Jul 2021 23:11:37 +0900 From: Masahiro Ikeda To: torikoshia Cc: Bharath Rupireddy , Fujii Masao , Dilip Kumar , Pgsql Hackers Subject: Re: RFC: Logging plan of the running query In-Reply-To: References: <0842b5da697a03869fb50be93817e4e1@oss.nttdata.com> <1c1590d3962cea6e06621da76677b5f3@oss.nttdata.com> <64f716c44629e303b66e6c24502147cc@oss.nttdata.com> User-Agent: Roundcube Webmail/1.4.11 Message-ID: X-Sender: ikedamsh@oss.nttdata.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jun 22, 2021 at 8:00 AM torikoshia wrote: > Updated the patch. Hi, torikoshi-san Thanks for your great work! I'd like to use this feature in v15. I confirmed that it works with queries I tried and make check-world has no error. When I tried this feature, I realized two things. So, I share them. (1) About output contents > The format of the query plan is the same as when FORMAT > TEXT > and VEBOSE are used in the > EXPLAIN command. > For example: I think the above needs to add COSTS and SETTINGS options too, and it's better to use an example which the SETTINGS option works like the following. ``` 2021-07-13 21:59:56 JST 69757 [client backend] LOG: plan of the query running on backend with PID 69757 is: Query Text: PREPARE query2 AS SELECT COUNT(*) FROM pgbench_accounts t1, pgbench_accounts t2; Aggregate (cost=3750027242.84..3750027242.86 rows=1 width=8) Output: count(*) -> Nested Loop (cost=0.84..3125027242.84 rows=250000000000 width=0) -> Index Only Scan using pgbench_accounts_pkey on public.pgbench_accounts t1 (cost=0.42..12996.42 rows=500000 width=0) Output: t1.aid -> Materialize (cost=0.42..15496.42 rows=500000 width=0) -> Index Only Scan using pgbench_accounts_pkey on public.pgbench_accounts t2 (cost=0.42..12996.42 rows=500000 width=0) Settings: effective_cache_size = '8GB', work_mem = '16MB' ``` (2) About EXPLAIN "BUFFER" option When I checked EXPLAIN option, I found there is another option "BUFFER" which can be used without the "ANALYZE" option. I'm not sure it's useful because your target use-case is analyzing a long-running query, not its planning phase. If so, the planning buffer usage is not so much useful. But, since the overhead to output buffer usages is not high and it's used for debugging use cases, I wonder it's not a bad idea to output buffer usages too. Thought? Regards, -- Masahiro Ikeda NTT DATA CORPORATION