Skip to content

Commit 7d07684

Browse files
committed
Changes needed to use core hooks proposed.
1 parent 9dcc7b3 commit 7d07684

9 files changed

+191
-171
lines changed

Diff for: aqo.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ set_baserel_rows_estimate_hook_type prev_set_baserel_rows_estimate_hook;
115115
get_parameterized_baserel_size_hook_type prev_get_parameterized_baserel_size_hook;
116116
set_joinrel_size_estimates_hook_type prev_set_joinrel_size_estimates_hook;
117117
get_parameterized_joinrel_size_hook_type prev_get_parameterized_joinrel_size_hook;
118-
ExplainOnePlan_hook_type prev_ExplainOnePlan_hook;
119-
ExplainOneNode_hook_type prev_ExplainOneNode_hook;
118+
explain_per_plan_hook_type prev_explain_per_plan_hook = NULL;
119+
explain_per_node_hook_type prev_explain_per_node_hook = NULL;
120120
static shmem_request_hook_type prev_shmem_request_hook = NULL;
121121
static object_access_hook_type prev_object_access_hook;
122122

@@ -480,10 +480,10 @@ _PG_init(void)
480480
create_plan_hook = aqo_create_plan_hook;
481481

482482
/* Service hooks. */
483-
prev_ExplainOnePlan_hook = ExplainOnePlan_hook;
484-
ExplainOnePlan_hook = print_into_explain;
485-
prev_ExplainOneNode_hook = ExplainOneNode_hook;
486-
ExplainOneNode_hook = print_node_explain;
483+
prev_explain_per_plan_hook = explain_per_plan_hook;
484+
explain_per_plan_hook = print_into_explain;
485+
prev_explain_per_node_hook = explain_per_node_hook;
486+
explain_per_node_hook = print_node_explain;
487487

488488
prev_create_upper_paths_hook = create_upper_paths_hook;
489489
create_upper_paths_hook = aqo_store_upper_signature_hook;

Diff for: aqo.h

+9-6
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ extern set_joinrel_size_estimates_hook_type
252252
prev_set_joinrel_size_estimates_hook;
253253
extern get_parameterized_joinrel_size_hook_type
254254
prev_get_parameterized_joinrel_size_hook;
255-
extern ExplainOnePlan_hook_type prev_ExplainOnePlan_hook;
256-
extern ExplainOneNode_hook_type prev_ExplainOneNode_hook;
255+
extern explain_per_plan_hook_type prev_explain_per_plan_hook;
256+
extern explain_per_node_hook_type prev_explain_per_node_hook;
257257

258258
extern void ppi_hook(ParamPathInfo *ppi);
259259
extern int aqo_statement_timeout;
@@ -269,12 +269,15 @@ extern bool load_fss_ext(uint64 fs, int fss, OkNNrdata *data, List **reloids);
269269
extern bool update_fss_ext(uint64 fs, int fss, OkNNrdata *data, List *reloids);
270270

