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 1lRbgT-0002Kr-Pc for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Mar 2021 14:19:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lRbgS-0002Cg-OF for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Mar 2021 14:19:00 +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 1lRbgS-0002CZ-HQ for pgsql-hackers@lists.postgresql.org; Wed, 31 Mar 2021 14:19:00 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lRbgL-0002k5-KE for pgsql-hackers@lists.postgresql.org; Wed, 31 Mar 2021 14:19:00 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id D28E25807AA; Wed, 31 Mar 2021 10:18:50 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 31 Mar 2021 10:18:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=zwDRRNLgSIzjbIdG3NyPut6kljALAW8HkF2C5kwqsWk=; b=J93aciZo sCi2/EekhGQUlmioiRyldyJIHy1cxcADRzy/pnnMIXXPggmGHTv38h5nyDkLejsB t89ep9lfTl97DmVPyJVO47cUcOdBYaKepvzdtaSlwD7/Qf6akCZZZVs+Gi2wUciI c+gwMxNXPO5J8pqDlF5lSdd8JiZPHahlmGpCPA4oOYgtC0ZZ09aJxGLDkBIE5Z2I ZMgc2BgwkKvjh0tygQPKbxWipwiiR9h9e6A9K6AQ/i1Ny7trQZCY9CIGYZ59W+ap IdYYdQ8Z8X+T158BxJ36845o8TMvwa2mfT2rbezg46mqvNDQrCyogjeHOzEpPWlk IajOmdT3Oo0BYw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeivddgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjfgesthekredttderudenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepueffhfejieeuueffgedvudekgeeltdeviedvieeufeei ieevgfetheeufeethedvnecukfhppeduledtrdelhedrudelrdelheenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghl vhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 9B1641080054; Wed, 31 Mar 2021 10:18:48 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id C4E072A0CAD; Wed, 31 Mar 2021 11:18:45 -0300 (-03) Date: Wed, 31 Mar 2021 11:18:45 -0300 From: Alvaro Herrera To: Bruce Momjian Cc: Julien Rouhaud , Hannu Krosing , Robert Haas , Pavel Stehule , Tom Lane , Michael Paquier , torikoshia , Atsushi Torikoshi , Tatsuro Yamada , Tomas Vondra , Evgeny Efimkin , PostgreSQL Hackers Subject: Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view? Message-ID: <20210331141845.GA958@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210331130643.GA11608@momjian.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Mar-31, Bruce Momjian wrote: > On Wed, Mar 31, 2021 at 11:25:32AM +0800, Julien Rouhaud wrote: > > On Thu, Mar 25, 2021 at 10:36:38AM +0800, Julien Rouhaud wrote: > > > On Wed, Mar 24, 2021 at 01:02:00PM -0300, Alvaro Herrera wrote: > > > > I find it odd that there's executor code that acquires the current query > > > > ID from pgstat, after having been put there by planner or ExecutorStart > > > > itself. Seems like a modularity violation. I wonder if it would make > > > > more sense to have the value maybe in struct EState (or perhaps there's > > > > a better place -- but I don't think they have a way to reach the > > > > QueryDesc anyhow), put there by ExecutorStart, so that places such as > > > > execParallel, nodeGather etc don't have to fetch it from pgstat but from > > > > EState. > > > > > > The current queryid is already available in the Estate, as the underlying > > > PlannedStmt contains it. The problem is that we want to display the top level > > > queryid, not the current query one, and the top level queryid is held in > > > pgstat. > > > > So is the current approach ok? If not I'm afraid that detecting and caching > > the top level queryid in the executor parts would lead to some code > > duplication. > > I assume it is since Alvaro didn't reply. I am planning to apply this > soon. I'm afraid I don't know enough about how parallel query works to make a good assessment on this being a good approach or not -- and no time at present to figure it all out. -- Álvaro Herrera 39°49'30"S 73°17'W "I think my standards have lowered enough that now I think 'good design' is when the page doesn't irritate the living f*ck out of me." (JWZ)