Re: Make query ID more portable

From: Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Julien Rouhaud <rjuju123(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, Jim Finnerty <jfinnert(at)amazon(dot)com>
Subject: Re: Make query ID more portable
Date: 2021-10-14 05:49:32
Message-ID: 82db99ed-0c23-30fc-ab03-4f290d2ca3fa@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/10/21 18:40, Tom Lane wrote:
> Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru> writes:
>> But core jumbling code is good, fast and much easier in support.
> A bigger issue is that query ID stability isn't something we are going
> to promise on a large scale --- for example, what if a new release adds
> some new fields to struct Query? So I'm not sure that "query IDs should
> survive dump/reload" is a useful goal to consider. It's certainly not
> something that could be reached by anything even remotely like the
> existing code.
Thank you for the explanation.
I think the problem of queryId is that is encapsulates two different
meanings:
1. It allows an extension to match an query on post parse and execution
stages. In this sense, queryId should be as unique as possible for each
query.
2. For pg_stat_statements purposes (and my project too) it represents an
query class and should be stable against permutations of range table
entries, clauses, e.t.c. For example:
"SELECT * FROM a,b;" and "SELECT * FROM b,a;" should have the same queryId.

This issue may be solved in an extension with next approach:
1. Force as unique value for queryId as extension wants in a post parse hook
2. Generalize the JumbleQuery routine code to generate a kind of query
class signature.

The attached patch is a first sketch for such change.

--
regards,
Andrey Lepikhov
Postgres Professional

Attachment Content-Type Size
0001-Add-callback-for-jumbling-of-an-OID-value.patch text/plain 15.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message osumi.takamichi@fujitsu.com 2021-10-14 06:13:18 RE: Failed transaction statistics to measure the logical replication progress
Previous Message Julien Rouhaud 2021-10-14 05:40:04 Re: Make query ID more portable