Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fbd53d

Browse files
committed
Remove the query_id_squash_values GUC
Commit62d712e introduced the capability to calculate the samequeryId for queries with different lengths of constants in a list for anIN clause. This behavior was originally enabled with a GUCquery_id_squash_values. After a discussion about the value of such aGUC, it was decided to back out of the use of a GUC and make thesquashing behavior the only available option.Author: Sami Imseih <samimseih@gmail.com>Discussion:https://postgr.es/m/Z-LZyygkkNyA8-kR@msg.df7cb.deDiscussion:https://postgr.es/m/CA+q6zcVTK-3C-8NWV1oY2NZrvtnMCDqnyYYyk1T7WMUG65MeOQ@mail.gmail.com
1 parent5d5f415 commit9fbd53d

File tree

10 files changed

+8
-104
lines changed

10 files changed

+8
-104
lines changed

‎contrib/pg_stat_statements/expected/dml.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ SELECT calls, rows, query FROM pg_stat_statements ORDER BY query COLLATE "C";
8080
1 | 10 | INSERT INTO pgss_dml_tab VALUES(generate_series($1, $2), $3)
8181
1 | 12 | SELECT * FROM pgss_dml_tab ORDER BY a
8282
2 | 4 | SELECT * FROM pgss_dml_tab WHERE a > $1 ORDER BY a
83-
1 | 8 | SELECT * FROM pgss_dml_tab WHERE a IN ($1, $2, $3, $4, $5)
83+
1 | 8 | SELECT * FROM pgss_dml_tab WHERE a IN ($1 /*, ... */)
8484
1 | 1 | SELECT pg_stat_statements_reset() IS NOT NULL AS t
8585
1 | 0 | SET pg_stat_statements.track_utility = $1
8686
6 | 6 | UPDATE pgss_dml_tab SET b = $1 WHERE a = $2

‎contrib/pg_stat_statements/expected/squashing.out

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,7 @@
44
CREATE EXTENSION pg_stat_statements;
55
CREATE TABLE test_squash (id int, data int);
66
-- IN queries
7-
-- No squashing is performed, as a baseline result
8-
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
9-
t
10-
---
11-
t
12-
(1 row)
13-
14-
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9);
15-
id | data
16-
----+------
17-
(0 rows)
18-
19-
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
20-
id | data
21-
----+------
22-
(0 rows)
23-
24-
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
25-
id | data
26-
----+------
27-
(0 rows)
28-
29-
SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C";
30-
query | calls
31-
--------------------------------------------------------------------------------------+-------
32-
SELECT * FROM test_squash WHERE id IN ($1, $2, $3, $4, $5, $6, $7, $8, $9) | 1
33-
SELECT * FROM test_squash WHERE id IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) | 1
34-
SELECT * FROM test_squash WHERE id IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) | 1
35-
SELECT pg_stat_statements_reset() IS NOT NULL AS t | 1
36-
(4 rows)
37-
387
-- Normal scenario, too many simple constants for an IN query
39-
SET query_id_squash_values = on;
408
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
419
t
4210
---
@@ -461,4 +429,3 @@ SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C";
461429
SELECT pg_stat_statements_reset() IS NOT NULL AS t | 1
462430
(2 rows)
463431

464-
RESET query_id_squash_values;

‎contrib/pg_stat_statements/sql/squashing.sql

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,7 @@ CREATE TABLE test_squash (id int, data int);
77

88
-- IN queries
99

10-
-- No squashing is performed, as a baseline result
11-
SELECT pg_stat_statements_reset()IS NOT NULLAS t;
12-
SELECT*FROM test_squashWHERE idIN (1,2,3,4,5,6,7,8,9);
13-
SELECT*FROM test_squashWHERE idIN (1,2,3,4,5,6,7,8,9,10);
14-
SELECT*FROM test_squashWHERE idIN (1,2,3,4,5,6,7,8,9,10,11);
15-
SELECT query, callsFROM pg_stat_statementsORDER BY query COLLATE"C";
16-
1710
-- Normal scenario, too many simple constants for an IN query
18-
SET query_id_squash_values=on;
19-
2011
SELECT pg_stat_statements_reset()IS NOT NULLAS t;
2112
SELECT*FROM test_squashWHERE idIN (1);
2213
SELECT*FROM test_squashWHERE idIN (1,2,3);
@@ -177,4 +168,3 @@ SELECT pg_stat_statements_reset() IS NOT NULL AS t;
177168
SELECT ARRAY[1,2,3,4,5,6,7,8,9,10];
178169
SELECT query, callsFROM pg_stat_statementsORDER BY query COLLATE"C";
179170

180-
RESET query_id_squash_values;

‎doc/src/sgml/config.sgml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8726,36 +8726,6 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
87268726
</listitem>
87278727
</varlistentry>
87288728

8729-
<varlistentry id="guc-query-id-squash-values" xreflabel="query_id_squash_values">
8730-
<term><varname>query_id_squash_values</varname> (<type>bool</type>)
8731-
<indexterm>
8732-
<primary><varname>query_id_squash_values</varname> configuration parameter</primary>
8733-
</indexterm>
8734-
</term>
8735-
<listitem>
8736-
<para>
8737-
Specifies how a list of constants (e.g., for an <literal>IN</literal>
8738-
clause) contributes to the query identifier computation.
8739-
Normally, every element of such a list contributes to the query
8740-
identifier separately, which means that two queries that only differ
8741-
in the number of elements in such a list would get different query
8742-
identifiers.
8743-
If this parameter is on, a list of constants will not contribute
8744-
to the query identifier. This means that two queries whose only
8745-
difference is the number of constants in such a list are going to get the
8746-
same query identifier.
8747-
</para>
8748-
<para>
8749-
Only constants are affected; bind parameters do not benefit from this
8750-
functionality. The default value is <literal>off</literal>.
8751-
</para>
8752-
<para>
8753-
This parameter also affects how <xref linkend="pgstatstatements"/>
8754-
generates normalized query texts.
8755-
</para>
8756-
</listitem>
8757-
</varlistentry>
8758-
87598729
<varlistentry id="guc-log-statement-stats">
87608730
<term><varname>log_statement_stats</varname> (<type>boolean</type>)
87618731
<indexterm>

