Re: [PATCH] Query Jumbling for CALL and SET utility statements

From: "Imseih (AWS), Sami" <simseih(at)amazon(dot)com>
To: "Drouvot, Bertrand" <bdrouvot(at)amazon(dot)com>, "Schneider (AWS), Jeremy" <schnjere(at)amazon(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>
Subject: Re: [PATCH] Query Jumbling for CALL and SET utility statements
Date: 2022-09-07 15:48:36
Message-ID: 82A35172-BEB3-4DFA-B11C-AE5E50A0F932@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This is ready for committer but I suggest the following for the
doc changes:

1.
Plannable queries (that is, SELECT, INSERT, UPDATE, and DELETE) are
combined into a single pg_stat_statements entry whenever they have
identical query structures according to an internal hash calculation.
Typically, two queries will be considered the same for this purpose
if they are semantically equivalent except for the values of literal
constants appearing in the query. Utility commands (that is, all other commands)
are compared strictly on the basis of their textual query strings, however.
-- to --
Plannable queries (that is, SELECT, INSERT, UPDATE, and DELETE) as
well as CALL and SET commands are combined into a single
pg_stat_statements entry whenever they have identical query
structures according to an internal hash calculation.
Typically, two queries will be considered the same for this purpose
if they are semantically equivalent except for the values of literal
constants appearing in the command. All other commands are compared
strictly on the basis of their textual query strings, however.

2.

pg_stat_statements.track_utility controls whether utility
commands are tracked by the module. Utility commands
are all those other than SELECT, INSERT, UPDATE and DELETE.
The default value is on. Only superusers can change this setting.
-- to --
pg_stat_statements.track_utility controls whether utility commands
are tracked by the module. Tracked utility commands are all those
other than SELECT, INSERT, UPDATE, DELETE, CALL and SET.
The default value is on. Only superusers can change this setting.

--
Thanks,
Sami Imseih
Amazon Web Services (AWS)

From: "Drouvot, Bertrand" <bdrouvot(at)amazon(dot)com>
Date: Friday, September 2, 2022 at 4:06 AM
To: "Imseih (AWS), Sami" <simseih(at)amazon(dot)com>, "Schneider (AWS), Jeremy" <schnjere(at)amazon(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>
Subject: Re: [PATCH] Query Jumbling for CALL and SET utility statements

Hi,
On 9/1/22 5:13 PM, Imseih (AWS), Sami wrote:

> Please find attached v2 as an attempt to do so.

+1 to the idea.

Thanks for looking at it!
I think it will be better to evaluate jstate instead of
JUMBLE_UTILITY, such as:

if (query->utilityStmt && !jstate)

instead of

if (query->utilityStmt && !JUMBLE_UTILITY(query->utilityStmt))

This will allow for support of potentially other utility statements
In the future without having to teach pg_stat_statements about them.
If a jstate is set for the utility statements, pgss will do the right thing.

Fair point, thanks!

v3 including this change is attached.

Thanks,
--

Bertrand Drouvot

PostgreSQL Contributors Team

RDS Open Source Databases

Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2022-09-07 15:48:43 Re: SYSTEM_USER reserved word implementation
Previous Message Jonathan S. Katz 2022-09-07 15:40:55 Re: PostgreSQL 15 Beta 4 release announcement draft