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 1lh2nh-00017w-6j for pgsql-hackers@arkaria.postgresql.org; Thu, 13 May 2021 04:18:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lh2ng-0000bV-3k for pgsql-hackers@arkaria.postgresql.org; Thu, 13 May 2021 04:18:16 +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 1lh2nf-0000bN-Se for pgsql-hackers@lists.postgresql.org; Thu, 13 May 2021 04:18:15 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lh2na-0003zD-4O for pgsql-hackers@lists.postgresql.org; Thu, 13 May 2021 04:18:14 +0000 Received: from hnk.local (p2388012-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.12]) by oss.nttdata.com (Postfix) with ESMTPSA id 82B86600FF; Thu, 13 May 2021 13:18:05 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.2 at oss.nttdata.com Subject: Re: compute_query_id and pg_stat_statements To: Julien Rouhaud , Bruce Momjian Cc: Pavel Stehule , Kyotaro Horiguchi , Magnus Hagander , Michael Paquier , Andres Freund , Tom Lane , Alvaro Herrera , Stephen Frost , Christoph Berg , Peter Eisentraut , PostgreSQL Hackers References: <20210512.183927.600535883807655721.horikyota.ntt@gmail.com> <20210512095149.kqbnhe72uijfwi2r@nol> <20210513003618.GA26043@momjian.us> <20210513005236.aj7n6b76yjsxythc@nol> <20210513011325.GA11075@momjian.us> <20210513015700.fp33q5rfvwl2ahfx@nol> <20210513030652.GB11075@momjian.us> <20210513031613.j47baglf6xl3mgbs@nol> <20210513033332.GF11075@momjian.us> <20210513040342.fouh7ryglrfgxglu@nol> From: Fujii Masao Message-ID: Date: Thu, 13 May 2021 13:18:05 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210513040342.fouh7ryglrfgxglu@nol> Content-Type: text/plain; charset=utf-8; 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/05/13 13:03, Julien Rouhaud wrote: > On Wed, May 12, 2021 at 11:33:32PM -0400, Bruce Momjian wrote: >> On Thu, May 13, 2021 at 11:16:13AM +0800, Julien Rouhaud wrote: >>> On Wed, May 12, 2021 at 11:06:52PM -0400, Bruce Momjian wrote: >>>> On Thu, May 13, 2021 at 09:57:00AM +0800, Julien Rouhaud wrote: >>>> >>>>> source? What if you have for instance pg_stat_statements, pg_stat_kcache, >>>>> pg_store_plans and pg_wait_sampling installed? All those extensions need a >>>>> query_id (or at least benefit from it for pg_wait_sampling), is there any value >>>>> to give a full list of all the modules that would enable compute_query_id? >>>> >>>> Well, we don't have any other cases where the source of the change is >>>> this indeterminate, so I don't really have a suggestion. I think this >>>> does highlight another case where 'auto' just isn't a good fit for our >>>> API. >>> >>> It may depends on your next question >>> >>>>> I'm assuming that anyone wanting to install any of those extensions (or any >>>>> similar one) is fully aware that they aggregate metrics based on at least a >>>>> query_id. If they don't, well they probably never read any documentation since >>>>> postgres 9.2 which introduced query normalization, and I doubt that they will >>>>> be interested in having access to the information anyway. >>>> >>>> My point is that we are changing a setting from an extension, and if you >>>> look in pg_setting, it will say "default"? >>> >>> No, it will say "on". What the patch I sent implements is: >> >> I was asking what pg_settings.source will say: >> >> SELECT name, soource FROM pg_settings; > > Oh sorry. Here's the full output before and after a dynamic call to > queryIsWanted(): > > name | compute_query_id > setting | auto > unit | > category | Statistics / Monitoring > short_desc | Compute query identifiers. > extra_desc | > context | superuser > vartype | enum > source | default > min_val | > max_val | > enumvals | {auto,on,off} > boot_val | auto > reset_val | auto > sourcefile | > sourceline | > pending_restart | f > > =# LOAD 'pg_qualstats'; /* will call queryIsWanted() */ > WARNING: 01000: Without shared_preload_libraries, only current backend stats will be available. > LOAD > > name | compute_query_id > setting | on > unit | > category | Statistics / Monitoring > short_desc | Compute query identifiers. > extra_desc | > context | superuser > vartype | enum > source | default > min_val | > max_val | > enumvals | {auto,on,off} > boot_val | auto > reset_val | auto > sourcefile | > sourceline | > pending_restart | f > > So yes, it says "default" (and it's the same if the change is done during > postmaster init). It can be fixed if that's the only issue. I like leaving compute_query_id=auto instead of overwriting it to "on", even when queryIsWanted() is called, as I told upthread. Then we can decide that query id computation is necessary when compute_query_id=auto and the special flag is enabled by queryIsWanted(). Of course as you and Magnus discussed upthread, the issue in EXEC_BACKEND case should be fixed, maybe by using save_backend_variables() or something, though. If we do this, compute_query_id=auto seems to be similar to huge_pages=try. When huge_pages=try, whether huge pages is actually used is defined depending outside PostgreSQL (i.e, OS setting in this case). Neither pg_settings.setting nor souce are not changed in that case. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION