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 1lN5cd-00085O-Bo for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Mar 2021 03:16:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lN5cb-0003bb-Uc for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Mar 2021 03:16:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lN5cb-0003ax-Lv for pgsql-hackers@lists.postgresql.org; Fri, 19 Mar 2021 03:16:21 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lN5cV-0005tr-CL for pgsql-hackers@lists.postgresql.org; Fri, 19 Mar 2021 03:16:20 +0000 Received: by mail-pg1-x52d.google.com with SMTP id m3so2749570pga.1 for ; Thu, 18 Mar 2021 20:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=BEieEwWSMUzv72eJV04uiXLUwdsc4Z/lsux6Kzr9t4A=; b=SiVfSjmTvFzwbTmhSrdgjGhGQ2701TiIuxWT+/tXiZEPf44+wvwuPn4QVW5EAd05Hp tzjlb09y8sAit1GP/84TMJIta6Le+bmFEkQzGe8amA7xfIIZn2zvlEobZpR8dN5Je36O zVn6GfNjpkHgKK4LgJKFkSymphJ6nbrrqqaKhY1rr7f3gFxFnPMPNlOWyqYM9QR3lwmJ QGpKHleae8aqXKny+KEcFTI2Bei2G2aF5N8iohnVLXwCafzuAvm8krEX8YRSJP4wQi6H sQQN8Vy0r0UjY3ON85kK0D+wE6kCkveMOQ0HxEc12ILcSSTkRLNOcFLLu8mIAEYRzc4K Q9Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BEieEwWSMUzv72eJV04uiXLUwdsc4Z/lsux6Kzr9t4A=; b=h6MQYXgKZh2sUm4pb3oM2FciuJ3dKXq7/bCQtt31/EqHmSuQ0w6/pjrGrpa1twPvpp RKmATAKyViGb1ZkPVb/D8Z9vf4qb4neRN97PU+Wv0xz0vV4ON24fJJarvhtUOWBsX1be U+6lPs0V0v1W+Gw//9qaq9Ob17m9GNDFNnSwRJyfQ8lBr7KByltIjB5v1z5AddOyLbKc eI3sd3DlxRTjJY/lY2EWlws//WkoyRcrd7NeXl+A/vmMKEyFkvTKkngyemEGWuoWMrSX 9b6H/Ucv+k/GP5OHRcC6lUmHra6XyadEwQPYZ1QpziRL2zPOLJC6rR05eDQ8Pl8CHUWV Tr3Q== X-Gm-Message-State: AOAM531G00++mTRlFTm+8y+PIcCfL/c+RB/2EnVtDukkAeGJ8BfA51wK bwib7tazQMF5/00z9wPCAdI= X-Google-Smtp-Source: ABdhPJzh+swdEHC2YnsXuTFoSzqQv2cPPn84ewwgmXNIrymw882V0Ke5AhAHHqO+LGhAMpzCi/4CMw== X-Received: by 2002:a63:4d09:: with SMTP id a9mr9904193pgb.90.1616123774113; Thu, 18 Mar 2021 20:16:14 -0700 (PDT) Received: from nol (2001-b011-0008-f895-38e7-6857-c733-1515.dynamic-ip6.hinet.net. [2001:b011:8:f895:38e7:6857:c733:1515]) by smtp.gmail.com with ESMTPSA id b9sm3285167pgn.42.2021.03.18.20.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 20:16:13 -0700 (PDT) Date: Fri, 19 Mar 2021 11:16:50 +0800 From: Julien Rouhaud To: Bruce Momjian Cc: Robert Haas , Pavel Stehule , Tom Lane , Alvaro Herrera , 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: <20210319031650.aqy3ad7fpqsudo3b@nol> References: <3519983.1615996898@sss.pgh.pa.us> <20210317162444.GD16650@momjian.us> <20210317164907.c4uogoqvchnwcnjy@nol> <20210317223216.GE16650@momjian.us> <20210317232956.veah6bax3mespdtq@nol> <20210318134729.GA8529@momjian.us> <20210318180656.3aat6jkbs7ylcg4k@nol> <20210318192349.GD3721@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210318192349.GD3721@momjian.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 18, 2021 at 03:23:49PM -0400, Bruce Momjian wrote: > On Fri, Mar 19, 2021 at 02:06:56AM +0800, Julien Rouhaud wrote: > > The above text is the part that made me think an extension could display > a query id even if disabled by the GUC. With the last version of the patch I sent it was the case. > Oh, OK. I can see an extension setting the query id on its own --- we > can't prevent that from happening. It is probably enough to tell > extensions to honor the GUC, since they would want it enabled so it > displays in pg_stat_activity and log_line_prefix. Ok. So no new hook, and we keep using post_parse_analyze_hook as the official way to have custom queryid implementation, with this new behavior: > > - if some extension calculates a queryid during post_parse_analyze_hook, we > > will always reset it. > > OK, good. Now that I'm back on the code I remember why I did it this way. It's unfortunately not really possible to make things work this way. pg_stat_statements' post_parse_analyze_hook relies on a queryid already being computed, as it's where we know where the constants are recorded. It means: - we have to call post_parse_analyze_hook *after* doing core queryid calculation - if users want to use a third party module to calculate a queryid, they'll have to make sure that the module's post_parse_analyze_hook is called *before* pg_stat_statements' one. - even if they do so, they'll still have to pay the price of core queryid calculation So it would be very hard to configure and will be too expensive. I think that we have to choose to either we make compute_query_id only trigger core calculation (like it was in previous patch version), or introduce a new hook. > I think compute_query_id works, and is shorter. WFM. > OK, good to know. I can run some tests here if people would like me to. +1. A read only pgbench will be some kind od worse case scenario that can be used I think.