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

Commit58fe21c

Browse files
Alena Rybakinadanolivo
Alena Rybakina
authored andcommitted
Add compute_query_id parameter in aqo configure with value as regress.
It is necessary for avoiding output Query Identifier while vanille's test are running.(Look at more in explain.c:612.We can get fail condition if only query identifier is not null)Where clause 'NOT LIKE '%Query Identifier%'' is throwed away due to being necessary any more.This addition parameter is appeared if we set compute_query_id parameter with value as 'auto'.Appearance of the parameter is checked in only gucs test.a.lepikhov: cherry-picked this commit down to stable13 just to have assynchronized as possible versions of the branches.
1 parentbdbc327 commit58fe21c

9 files changed

+128
-81
lines changed

‎aqo.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ autovacuum = off
22
shared_preload_libraries = 'postgres_fdw, aqo'
33
max_parallel_maintenance_workers = 1 # switch off parallel workers because of unsteadiness
44
aqo.wide_search = 'on'
5+

‎aqo_pg13.patch

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ index bc05c96b4c..b6a3abe0d2 100644
5757
if (es->format == EXPLAIN_FORMAT_TEXT)
5858
appendStringInfoChar(es->str, '\n');
5959
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
60-
index682b28ed72..3a5c615deb 100644
60+
index692b6c1559..580d04d784 100644
6161
--- a/src/backend/nodes/copyfuncs.c
6262
+++ b/src/backend/nodes/copyfuncs.c
6363
@@ -132,6 +132,7 @@ CopyPlanFields(const Plan *from, Plan *newnode)
@@ -69,7 +69,7 @@ index 682b28ed72..3a5c615deb 100644
6969

7070
/*
7171
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
72-
index7237b52e96..5e2ee2732a 100644
72+
index21ececf0c2..a0e7a7ebca 100644
7373
--- a/src/backend/nodes/outfuncs.c
7474
+++ b/src/backend/nodes/outfuncs.c
7575
@@ -342,6 +342,7 @@ _outPlanInfo(StringInfo str, const Plan *node)
@@ -81,7 +81,7 @@ index 7237b52e96..5e2ee2732a 100644
8181

8282
/*
8383
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
84-
index62c945b6c5..a39046ca56 100644
84+
index7976b369ba..604314e0b3 100644
8585
--- a/src/backend/nodes/readfuncs.c
8686
+++ b/src/backend/nodes/readfuncs.c
8787
@@ -1580,6 +1580,11 @@ ReadCommonPlan(Plan *local_node)
@@ -394,7 +394,7 @@ index 917713c163..5b7bf1cec6 100644
394394

395395
/*
396396
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
397-
index60e7fda6a9..5732c7a685 100644
397+
index27c665ac12..f599fba755 100644
398398
--- a/src/backend/optimizer/plan/planner.c
399399
+++ b/src/backend/optimizer/plan/planner.c
400400
@@ -145,7 +145,8 @@ static List *extract_rollup_sets(List *groupingSets);
@@ -407,7 +407,7 @@ index 60e7fda6a9..5732c7a685 100644
407407
grouping_sets_data *gd,
408408
List *target_list);
409409
static RelOptInfo *create_grouping_paths(PlannerInfo *root,
410-
@@ -3682,7 +3683,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
410+
@@ -3686,7 +3687,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
411411
*/
412412
static double
413413
get_number_of_groups(PlannerInfo *root,
@@ -417,7 +417,7 @@ index 60e7fda6a9..5732c7a685 100644
417417
grouping_sets_data *gd,
418418
List *target_list)
419419
{
420-
@@ -3719,7 +3721,7 @@ get_number_of_groups(PlannerInfo *root,
420+
@@ -3723,7 +3725,7 @@ get_number_of_groups(PlannerInfo *root,
421421
GroupingSetData *gs = lfirst_node(GroupingSetData, lc2);
422422
doublenumGroups = estimate_num_groups(root,
423423
groupExprs,
@@ -426,7 +426,7 @@ index 60e7fda6a9..5732c7a685 100644
426426
&gset);
427427

428428
gs->numGroups = numGroups;
429-
@@ -3744,7 +3746,7 @@ get_number_of_groups(PlannerInfo *root,
429+
@@ -3748,7 +3750,7 @@ get_number_of_groups(PlannerInfo *root,
430430
GroupingSetData *gs = lfirst_node(GroupingSetData, lc2);
431431
doublenumGroups = estimate_num_groups(root,
432432
groupExprs,
@@ -435,7 +435,7 @@ index 60e7fda6a9..5732c7a685 100644
435435
&gset);
436436

437437
gs->numGroups = numGroups;
438-
@@ -3760,8 +3762,8 @@ get_number_of_groups(PlannerInfo *root,
438+
@@ -3764,8 +3766,8 @@ get_number_of_groups(PlannerInfo *root,
439439
groupExprs = get_sortgrouplist_exprs(parse->groupClause,
440440
target_list);
441441

@@ -446,7 +446,7 @@ index 60e7fda6a9..5732c7a685 100644
446446
}
447447
}
448448
else if (parse->groupingSets)
449-
@@ -4147,7 +4149,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
449+
@@ -4151,7 +4153,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
450450
* Estimate number of groups.
451451
*/
452452
dNumGroups = get_number_of_groups(root,
@@ -456,7 +456,7 @@ index 60e7fda6a9..5732c7a685 100644
456456
gd,
457457
extra->targetList);
458458

459-
@@ -6931,13 +6934,15 @@ create_partial_grouping_paths(PlannerInfo *root,
459+
@@ -6935,13 +6938,15 @@ create_partial_grouping_paths(PlannerInfo *root,
460460
if (cheapest_total_path != NULL)
461461
dNumPartialGroups =
462462
get_number_of_groups(root,
@@ -541,7 +541,7 @@ index a203e6f1ff..d31bf5bae6 100644
541541

542542
return ppi;
543543
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
544-
index821844ada3..85b2482114 100644
544+
index37458da096..248a1875a1 100644
545545
--- a/src/backend/utils/adt/selfuncs.c
546546
+++ b/src/backend/utils/adt/selfuncs.c
547547
@@ -147,6 +147,7 @@
@@ -635,18 +635,15 @@ index 5ebf070979..5b2acd7de2 100644
635635

636636

637637
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
638-
index 90f02ce6fd..f3e2138ee2 100644
638+
index 90f02ce6fd..88c332164d 100644
639639
--- a/src/include/nodes/plannodes.h
640640
+++ b/src/include/nodes/plannodes.h
641-
@@ -159,6 +159,12 @@ typedef struct Plan
641+
@@ -159,6 +159,9 @@ typedef struct Plan
642642
*/
643643
Bitmapset *extParam;
644644
Bitmapset *allParam;
645645
+
646-
+/*
647-
+ * Additional fields for an extension purposes.
648-
+ * TODO: allow to serialize/deserialize this list.
649-
+ */
646+
+/* Additional field for an extension purposes. */
650647
+List*ext_nodes;
651648
} Plan;
652649

‎expected/aqo_fdw.out

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,11 @@ SELECT x FROM frgn;
5454
(5 rows)
5555

5656
-- Push down base filters. Use verbose mode to see filters.
57-
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE))
58-
SELECT x FROM frgn WHERE x < 10;
59-
ERROR: syntax error at or near ")"
60-
LINE 1: ...LAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE))
61-
^
62-
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
63-
SELECT x FROM frgn WHERE x < 10;
64-
QUERY PLAN
57+
SELECT str FROM expln('
58+
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
59+
SELECT x FROM frgn WHERE x < 10;
60+
') AS str;
61+
str
6562
-----------------------------------------------------------
6663
Foreign Scan on public.frgn (actual rows=1 loops=1)
6764
AQO not used
@@ -72,6 +69,21 @@ SELECT x FROM frgn WHERE x < 10;
7269
JOINS: 0
7370
(7 rows)
7471

72+
SELECT str FROM expln('
73+
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
74+
SELECT x FROM frgn WHERE x < 10;
75+
') AS str;
76+
str
77+
-----------------------------------------------------------
78+
Foreign Scan on public.frgn (actual rows=1 loops=1)
79+
AQO: rows=1, error=0%
80+
Output: x
81+
Remote SQL: SELECT x FROM public.local WHERE ((x < 10))
82+
Using aqo: true
83+
AQO mode: LEARN
84+
JOINS: 0
85+
(7 rows)
86+
7587
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
7688
SELECT x FROM frgn WHERE x < -10; -- AQO ignores constants
7789
QUERY PLAN
@@ -98,10 +110,12 @@ SELECT str FROM expln('
98110
JOINS: 0
99111
(6 rows)
100112

101-
-- TODO: Should learn on postgres_fdw nodes
102-
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
103-
SELECT * FROM frgn AS a, frgn AS b WHERE a.x=b.x;
104-
QUERY PLAN
113+
-- Should learn on postgres_fdw nodes
114+
SELECT str FROM expln('
115+
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
116+
SELECT * FROM frgn AS a, frgn AS b WHERE a.x=b.x;
117+
') AS str;
118+
str
105119
--------------------------------------------------------------------------------------------------------
106120
Foreign Scan (actual rows=1 loops=1)
107121
AQO: rows=1, error=0%
@@ -246,9 +260,11 @@ SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
246260
JOINS: 0
247261
(6 rows)
248262

249-
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
250-
SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
251-
QUERY PLAN
263+
SELECT str FROM expln('
264+
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
265+
SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
266+
') AS str;
267+
str
252268
--------------------------------------------------------------------------------------------------------
253269
Foreign Scan (actual rows=0 loops=1)
254270
AQO: rows=1, error=100%

‎expected/gucs.out

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
CREATE EXTENSION aqo;
2+
-- Utility tool. Allow to filter system-dependent strings from an explain output.
3+
CREATE OR REPLACE FUNCTION expln(query_string text) RETURNS SETOF text AS $$
4+
BEGIN
5+
RETURN QUERY
6+
EXECUTE format('%s', query_string);
7+
RETURN;
8+
END;
9+
$$ LANGUAGE PLPGSQL;
210
SET aqo.join_threshold = 0;
311
SET aqo.mode = 'learn';
412
SET aqo.show_details = true;
@@ -12,9 +20,12 @@ SELECT true FROM aqo_reset(); -- Remember! DROP EXTENSION doesn't remove any AQO
1220
(1 row)
1321

1422
-- Check AQO addons to explain (the only stable data)
15-
EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF)
16-
SELECT x FROM t;
17-
QUERY PLAN
23+
SELECT regexp_replace(
24+
str,'Query Identifier: -?\m\d+\M','Query Identifier: N','g') as str FROM expln('
25+
EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF)
26+
SELECT x FROM t;
27+
') AS str;
28+
str
1829
------------------------------------------------
1930
Seq Scan on public.t (actual rows=100 loops=1)
2031
AQO not used
@@ -24,9 +35,12 @@ EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF)
2435
JOINS: 0
2536
(6 rows)
2637

27-
EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF)
28-
SELECT x FROM t;
29-
QUERY PLAN
38+
SELECT regexp_replace(
39+
str,'Query Identifier: -?\m\d+\M','Query Identifier: N','g') as str FROM expln('
40+
EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF)
41+
SELECT x FROM t;
42+
') AS str;
43+
str
3044
------------------------------------------------
3145
Seq Scan on public.t (actual rows=100 loops=1)
3246
AQO: rows=100, error=0%

‎expected/unsupported.out

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
CREATE EXTENSION aqo;
2+
-- Utility tool. Allow to filter system-dependent strings from an explain output.
3+
CREATE OR REPLACE FUNCTION expln(query_string text) RETURNS SETOF text AS $$
4+
BEGIN
5+
RETURN QUERY
6+
EXECUTE format('%s', query_string);
7+
RETURN;
8+
END;
9+
$$ LANGUAGE PLPGSQL;
210
SET aqo.join_threshold = 0;
311
SET aqo.mode = 'learn';
412
SET aqo.show_details = 'on';
@@ -484,17 +492,6 @@ SELECT * FROM
484492
-- any prediction on number of fetched tuples.
485493
-- So, if selectivity was wrong we could make bad choice of Scan operation.
486494
-- For example, we could choose suboptimal index.
487-
--
488-
-- Returns string-by-string explain of a query. Made for removing some strings
489-
-- from the explain output.
490-
--
491-
CREATE OR REPLACE FUNCTION expln(query_string text) RETURNS SETOF text AS $$
492-
BEGIN
493-
RETURN QUERY
494-
EXECUTE format('EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF) %s', query_string);
495-
RETURN;
496-
END;
497-
$$ LANGUAGE PLPGSQL;
498495
-- Turn off statistics gathering for simple demonstration of filtering problem.
499496
ALTER TABLE t SET (autovacuum_enabled = 'false');
500497
CREATE INDEX ind1 ON t(x);
@@ -530,10 +527,11 @@ SELECT count(*) FROM t WHERE x < 3 AND mod(x,3) = 1;
530527
50
531528
(1 row)
532529

533-
SELECT str AS result
534-
FROM expln('SELECT count(*) FROM t WHERE x < 3 AND mod(x,3) = 1') AS str
530+
SELECT str FROM expln('
531+
EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, SUMMARY OFF, TIMING OFF)
532+
SELECT count(*) FROM t WHERE x < 3 AND mod(x,3) = 1') AS str
535533
WHERE str NOT LIKE '%Heap Blocks%';
536-
result
534+
str
537535
-----------------------------------------------------------------
538536
Aggregate (actual rows=1 loops=1)
539537
AQO not used

‎preprocessing.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
#include"preprocessing.h"
6868
#include"storage.h"
6969

70-
7170
/* List of feature spaces, that are processing in this backend. */
7271
List*cur_classes=NIL;
7372

‎sql/aqo_fdw.sql

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
4444
SELECT xFROM frgn;
4545

4646
-- Push down base filters. Use verbose mode to see filters.
47-
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE))
48-
SELECT xFROM frgnWHERE x<10;
49-
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
50-
SELECT xFROM frgnWHERE x<10;
47+
SELECT strFROM expln('
48+
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
49+
SELECT x FROM frgn WHERE x < 10;
50+
')AS str;
51+
SELECT strFROM expln('
52+
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
53+
SELECT x FROM frgn WHERE x < 10;
54+
')AS str;
5155
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
5256
SELECT xFROM frgnWHERE x<-10;-- AQO ignores constants
5357

@@ -57,9 +61,11 @@ SELECT str FROM expln('
5761
SELECT * FROM frgn AS a, frgn AS b WHERE a.x=b.x;
5862
')AS strWHERE str NOTLIKE'%Sort Method%';
5963

60-
-- TODO: Should learn on postgres_fdw nodes
61-
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
62-
SELECT*FROM frgnAS a, frgnAS bWHEREa.x=b.x;
64+
-- Should learn on postgres_fdw nodes
65+
SELECT strFROM expln('
66+
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
67+
SELECT * FROM frgn AS a, frgn AS b WHERE a.x=b.x;
68+
')AS str;
6369

6470
CREATETABLElocal_a(aidintprimary key, avaltext);
6571
CREATETABLElocal_b(bidintprimary key, aidintreferences local_a(aid), bvaltext);
@@ -130,8 +136,10 @@ reset enable_partitionwise_join;
130136
-- TODO: Non-mergejoinable join condition.
131137
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
132138
SELECT*FROM frgnAS a, frgnAS bWHEREa.x<b.x;
133-
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
134-
SELECT*FROM frgnAS a, frgnAS bWHEREa.x<b.x;
139+
SELECT strFROM expln('
140+
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
141+
SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
142+
')AS str;
135143

136144
DROP EXTENSION aqo CASCADE;
137145
DROP EXTENSION postgres_fdw CASCADE;

‎sql/gucs.sql

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
CREATE EXTENSION aqo;
2-
SETaqo.join_threshold=0;
32

3+
-- Utility tool. Allow to filter system-dependent strings from an explain output.
4+
CREATE OR REPLACEFUNCTIONexpln(query_stringtext) RETURNS SETOFtextAS $$
5+
BEGIN
6+
RETURN QUERY
7+
EXECUTE format('%s', query_string);
8+
RETURN;
9+
END;
10+
$$ LANGUAGE PLPGSQL;
11+
12+
SETaqo.join_threshold=0;
413
SETaqo.mode='learn';
514
SETaqo.show_details= true;
615

@@ -10,10 +19,16 @@ ANALYZE t;
1019

1120
SELECT trueFROM aqo_reset();-- Remember! DROP EXTENSION doesn't remove any AQO data gathered.
1221
-- Check AQO addons to explain (the only stable data)
13-
EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF)
14-
SELECT xFROM t;
15-
EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF)
16-
SELECT xFROM t;
22+
SELECT regexp_replace(
23+
str,'Query Identifier: -?\m\d+\M','Query Identifier: N','g')as strFROM expln('
24+
EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF)
25+
SELECT x FROM t;
26+
')AS str;
27+
SELECT regexp_replace(
28+
str,'Query Identifier: -?\m\d+\M','Query Identifier: N','g')as strFROM expln('
29+
EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF)
30+
SELECT x FROM t;
31+
')AS str;
1732
SETaqo.mode='disabled';
1833

1934
-- Check existence of the interface functions.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp