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 1lNG61-0007Lu-5J for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Mar 2021 14:27:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lNG5z-0007T2-OG for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Mar 2021 14:27:23 +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 1lNG5z-0007Sv-F8 for pgsql-hackers@lists.postgresql.org; Fri, 19 Mar 2021 14:27:23 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lNG5s-00057i-Qz for pgsql-hackers@lists.postgresql.org; Fri, 19 Mar 2021 14:27:23 +0000 Received: by mail-pf1-x432.google.com with SMTP id q5so6017061pfh.10 for ; Fri, 19 Mar 2021 07:27:16 -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=+Ja9l/BTgAsLepKBeMr4Z/0r3G+wB3EXyKV1ZgcxT4E=; b=CjP0zRiRPRxtyxqGBxI+ZZqDjebiPn0MNszA6i5Ra2szuNK8SGIWY/dgeqigGBqcu6 Z+8XPxCTykEFbsMqE2g8HZW76NacI5Rt3VOx6ldqVWtIXVf4iEEgfd1yaKuMSFDtpQ+b JX7S0OSK3HsMC7oNNSnUNDBt7U8tL/pu6O7vg5sZTcc+wkLjkd5tl8eRZKBrusAg5JmK 1HOcdzO35IMGSHMwvW10TIsTMRLjrak0AfkzRRyiSz29UgaZJu+zePN707bwq6TEc8Dj YzI+170zR13YZjwefg1bnY0pd8j47LJQQWEz4LZ0WDa4AG3Wc6z4540Gia90zX48WD2b yapQ== 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=+Ja9l/BTgAsLepKBeMr4Z/0r3G+wB3EXyKV1ZgcxT4E=; b=cjHsnZ30bZzhyAlK68+1B1/j/QwgPRjwCMKhYLuzqYu5JDgPhuGOw4sz++W3owHCnC DeL443E2ZL2wrVZIcEHD7oejDJlw/ZINHCu5DXlBIkAkXpFLpkRdpaAdoVtOVqar3sj/ svtHzwZ7Mp8xZRZrAcdK7GJxRDIBKrLPpdGSe5ZTJ9cJnRUlB3kpyjuwiIelMYm/MTOl Us7rGZ+LyiBTvIFJp1GVrt7itwbvGM4FdXD8zFXFUxQSUH6+iYJ1fD10+APNeHpBOIBY 96xnIiMulWea/rP979dmRZlSBs3a5tQAzUuDKY3Qxs+QXhIGz+iiA8zx0wzGob+Y2tLB 2yFw== X-Gm-Message-State: AOAM533BZGAZyjYxXG6BPmhvloBErfD3iLTFVb9qX5KSJ4hSWXdrIsZz elo8cTwGjNOJ4Yd6+g8kvls= X-Google-Smtp-Source: ABdhPJy3ujhMsVw3ht7U5DPNNvVqTNqOr+NNZ89KfRZVYbLW/T6XMRwIZG97g8bGYEVfehtEAgr/Kw== X-Received: by 2002:a65:4083:: with SMTP id t3mr11580245pgp.150.1616164034454; Fri, 19 Mar 2021 07:27: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 h6sm5541226pfb.157.2021.03.19.07.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 07:27:13 -0700 (PDT) Date: Fri, 19 Mar 2021 22:27:51 +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: <20210319142751.vsvsjbp4bsvbh4ek@nol> References: <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> <20210319031650.aqy3ad7fpqsudo3b@nol> <20210319132906.GG3572@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210319132906.GG3572@momjian.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Mar 19, 2021 at 09:29:06AM -0400, Bruce Momjian wrote: > On Fri, Mar 19, 2021 at 11:16:50AM +0800, Julien Rouhaud wrote: > > 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 > > OK, that makes perfect sense. I think the best solution is to document > that compute_query_id just controls the built-in computation of the > query id, and that extensions can also compute it if this is off, and > pg_stat_activity and log_line_prefix will display built-in or extension > computed query ids. So the last version of the patch should implement that behavior right? It's just missing some explicit guidance that third-party extensions should only calculate a queryid if compute_query_id is off > It might be interesting someday to check if the hook changed a > pre-computed query id and warn the user in the logs, but that could > cause more log-spam problems than help. I am a little worried that > someone might have compute_query_id enabled and then install an > extension that overwrites it, but we will just have to document this > issue. Hopefully extensions will be clear that they are computing their > own query id. I agree. And hopefully they will split the queryid calculation from the rest of the extension so that users can use the combination they want.