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 1kTSDE-0000xB-Qp for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Oct 2020 16:04:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kTSDB-0000wJ-5y for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Oct 2020 16:04:09 +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 1kTSDA-0000wB-6A for pgsql-hackers@lists.postgresql.org; Fri, 16 Oct 2020 16:04:08 +0000 Received: from new4-smtp.messagingengine.com ([66.111.4.230]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTSD7-0000Il-8l for pgsql-hackers@lists.postgresql.org; Fri, 16 Oct 2020 16:04:07 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 33357580389; Fri, 16 Oct 2020 12:04:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 16 Oct 2020 12:04:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm1; bh=nSNUvitHPHtKn5zW6 +lBoe5GSC6OuP43+UOEFQKQL9o=; b=BZ5xfUdAkmlRpmtPm+be1aBFuczDYDTA0 1POg4jxet9tIJ1qPjCgzXisu5rBvShZb+xgHEcF0nItVMWP7NpzHPQcxueq7LiV9 SRG5Y8khj8J3jK+dydcOGeiaqJ4N5Ec1RjXkotm/LRpBRqtNtDoC4Y+l3zGt0pVz GKktTTqAtiq9yY9VBpvZh0jqKxbolQrG8vIXowY4KR6e9mikXVEpMjZy5xDvkhAB uKnGWXR93Qq+UpaXF1cf0J71sTO1NfeWgcfkB0LgV6zjfFPX2azefqBgF8Bt81Vg 9AMG5y6QI3vbFjtqkw7p/YuSX+L9gt+Emh364fmPmS8Bp3i1PEycw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrieehgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtuggjfgesthdtredttdervdenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepvefgleevgeeujeeghfegteeghfegheeifeehheelteetiedu ieeihffggfehffetnecukfhppeduledtrddutdeirddufeegrddutddtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegr lhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (h100-n190-106-134.v8.fangio.net [190.106.134.100]) by mail.messagingengine.com (Postfix) with ESMTPA id BCD8C3064610; Fri, 16 Oct 2020 12:03:59 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id EF7862A14D3; Fri, 16 Oct 2020 13:03:55 -0300 (-03) Date: Fri, 16 Oct 2020 13:03:55 -0300 From: Alvaro Herrera To: Bruce Momjian Cc: Julien Rouhaud , Tom Lane , Robert Haas , 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: <20201016160355.GA31474@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201016150449.GA23488@momjian.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Oct-16, Bruce Momjian wrote: > On Thu, Oct 15, 2020 at 11:41:23AM +0800, Julien Rouhaud wrote: > > I did some naive benchmarking. Using a custom pgbench script with this query: > > I can see around 2% overhead (this query is reported with ~ 3ms > > latency average). Adding a few joins, overhead goes down to 1%. > > That number is too high to enable this by default. I suggest we either > improve the performance of this, or clearly document that you have to > enable the hash computation to see the pg_stat_activity and > log_line_prefix fields. Agreed. This is similar to how we used to deal with query strings: an optional feature, disabled by default (cf. commit b13c9686d084). In this case, I suppose using pg_stat_statement would require to have it enabled, and it'd just not collect anything if disabled. Similarly, the field would show NULL in pg_stat_activity or an empty string in log_line_prefix/CSV logs. So users that want it can easily have it, and users that don't are not paying the price. For maximum user-friendliness, pg_stat_statement could be loaded and shmem-initialized even when query ID computation is turned off, and you'd be able to enable query ID computation with just SIGHUP; so you don't have to restart the server in order to enable statement tracking. (I suppose we would forbid users from disabling query ID with SET, though.)