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

Commita1cd6e7

Browse files
author
Oleg Ivanov
committed
Closed PGPRO-363
1 parent7f7c2d1 commita1cd6e7

File tree

11 files changed

+474
-9
lines changed

11 files changed

+474
-9
lines changed

‎contrib/aqo/aqo.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ boolauto_tuning;
4343
boolcollect_stat;
4444
booladding_query;
4545
boolexplain_only;
46+
boolexplain_aqo;
4647

4748
/* Query execution time */
4849
instr_timequery_starttime;
@@ -58,6 +59,7 @@ get_parameterized_baserel_size_hook_type prev_get_parameterized_baserel_size_hoo
5859
set_joinrel_size_estimates_hook_typeprev_set_joinrel_size_estimates_hook;
5960
get_parameterized_joinrel_size_hook_typeprev_get_parameterized_joinrel_size_hook;
6061
copy_generic_path_info_hook_typeprev_copy_generic_path_info_hook;
62+
ExplainOnePlan_hook_typeprev_ExplainOnePlan_hook;
6163

6264
/*****************************************************************************
6365
*
@@ -102,6 +104,8 @@ _PG_init(void)
102104
&aqo_get_parameterized_joinrel_size;
103105
prev_copy_generic_path_info_hook=copy_generic_path_info_hook;
104106
copy_generic_path_info_hook=&aqo_copy_generic_path_info;
107+
prev_ExplainOnePlan_hook=ExplainOnePlan_hook;
108+
ExplainOnePlan_hook=print_into_explain;
105109
init_deactivated_queries_storage();
106110
}
107111

@@ -119,6 +123,7 @@ _PG_fini(void)
119123
get_parameterized_joinrel_size_hook=
120124
prev_get_parameterized_joinrel_size_hook;
121125
copy_generic_path_info_hook=prev_copy_generic_path_info_hook;
126+
ExplainOnePlan_hook=prev_ExplainOnePlan_hook;
122127
fini_deactivated_queries_storage();
123128
}
124129

‎contrib/aqo/aqo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
#include"catalog/indexing.h"
122122
#include"catalog/pg_type.h"
123123
#include"catalog/pg_operator.h"
124+
#include"commands/explain.h"
124125
#include"executor/executor.h"
125126
#include"executor/execdesc.h"
126127
#include"nodes/makefuncs.h"
@@ -195,6 +196,7 @@ extern bool auto_tuning;
195196
externboolcollect_stat;
196197
externbooladding_query;
197198
externboolexplain_only;
199+
externboolexplain_aqo;
198200

199201
/* Query execution time */
200202
externinstr_timequery_starttime;
@@ -215,6 +217,7 @@ externget_parameterized_joinrel_size_hook_type
215217
prev_get_parameterized_joinrel_size_hook;
216218
externcopy_generic_path_info_hook_type
217219
prev_copy_generic_path_info_hook;
220+
externExplainOnePlan_hook_typeprev_ExplainOnePlan_hook;
218221

219222

220223
/* Hash functions */
@@ -254,6 +257,9 @@ PlannedStmt *call_default_planner(Query *parse,
254257
PlannedStmt*aqo_planner(Query*parse,
255258
intcursorOptions,
256259
ParamListInfoboundParams);
260+
voidprint_into_explain(PlannedStmt*plannedstmt,IntoClause*into,
261+
ExplainState*es,constchar*queryString,
262+
ParamListInfoparams,constinstr_time*planduration);
257263
voiddisable_aqo_for_query(void);
258264

259265
/* Cardinality estimation hooks */

‎contrib/aqo/expected/aqo_disabled.out

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ AS (
1616
) INSERT INTO aqo_test1 (SELECT * FROM t);
1717
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
1818
ANALYZE aqo_test1;
19+
SET aqo.mode = 'disabled';
1920
CREATE TABLE tmp1 AS SELECT * FROM aqo_test0
2021
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
2122
SELECT count(*) FROM tmp1;
@@ -91,7 +92,8 @@ WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
9192
Index Scan using aqo_test0_idx_a on aqo_test0 (cost=0.28..8.35 rows=3 width=16)
9293
Index Cond: (a < 3)
9394
Filter: ((b < 3) AND (c < 3) AND (d < 3))
94-
(3 rows)
95+
Using aqo: true
96+
(4 rows)
9597

9698
EXPLAIN SELECT t1.a, t2.b, t3.c
9799
FROM aqo_test1 AS t1, aqo_test0 AS t2, aqo_test0 AS t3
@@ -108,7 +110,8 @@ WHERE t1.a < 1 AND t3.b < 1 AND t2.c < 1 AND t3.d < 0 AND t1.a = t2.a AND t1.b =
108110
Filter: (c < 1)
109111
-> Seq Scan on aqo_test0 t3 (cost=0.00..41.02 rows=1 width=8)
110112
Filter: ((b < 1) AND (d < 0))
111-
(10 rows)
113+
Using aqo: true
114+
(11 rows)
112115

113116
SET aqo.mode = 'disabled';
114117
EXPLAIN SELECT * FROM aqo_test0

‎contrib/aqo/expected/aqo_forced.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
6565
Index Scan using aqo_test0_idx_a on aqo_test0
6666
Index Cond: (a < 3)
6767
Filter: ((b < 3) AND (c < 3) AND (d < 3))
68-
(3 rows)
68+
Using aqo: true
69+
(4 rows)
6970

7071
EXPLAIN (COSTS FALSE)
7172
SELECT * FROM aqo_test0
@@ -75,7 +76,8 @@ WHERE a < 5 AND b < 5 AND c < 5 AND d < 5;
7576
Index Scan using aqo_test0_idx_a on aqo_test0
7677
Index Cond: (a < 5)
7778
Filter: ((b < 5) AND (c < 5) AND (d < 5))
78-
(3 rows)
79+
Using aqo: true
80+
(4 rows)
7981

8082
DROP INDEX aqo_test0_idx_a;
8183
DROP TABLE aqo_test0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp