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 1lyqHU-00037u-Sj for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Jul 2021 06:34:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lyqHT-0003rQ-T1 for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Jul 2021 06:34:35 +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 1lyqHT-0003rH-LG for pgsql-hackers@lists.postgresql.org; Thu, 01 Jul 2021 06:34:35 +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 1lyqHQ-000444-8s for pgsql-hackers@postgresql.org; Thu, 01 Jul 2021 06:34:35 +0000 Received: from hnk.local (p2388012-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.12]) by oss.nttdata.com (Postfix) with ESMTPSA id 0140B60651; Thu, 1 Jul 2021 15:34:26 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.2 at oss.nttdata.com Subject: Re: RFC: Logging plan of the running query To: torikoshia , Bharath Rupireddy Cc: Dilip Kumar , Pgsql Hackers References: <0842b5da697a03869fb50be93817e4e1@oss.nttdata.com> <1c1590d3962cea6e06621da76677b5f3@oss.nttdata.com> <64f716c44629e303b66e6c24502147cc@oss.nttdata.com> From: Fujii Masao Message-ID: <632e99eb-8090-53e6-1b1a-101601904cbd@oss.nttdata.com> Date: Thu, 1 Jul 2021 15:34:26 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <64f716c44629e303b66e6c24502147cc@oss.nttdata.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/06/22 11:30, torikoshia wrote: > On Thu, Jun 10, 2021 at 11:09 AM torikoshia wrote: >> On 2021-06-09 23:04, Fujii Masao wrote: > >> > auto_explain can log the plan of even nested statement >> > if auto_explain.log_nested_statements is enabled. >> > But ISTM that pg_log_current_plan() cannot log that plan. >> > Is this intentional? >> >> > I think that it's better to make pg_log_current_plan() log >> > the plan of even nested statement. >> >> +1. It would be better. >> But currently plan information is got from ActivePortal and ISTM there >> are no easy way to retrieve plan information of nested statements from >> ActivePortal. >> Anyway I'll do some more research. > > I haven't found a proper way yet but it seems necessary to use something other than ActivePortal and I'm now thinking this could be a separate patch in the future. DO $$ BEGIN PERFORM pg_sleep(100); END$$; When I called pg_log_current_query_plan() to send the signal to the backend executing the above query, I got the following log message. I think that this is not expected message. I guess this issue happened because the information about query text and plan is retrieved from ActivePortal. If this understanding is right, ISTM that we should implement new mechanism so that we can retrieve those information even while nested query is being executed. LOG: backend with PID 42449 is not running a query Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION