@@ -44,6 +44,7 @@ pathman_join_pathlist_hook(PlannerInfo *root,
44
44
ListCell * lc ;
45
45
double paramsel ;
46
46
WalkerContext context ;
47
+ bool innerrel_rinfo_contains_part_attr ;
47
48
48
49
if (set_join_pathlist_next )
49
50
set_join_pathlist_next (root , joinrel , outerrel ,
@@ -92,6 +93,11 @@ pathman_join_pathlist_hook(PlannerInfo *root,
92
93
paramsel *= wrap -> paramsel ;
93
94
}
94
95
96
+ innerrel_rinfo_contains_part_attr =
97
+ check_rinfo_for_partitioned_attr (innerrel -> baserestrictinfo ,
98
+ innerrel -> relid ,
99
+ inner_prel -> attnum );
100
+
95
101
foreach (lc , innerrel -> pathlist )
96
102
{
97
103
AppendPath * cur_inner_path = (AppendPath * ) lfirst (lc );
@@ -107,6 +113,16 @@ pathman_join_pathlist_hook(PlannerInfo *root,
107
113
108
114
ppi = get_baserel_parampathinfo (root , innerrel , inner_required );
109
115
116
+ /*
117
+ * Skip if neither rel->baserestrictinfo nor
118
+ * ppi->ppi_clauses reference partition attribute
119
+ */
120
+ if (!(innerrel_rinfo_contains_part_attr ||
121
+ (ppi && check_rinfo_for_partitioned_attr (ppi -> ppi_clauses ,
122
+ innerrel -> relid ,
123
+ inner_prel -> attnum ))))
124
+ continue ;
125
+
110
126
inner = create_runtimeappend_path (root , cur_inner_path ,
111
127
ppi ,
112
128
paramsel );
@@ -162,6 +178,7 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
162
178
double paramsel = 1.0 ;
163
179
WalkerContext context ;
164
180
int i ;
181
+ bool rel_rinfo_contains_part_attr = false;
165
182
166
183
if (prel -> parttype == PT_RANGE )
167
184
{
@@ -280,6 +297,11 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
280
297
if (!clause_contains_params ((Node * ) get_actual_clauses (rel -> baserestrictinfo )))
281
298
return ;
282
299
300
+ rel_rinfo_contains_part_attr =
301
+ check_rinfo_for_partitioned_attr (rel -> baserestrictinfo ,
302
+ rel -> relid ,
303
+ prel -> attnum );
304
+
283
305
foreach (lc , rel -> pathlist )
284
306
{
285
307
AppendPath * cur_path = (AppendPath * ) lfirst (lc );
@@ -295,6 +317,16 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
295
317
continue ;
296
318
}
297
319
320
+ /*
321
+ * Skip if neither rel->baserestrictinfo nor
322
+ * ppi->ppi_clauses reference partition attribute
323
+ */
324
+ if (!(rel_rinfo_contains_part_attr ||
325
+ (ppi && check_rinfo_for_partitioned_attr (ppi -> ppi_clauses ,
326
+ rel -> relid ,
327
+ prel -> attnum ))))
328
+ continue ;
329
+
298
330
if (IsA (cur_path , AppendPath ) && pg_pathman_enable_runtimeappend )
299
331
inner_path = create_runtimeappend_path (root , cur_path ,
300
332
ppi , paramsel );
0 commit comments