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 1nDUUG-0000jt-Fb for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Jan 2022 16:52:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nDUTj-0007Vo-PI for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Jan 2022 16:52:03 +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 <9erthalion6@gmail.com>) id 1nDUTj-0007Ve-EE for pgsql-hackers@lists.postgresql.org; Fri, 28 Jan 2022 16:52:03 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1nDUTe-0004yO-Lm for pgsql-hackers@lists.postgresql.org; Fri, 28 Jan 2022 16:52:03 +0000 Received: by mail-ej1-x62c.google.com with SMTP id o12so17853638eju.13 for ; Fri, 28 Jan 2022 08:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lJ4bTPt13j04xL6t+RmP1XjiKqdSAwEWr3E3TBKuQDk=; b=Db4F3xYiLmRSkHO7JYYaWnT/qrf24JfSYG3O8nTypQKLUikKsXazMTEXiH0ppISPJs BkLhIbxuNgqF8IfJoERCq+I2RfX3CHqvbjNdSj+6D0Q5ugn+ibNXHKu1yfcowUXjCDi+ 7x/rvKkyfSxzQxRdkCspFHpGG3qP9q4oDrG7ES/iVNBzIHGQyxEc8+StF/AHRx9yeqEx FwT3XVbbSjZZaOuEQvpo+QdZ8+gPxs/ph1eg4zjjBUsMiwYI+U965jPpd6UTXDC2c6y0 GjIXq+SR/TI06OQyg/gUaWmTgABvjQCR2GYHxOAohvZnSJyFYAC1ipfRo0dCAOy122lW kEiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lJ4bTPt13j04xL6t+RmP1XjiKqdSAwEWr3E3TBKuQDk=; b=0X66NvCU+Src0CznAOzzu5RbSigJDq7Yhbw2NsI+14BU8amy42jYDH6juMXrZaDEVS mUM7SU6JYqe6r1pp1cYd/5m68Dr9zwaYty8L0SnhqTA5Lgxe4EZqdpvcPkpb8zonfN27 Kv0Gvi926j84+VehqKDck1zGEprJiU681ElDOQDEcG6cbj2hjJczS8eYfGsvzu2eu9Uv CHvosb/fCz5Zoy4GKXc3a4TBq9Qgv48sa5+Mc7bx+sUqn3903d0EM+IHg2e5Uw/l4ddZ 2Utwu7aRTt181hwK8wVTEgA8ggO6bhbD/5Hp7zovJlrrwwtfolxrLAJDdXRaGGkb3TXp WVig== X-Gm-Message-State: AOAM5321ZT6R+1IfPkMUNnAduVPuZJgWroR+WnC2v9pDPB4IWvub3aS4 sVO2vDOfKFjeIoM2F5yDqrs= X-Google-Smtp-Source: ABdhPJy7l1lnsGOtnpamkvc732g2kIuhEwXClMZ7ijt45t7nepgKY/9BN9LScC/hUG0c9a/hirnVew== X-Received: by 2002:a17:907:6d99:: with SMTP id sb25mr7787082ejc.15.1643388717628; Fri, 28 Jan 2022 08:51:57 -0800 (PST) Received: from ddolgov.remote.csb (dslb-094-223-160-189.094.223.pools.vodafone-ip.de. [94.223.160.189]) by smtp.gmail.com with ESMTPSA id p29sm13322378edi.11.2022.01.28.08.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 08:51:57 -0800 (PST) Date: Fri, 28 Jan 2022 17:51:56 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: "Andrey V. Lepikhov" Cc: Tom Lane , PostgreSQL Hackers Subject: Re: Multiple Query IDs for a rewritten parse tree Message-ID: <20220128165156.yx43kcqeifjgiwmc@ddolgov.remote.csb> References: <1606733.1641689399@sss.pgh.pa.us> <54863479-1144-43fb-853e-fa7d279e2d37@postgrespro.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54863479-1144-43fb-853e-fa7d279e2d37@postgrespro.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Fri, Jan 21, 2022 at 11:33:22AM +0500, Andrey V. Lepikhov wrote: > On 1/9/22 5:49 AM, Tom Lane wrote: > > The idea I'd been vaguely thinking about is to allow attaching a list > > of query-hash nodes to a Query, where each node would contain a "tag" > > identifying the specific hash calculation method, and also the value > > of the query's hash calculated according to that method. We could > > probably get away with saying that all such hash values must be uint64. > > The main difference from your function-OID idea, I think, is that > > I'm envisioning the tags as being small integers with well-known > > values, similarly to the way we manage stakind values in pg_statistic. > > In this way, an extension that wants a hash that the core knows how > > to calculate doesn't need its own copy of the code, and similarly > > one extension could publish a calculation method for use by other > > extensions. > > To move forward, I have made a patch that implements this idea (see > attachment). It is a POC, but passes all regression tests. Thanks. Couple of comments off the top of my head: > Registration of an queryId generator implemented by analogy with extensible > methods machinery. Why not more like suggested with stakind and slots in some data structure? All of those generators have to be iterated anyway, so not sure if a hash table makes sense. > Also, I switched queryId to int64 type and renamed to > 'label'. A name with "id" in it would be better I believe. Label could be think of as "the query belongs to a certain category", while the purpose is identification. > 2. We need a custom queryId, that is based on a generated queryId (according > to the logic of pg_stat_statements). Could you clarify? > 4. We should reserve position of default in-core generator From the discussion above I was under the impression that the core generator should be distinguished by a predefined kind. > 5. We should add an EXPLAIN hook, to allow an extension to print this custom > queryId. Why? It would make sense if custom generation code will be generating some complex structure, but the queryId itself is still a hash.