271271
/* Query preprocessing hooks */
272-
extern void print_into_explain(PlannedStmt *plannedstmt, IntoClause *into,
273-
struct ExplainState *es, const char *queryString,
272+
extern void print_into_explain(PlannedStmt *ps,
273+
IntoClause *into,
274+
struct ExplainState *es,
275+
const char *queryString,
274276
ParamListInfo params,
275-
const instr_time *planduration,
276277
QueryEnvironment *queryEnv);
277-
extern void print_node_explain(struct ExplainState *es, PlanState *ps, Plan *plan);
278+
extern void print_node_explain(PlanState *ps, List *ancestors,
279+
const char *relationship, const char *plan_name,
280+
struct ExplainState *es);
278281

279282
/* Cardinality estimation */
280283
extern double predict_for_relation(List *restrict_clauses, List *selectivities,

Diff for: expected/aqo_fdw.out

+17-17
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ SELECT str FROM expln('
6666
str
6767
-----------------------------------------------------------
6868
Foreign Scan on public.frgn (actual rows=1.00 loops=1)
69-
AQO not used
7069
Output: x
7170
Remote SQL: SELECT x FROM public.local WHERE ((x < 10))
71+
AQO not used
7272
Using aqo: true
7373
AQO mode: LEARN
7474
JOINS: 0
@@ -81,9 +81,9 @@ SELECT str FROM expln('
8181
str
8282
-----------------------------------------------------------
8383
Foreign Scan on public.frgn (actual rows=1.00 loops=1)
84-
AQO: rows=1, error=0%
8584
Output: x
8685
Remote SQL: SELECT x FROM public.local WHERE ((x < 10))
86+
AQO: rows=1, error=0%
8787
Using aqo: true
8888
AQO mode: LEARN
8989
JOINS: 0
@@ -108,8 +108,8 @@ SELECT str FROM expln('
108108
str
109109
---------------------------------------------------------------
110110
Merge Join (actual rows=1.00 loops=1)
111-
AQO not used
112111
Merge Cond: (a.x = b.x)
112+
AQO not used
113113
-> Sort (actual rows=1.00 loops=1)
114114
Sort Key: a.x
115115
-> Foreign Scan on frgn a (actual rows=1.00 loops=1)
@@ -131,10 +131,10 @@ SELECT str FROM expln('
131131
str
132132
--------------------------------------------------------------------------------------------------------
133133
Foreign Scan (actual rows=1.00 loops=1)
134-
AQO: rows=1, error=0%
135134
Output: a.x, b.x
136135
Relations: (public.frgn a) INNER JOIN (public.frgn b)
137136
Remote SQL: SELECT r1.x, r2.x FROM (public.local r1 INNER JOIN public.local r2 ON (((r1.x = r2.x))))
137+
AQO: rows=1, error=0%
138138
Using aqo: true
139139
AQO mode: LEARN
140140
JOINS: 0
@@ -153,8 +153,8 @@ WHERE a.aid = b.aid AND b.bval like 'val%';
153153
QUERY PLAN
154154
-----------------------------------------------
155155
Foreign Scan (actual rows=1000.00 loops=1)
156-
AQO not used
157156
Relations: (frgn_a a) INNER JOIN (frgn_b b)
157+
AQO not used
158158
Using aqo: true
159159
AQO mode: LEARN
160160
JOINS: 0
@@ -166,8 +166,8 @@ WHERE a.aid = b.aid AND b.bval like 'val%';
166166
QUERY PLAN
167167
-----------------------------------------------
168168
Foreign Scan (actual rows=1000.00 loops=1)
169-
AQO: rows=1000, error=0%
170169
Relations: (frgn_a a) INNER JOIN (frgn_b b)
170+
AQO: rows=1000, error=0%
171171
Using aqo: true
172172
AQO mode: LEARN
173173
JOINS: 0
@@ -207,17 +207,17 @@ WHERE str NOT LIKE '%Memory%';
207207
Append (actual rows=1000.00 loops=1)
208208
AQO not used
209209
-> Foreign Scan (actual rows=400.00 loops=1)
210-
AQO not used
211210
Relations: (main_p0 a_1) INNER JOIN (ref_p0 b_1)
212-
-> Foreign Scan (actual rows=300.00 loops=1)
213211
AQO not used
212+
-> Foreign Scan (actual rows=300.00 loops=1)
214213
Relations: (main_p1 a_2) INNER JOIN (ref_p1 b_2)
215-
-> Hash Join (actual rows=300.00 loops=1)
216214
AQO not used
215+
-> Hash Join (actual rows=300.00 loops=1)
217216
Hash Cond: (b_3.aid = a_3.aid)
217+
AQO not used
218218
-> Seq Scan on ref_p2 b_3 (actual rows=300.00 loops=1)
219-
AQO not used
220219
Filter: (bval ~~ 'val%'::text)
220+
AQO not used
221221
-> Hash (actual rows=38.00 loops=1)
222222
-> Seq Scan on main_p2 a_3 (actual rows=38.00 loops=1)
223223
AQO not used
@@ -237,17 +237,17 @@ WHERE str NOT LIKE '%Memory%';
237237
Append (actual rows=1000.00 loops=1)
238238
AQO not used
239239
-> Foreign Scan (actual rows=400.00 loops=1)
240-
AQO: rows=400, error=0%
241240
Relations: (main_p0 a_1) INNER JOIN (ref_p0 b_1)
241+
AQO: rows=400, error=0%
242242
-> Foreign Scan (actual rows=300.00 loops=1)
243-
AQO: rows=300, error=0%
244243
Relations: (main_p1 a_2) INNER JOIN (ref_p1 b_2)
245-
-> Hash Join (actual rows=300.00 loops=1)
246244
AQO: rows=300, error=0%
245+
-> Hash Join (actual rows=300.00 loops=1)
247246
Hash Cond: (b_3.aid = a_3.aid)
247+
AQO: rows=300, error=0%
248248
-> Seq Scan on ref_p2 b_3 (actual rows=300.00 loops=1)
249-
AQO: rows=300, error=0%
250249
Filter: (bval ~~ 'val%'::text)
250+
AQO: rows=300, error=0%
251251
-> Hash (actual rows=38.00 loops=1)
252252
-> Seq Scan on main_p2 a_3 (actual rows=38.00 loops=1)
253253
AQO: rows=38, error=0%
@@ -266,14 +266,14 @@ SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
266266
QUERY PLAN
267267
---------------------------------------------------------------
268268
Nested Loop (actual rows=0.00 loops=1)
269-
AQO not used
270269
Join Filter: (a.x < b.x)
271270
Rows Removed by Join Filter: 1
271+
AQO not used
272272
-> Foreign Scan on frgn a (actual rows=1.00 loops=1)
273273
AQO not used
274274
-> Materialize (actual rows=1.00 loops=1)
275-
AQO not used
276275
Storage: Memory Maximum Storage: 17kB
276+
AQO not used
277277
-> Foreign Scan on frgn b (actual rows=1.00 loops=1)
278278
AQO not used
279279
Using aqo: true
@@ -288,10 +288,10 @@ SELECT str FROM expln('
288288
str
289289
--------------------------------------------------------------------------------------------------------
290290
Foreign Scan (actual rows=0.00 loops=1)
291-
AQO: rows=1, error=100%
292291
Output: a.x, b.x
293292
Relations: (public.frgn a) INNER JOIN (public.frgn b)
294293
Remote SQL: SELECT r1.x, r2.x FROM (public.local r1 INNER JOIN public.local r2 ON (((r1.x < r2.x))))
294+
AQO: rows=1, error=100%
295295
Using aqo: true
296296
AQO mode: LEARN
297297
JOINS: 0

Diff for: expected/feature_subspace.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ WHERE str NOT LIKE '%Memory%';
3131
result
3232
--------------------------------------------------------
3333
Merge Left Join (actual rows=10.00 loops=1)
34-
AQO not used
3534
Merge Cond: (a.x = b.x)
35+
AQO not used
3636
-> Sort (actual rows=10.00 loops=1)
3737
Sort Key: a.x
3838
-> Seq Scan on a (actual rows=10.00 loops=1)
@@ -54,8 +54,8 @@ WHERE str NOT LIKE '%Memory%';
5454
result
5555
--------------------------------------------------------
5656
Merge Left Join (actual rows=100.00 loops=1)
57-
AQO not used
5857
Merge Cond: (b.x = a.x)
58+
AQO not used
5959
-> Sort (actual rows=100.00 loops=1)
6060
Sort Key: b.x
6161
-> Seq Scan on b (actual rows=100.00 loops=1)

Diff for: expected/gucs.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ SELECT regexp_replace(
3535
str
3636
---------------------------------------------------
3737
Seq Scan on public.t (actual rows=100.00 loops=1)
38-
AQO not used
3938
Output: x
39+
AQO not used
4040
Query Identifier: N
4141
Using aqo: true
4242
AQO mode: LEARN
@@ -51,8 +51,8 @@ SELECT regexp_replace(
5151
str
5252
---------------------------------------------------
5353
Seq Scan on public.t (actual rows=100.00 loops=1)
54-
AQO: rows=100, error=0%
5554
Output: x
55+
AQO: rows=100, error=0%
5656
Query Identifier: N
5757
Using aqo: true
5858
AQO mode: LEARN

0 commit comments

Comments
 (0)