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

Commit632e864

Browse files
committed
show pruning clause of Runtime[Merge]Append
1 parent09ac33e commit632e864

File tree

8 files changed

+45
-11
lines changed

8 files changed

+45
-11
lines changed

‎expected/pathman_join_clause.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ SELECT m.tableoid::regclass, id1, id2, key, start_key, end_key
4040
Nested Loop
4141
-> Seq Scan on fk
4242
-> Custom Scan (RuntimeAppend)
43+
Prune by: (fk.id1 = m.id1)
4344
-> Bitmap Heap Scan on mytbl_0 m
4445
Recheck Cond: (id1 = fk.id1)
4546
Filter: ((fk.id2 = id2) AND (NOT (key <@ int4range(6, fk.end_key))))
@@ -80,7 +81,7 @@ SELECT m.tableoid::regclass, id1, id2, key, start_key, end_key
8081
Filter: ((fk.id2 = id2) AND (NOT (key <@ int4range(6, fk.end_key))))
8182
-> Bitmap Index Scan on mytbl_7_pkey
8283
Index Cond: (id1 = fk.id1)
83-
(43 rows)
84+
(44 rows)
8485

8586
/* test joint data */
8687
SELECT m.tableoid::regclass, id1, id2, key, start_key, end_key

‎expected/pathman_only.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ SELECT * FROM test_only.from_only_test JOIN q1 USING(val);
178178
-> Seq Scan on from_only_test from_only_test_1
179179
-> CTE Scan on q1
180180
-> Custom Scan (RuntimeAppend)
181+
Prune by: (q1.val = from_only_test.val)
181182
-> Seq Scan on from_only_test_1 from_only_test
182183
Filter: (q1.val = val)
183184
-> Seq Scan on from_only_test_2 from_only_test
@@ -198,7 +199,7 @@ SELECT * FROM test_only.from_only_test JOIN q1 USING(val);
198199
Filter: (q1.val = val)
199200
-> Seq Scan on from_only_test_10 from_only_test
200201
Filter: (q1.val = val)
201-
(25 rows)
202+
(26 rows)
202203

203204
/* should be OK */
204205
EXPLAIN (COSTS OFF)
@@ -209,6 +210,7 @@ WHERE val = (SELECT val FROM ONLY test_only.from_only_test
209210
QUERY PLAN
210211
-----------------------------------------------------------------
211212
Custom Scan (RuntimeAppend)
213+
Prune by: (from_only_test.val = $0)
212214
InitPlan 1 (returns $0)
213215
-> Limit
214216
-> Sort
@@ -234,7 +236,7 @@ WHERE val = (SELECT val FROM ONLY test_only.from_only_test
234236
Filter: (val = $0)
235237
-> Seq Scan on from_only_test_10 from_only_test
236238
Filter: (val = $0)
237-
(26 rows)
239+
(27 rows)
238240

239241
DROP SCHEMA test_only CASCADE;
240242
NOTICE: drop cascades to 12 other objects

‎expected/pathman_rowmarks.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ FOR SHARE;
100100
-> Seq Scan on first_3
101101
-> Seq Scan on first_4
102102
-> Custom Scan (RuntimeAppend)
103+
Prune by: (first.id = $1)
103104
-> Seq Scan on first_0 first
104105
Filter: (id = $1)
105106
-> Seq Scan on first_1 first
@@ -110,7 +111,7 @@ FOR SHARE;
110111
Filter: (id = $1)
111112
-> Seq Scan on first_4 first
112113
Filter: (id = $1)
113-
(23 rows)
114+
(24 rows)
114115

115116
/* A little harder (execution) */
116117
SELECT * FROM rowmarks.first
@@ -142,6 +143,7 @@ FOR SHARE;
142143
Sort Key: second.id
143144
-> Seq Scan on second
144145
-> Custom Scan (RuntimeAppend)
146+
Prune by: (first.id = $1)
145147
-> Seq Scan on first_0 first
146148
Filter: (id = $1)
147149
-> Seq Scan on first_1 first
@@ -152,7 +154,7 @@ FOR SHARE;
152154
Filter: (id = $1)
153155
-> Seq Scan on first_4 first
154156
Filter: (id = $1)
155-
(18 rows)
157+
(19 rows)
156158

157159
/* Two tables (execution) */
158160
SELECT * FROM rowmarks.first

‎expected/pathman_runtime_nodes.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ join (select * from test.run_values limit 4) as t2 on t1.id = t2.val;
318318
-> Limit
319319
-> Seq Scan on run_values
320320
-> Custom Scan (RuntimeAppend)
321+
Prune by: (run_values.val = t1.id)
321322
-> Seq Scan on runtime_test_1 t1
322323
Filter: (run_values.val = id)
323324
-> Index Only Scan using runtime_test_1_0_pkey on runtime_test_1_0 t1
@@ -332,7 +333,7 @@ join (select * from test.run_values limit 4) as t2 on t1.id = t2.val;
332333
Index Cond: (id = run_values.val)
333334
-> Index Only Scan using runtime_test_1_5_pkey on runtime_test_1_5 t1
334335
Index Cond: (id = run_values.val)
335-
(18 rows)
336+
(19 rows)
336337

337338
select from test.runtime_test_1 as t1
338339
join (select * from test.run_values limit 4) as t2 on t1.id = t2.val;
@@ -355,6 +356,7 @@ join (select * from test.run_values limit 4) as t2 on t1.id = t2.val;
355356
-> Limit
356357
-> Seq Scan on run_values
357358
-> Custom Scan (RuntimeAppend)
359+
Prune by: (run_values.val = t1.id)
358360
-> Index Only Scan using runtime_test_1_0_pkey on runtime_test_1_0 t1
359361
Index Cond: (id = run_values.val)
360362
-> Index Only Scan using runtime_test_1_1_pkey on runtime_test_1_1 t1
@@ -367,7 +369,7 @@ join (select * from test.run_values limit 4) as t2 on t1.id = t2.val;
367369
Index Cond: (id = run_values.val)
368370
-> Index Only Scan using runtime_test_1_5_pkey on runtime_test_1_5 t1
369371
Index Cond: (id = run_values.val)
370-
(16 rows)
372+
(17 rows)
371373

372374
select from test.runtime_test_1 as t1
373375
join (select * from test.run_values limit 4) as t2 on t1.id = t2.val;

‎src/include/nodes_common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ void end_append_common(CustomScanState *node);
9898
voidrescan_append_common(CustomScanState*node);
9999

100100
voidexplain_append_common(CustomScanState*node,
101+
List*ancestors,
102+
ExplainState*es,
101103
HTAB*children_table,
102-
ExplainState*es);
104+
List*custom_exprs);
103105

104106

105107
#endif/* NODES_COMMON_H */

‎src/nodes_common.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
#include"utils.h"
1414

1515
#include"access/sysattr.h"
16+
#include"optimizer/clauses.h"
1617
#include"optimizer/restrictinfo.h"
1718
#include"optimizer/tlist.h"
1819
#include"optimizer/var.h"
1920
#include"rewrite/rewriteManip.h"
2021
#include"utils/memutils.h"
22+
#include"utils/ruleutils.h"
2123

2224

2325
/* Allocation settings */
@@ -688,8 +690,27 @@ rescan_append_common(CustomScanState *node)
688690
}
689691

690692
void
691-
explain_append_common(CustomScanState*node,HTAB*children_table,ExplainState*es)
693+
explain_append_common(CustomScanState*node,
694+
List*ancestors,
695+
ExplainState*es,
696+
HTAB*children_table,
697+
List*custom_exprs)
692698
{
699+
List*deparse_context;
700+
char*exprstr;
701+
702+
/* Set up deparsing context */
703+
deparse_context=set_deparse_context_planstate(es->deparse_cxt,
704+
(Node*)node,
705+
ancestors);
706+
707+
/* Deparse the expression */
708+
exprstr=deparse_expression((Node*)make_ands_explicit(custom_exprs),
709+
deparse_context, true, false);
710+
711+
/* And add to es->str */
712+
ExplainPropertyText("Prune by",exprstr,es);
713+
693714
/* Construct excess PlanStates */
694715
if (!es->analyze)
695716
{

‎src/runtime_merge_append.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ runtimemergeappend_explain(CustomScanState *node, List *ancestors, ExplainState
482482
{
483483
RuntimeMergeAppendState*scan_state= (RuntimeMergeAppendState*)node;
484484

485-
explain_append_common(node,scan_state->rstate.children_table,es);
485+
explain_append_common(node,ancestors,es,
486+
scan_state->rstate.children_table,
487+
scan_state->rstate.custom_exprs);
486488

487489
/* We should print sort keys as well */
488490
show_sort_group_keys((PlanState*)&node->ss.ps,"Sort Key",

‎src/runtimeappend.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,7 @@ runtimeappend_explain(CustomScanState *node, List *ancestors, ExplainState *es)
140140
{
141141
RuntimeAppendState*scan_state= (RuntimeAppendState*)node;
142142

143-
explain_append_common(node,scan_state->children_table,es);
143+
explain_append_common(node,ancestors,es,
144+
scan_state->children_table,
145+
scan_state->custom_exprs);
144146
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp