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 1lgzaR-0000yQ-6J for pgsql-hackers@arkaria.postgresql.org; Thu, 13 May 2021 00:52: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 1lgzaP-0007yH-UC for pgsql-hackers@arkaria.postgresql.org; Thu, 13 May 2021 00:52: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 1lgzaP-0007y9-Kd for pgsql-hackers@lists.postgresql.org; Thu, 13 May 2021 00:52:21 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lgzaJ-0002NK-AJ for pgsql-hackers@lists.postgresql.org; Thu, 13 May 2021 00:52:20 +0000 Received: by mail-pf1-x433.google.com with SMTP id x188so20116821pfd.7 for ; Wed, 12 May 2021 17:52: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=9sjiNU9SsSw7VtQybu0Py3mwF4xRCnPmbvrAiQdSrKw=; b=pzIXVF6l+TNYmiRLxbZ3IC9Rd8hedKb+2avUQhIqH6a59+j23J7G6+H4Z0g3gEcG1X INqn1C1jxwf9LNtEyURzZ1zxbS5B5DhZ0BT02chHYvVjoUUA7M14bFgS5mcvky2aqFrB VdLdMp2cyzn/mzCjyaI7xoPq6GTorbkZcstGEq1ug0bUShbEee11wg93UKCnBmU5Kg/P S4J16fiHSmIFHVpdtgwL4pua8tHvH84vPVvxr5sUBQwFBUFfBMq36MAPAgl+BmhHHyyt wOuFhXC5ezNGvt0uY9FjX7XoT0RLB42wSZO5M9NVZn/j7c6+mIroWOhaFKlH5ZcgaYrB NXIA== 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=9sjiNU9SsSw7VtQybu0Py3mwF4xRCnPmbvrAiQdSrKw=; b=Po22OxMySoQFrrIPHp2d6LNkwSsOE+a/ggYGf4tFc+qo7W+jEt6tY8k0+Er17H6n7A LAAiWYalkfeQZdHexzCcoZL0t36gZcYIldJLepn3F+Zbq94Q6fADvyNrF1qeE8qNho9N jEKa9Lec/xwwvKULAK9T3xCSva3kF0Mtb1KTYQj+/DY7Q98e0liRiZwHLU/fMg/8wa/W lvJWNQaexmZmtHJKDjffZGjkwynJwodDVUTiblm0av/3RHuI8PM+pIrz2O0ig2/BvU+e JGDBNPsExRVyc9HIHEpqgEko4O3+NVvJedCE/m84t/b9BcB4dbBEEnbIT6ic4UchYrtt pvag== X-Gm-Message-State: AOAM531rih49Ri2fGHNhynK8ScTWGpt8DGx3F+vtzjfTs85DBa5ViYlu z0f81meZQ4+DxIQyC2BotYA= X-Google-Smtp-Source: ABdhPJymQ/v9Sh/Ips56ARl4SieWQbDhFxOlb2EOVaWKMH36P6D8ITgxwMqLOmr1AmQp/XW1zpFO6g== X-Received: by 2002:a17:90a:1588:: with SMTP id m8mr1540260pja.31.1620867133988; Wed, 12 May 2021 17:52:13 -0700 (PDT) Received: from nol (2001-b011-0008-3a8c-638b-a3db-2ad1-c7d1.dynamic-ip6.hinet.net. [2001:b011:8:3a8c:638b:a3db:2ad1:c7d1]) by smtp.gmail.com with ESMTPSA id j16sm818930pgh.69.2021.05.12.17.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 17:52:13 -0700 (PDT) Date: Thu, 13 May 2021 08:52:36 +0800 From: Julien Rouhaud To: Bruce Momjian Cc: Pavel Stehule , Kyotaro Horiguchi , Magnus Hagander , Fujii Masao , Michael Paquier , Andres Freund , Tom Lane , Alvaro Herrera , Stephen Frost , Christoph Berg , Peter Eisentraut , PostgreSQL Hackers Subject: Re: compute_query_id and pg_stat_statements Message-ID: <20210513005236.aj7n6b76yjsxythc@nol> References: <20210512081445.axosz3xf7ydrhe7o@nol> <20210512093026.ur43cu3c46eshbew@nol> <20210512.183927.600535883807655721.horikyota.ntt@gmail.com> <20210512095149.kqbnhe72uijfwi2r@nol> <20210513003618.GA26043@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210513003618.GA26043@momjian.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, May 12, 2021 at 08:36:18PM -0400, Bruce Momjian wrote: > On Wed, May 12, 2021 at 05:51:49PM +0800, Julien Rouhaud wrote: > > On Wed, May 12, 2021 at 11:42:12AM +0200, Pavel Stehule wrote: > > > this check just can check if there is "any" query-id provider. In this > > > context is not important if it is buildin or external > > > > Yes, the idea is that if you execute "SELECT * FROM pg_stat_statements" or > > similar, then if the executing query itself doesn't have a queryid then > > it's very likely that you didn't configure compute_query_id or an alternative > > query_id implementation properly. And loudly complaining seems like the right > > thing to do. > > I understand the desire to make pg_stat_statements require minimal > configuration, but frankly, if the server-side variable query id API is > confusing, I think we have done more harm than good. > > The problem with compute_query_id=auto is that there is no way to know > if the query id is actually enabled, unless you guess from the installed > extensions, or we add another variable to report that, and maybe another > variable to control the provier, unless we require turning > compute_query_id=off if you are using custom query id computation. What > if it is auto, and pg_stat_statments is installed, and you want to use a > custom query id computation --- what happens? As you can see, this is > all becoming very complicated. Well, as implemented you can get the value of compute_query_id, and if it's still "auto" then it's not enabled as calling queryIdWanted() would turn it to on. I agree that it's not ideal but you have a way to know. We could document that auto means that it's set to auto and no one asked to automatically enabled it. Or you can just do e.g. SELECT query_id FROM pg_stat_activity WHERE pid = pg_backend_pid(); and see if you have a query_id or not. If you want to use third-party modules, they you have to explicitly disable compute_query_id. If you don't, every query execution will raise an error as we documented that third-party modules should error out if they see that a query_id is already generated. Such module could also explicitly check that compute_query_id is off and also raise an error if that's not the case. > I think we might be just as well to go with compute_query_id=on/off, and > just complain loudly from CREATE EXTENSION, or in the server logs on > server start via shared_preload_libraries, or when querying > pg_stat_statements system view. We simply say to change > compute_query_id=on or to provide a custom query id implementation. I'm not opposed to that, but it was already suggested and apparently people didn't like that approach.