‎doc/src/sgml/pgstatstatements.sgml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,13 +632,11 @@
632632
In some cases, queries with visibly different texts might get merged into a
633633
single <structname>pg_stat_statements</structname> entry; as explained above,
634634
this is expected to happen for semantically equivalent queries.
635-
In addition, if <varname>query_id_squash_values</varname> is enabled
636-
and the only difference between queries is the number of elements in a list
637-
of constants, the list will get squashed down to a single element but shown
635+
In addition, if the only difference between queries is the number of elements
636+
in a list of constants, the list will get squashed down to a single element but shown
638637
with a commented-out list indicator:
639638

640639
<screen>
641-
=# SET query_id_squash_values = on;
642640
=# SELECT pg_stat_statements_reset();
643641
=# SELECT * FROM test WHERE a IN (1, 2, 3, 4, 5, 6, 7);
644642
=# SELECT * FROM test WHERE a IN (1, 2, 3, 4, 5, 6, 7, 8);

‎src/backend/nodes/queryjumblefuncs.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
/* GUC parameters */
4747
intcompute_query_id=COMPUTE_QUERY_ID_AUTO;
4848

49-
/* Whether to merge constants in a list when computing query_id */
50-
boolquery_id_squash_values= false;
51-
5249
/*
5350
* True when compute_query_id is ON or AUTO, and a module requests them.
5451
*
@@ -472,7 +469,7 @@ IsSquashableConstList(List *elements, Node **firstExpr, Node **lastExpr)
472469
* If squashing is disabled, or the list is too short, we don't try to
473470
* squash it.
474471
*/
475-
if (!query_id_squash_values||list_length(elements)<2)
472+
if (list_length(elements)<2)
476473
return false;
477474

478475
foreach(temp,elements)
@@ -520,13 +517,10 @@ do { \
520517
#include"queryjumblefuncs.funcs.c"
521518

522519
/*
523-
* When query_id_squash_values is enabled, we jumble lists of constant
524-
* elements as one individual item regardless of how many elements are
525-
* in the list. This means different queries jumble to the same query_id,
526-
* if the only difference is the number of elements in the list.
527-
*
528-
* If query_id_squash_values is disabled or the list is not "simple
529-
* enough", we jumble each element normally.
520+
* We jumble lists of constant elements as one individual item regardless
521+
* of how many elements are in the list. This means different queries
522+
* jumble to the same query_id, if the only difference is the number of
523+
* elements in the list.
530524
*/
531525
staticvoid
532526
_jumbleElements(JumbleState*jstate,List*elements)

‎src/backend/postmaster/launch_backend.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ typedef struct
116116
boolredirection_done;
117117
boolIsBinaryUpgrade;
118118
boolquery_id_enabled;
119-
boolquery_id_squash_values;
120119
intmax_safe_fds;
121120
intMaxBackends;
122121
intnum_pmchild_slots;
@@ -778,7 +777,6 @@ save_backend_variables(BackendParameters *param,
778777
param->redirection_done=redirection_done;
779778
param->IsBinaryUpgrade=IsBinaryUpgrade;
780779
param->query_id_enabled=query_id_enabled;
781-
param->query_id_squash_values=query_id_squash_values;
782780
param->max_safe_fds=max_safe_fds;
783781

784782
param->MaxBackends=MaxBackends;
@@ -1039,7 +1037,6 @@ restore_backend_variables(BackendParameters *param)
10391037
redirection_done=param->redirection_done;
10401038
IsBinaryUpgrade=param->IsBinaryUpgrade;
10411039
query_id_enabled=param->query_id_enabled;
1042-
query_id_squash_values=param->query_id_squash_values;
10431040
max_safe_fds=param->max_safe_fds;
10441041

10451042
MaxBackends=param->MaxBackends;

‎src/backend/utils/misc/guc_tables.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,16 +2122,6 @@ struct config_bool ConfigureNamesBool[] =
21222122
NULL,NULL,NULL
21232123
},
21242124

2125-
{
2126-
{"query_id_squash_values",PGC_USERSET,STATS_MONITORING,
2127-
gettext_noop("Allows to merge constants in a list when computing "
2128-
"query_id."),
2129-
},
2130-
&query_id_squash_values,
2131-
false,
2132-
NULL,NULL,NULL
2133-
},
2134-
21352125
{
21362126
{"vacuum_truncate",PGC_USERSET,VACUUM_DEFAULT,
21372127
gettext_noop("Enables vacuum to truncate empty pages at the end of the table."),

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@
664664
# - Monitoring -
665665

666666
#compute_query_id = auto
667-
#query_id_squash_values = off
668667
#log_statement_stats = off
669668
#log_parser_stats = off
670669
#log_planner_stats = off

‎src/include/nodes/queryjumble.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ extern JumbleState *JumbleQuery(Query *query);
8686
externvoidEnableQueryId(void);
8787

8888
externPGDLLIMPORTboolquery_id_enabled;
89-
externPGDLLIMPORTboolquery_id_squash_values;
9089

9190
/*
9291
* Returns whether query identifier computation has been enabled, either

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp