@@ -99,18 +99,13 @@ static void set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
99
99
Index rti , RangeTblEntry * rte );
100
100
static void generate_orderedappend_paths (PlannerInfo * root , RelOptInfo * rel ,
101
101
List * live_childrels ,
102
- List * all_child_pathkeys ,
103
- List * partitioned_rels );
102
+ List * all_child_pathkeys );
104
103
static Path * get_cheapest_parameterized_child_path (PlannerInfo * root ,
105
104
RelOptInfo * rel ,
106
105
Relids required_outer );
107
- static List * accumulate_partitioned_rels (List * partitioned_rels ,
108
- List * sub_partitioned_rels ,
109
- bool flatten_partitioned_rels );
110
106
static void accumulate_append_subpath (Path * path ,
111
- List * * subpaths , List * * special_subpaths ,
112
- List * * partitioned_rels ,
113
- bool flatten_partitioned_rels );
107
+ List * * subpaths ,
108
+ List * * special_subpaths );
114
109
static Path * get_singleton_append_subpath (Path * path );
115
110
static void set_dummy_rel_pathlist (RelOptInfo * rel );
116
111
static void set_subquery_pathlist (PlannerInfo * root , RelOptInfo * rel ,
@@ -1299,38 +1294,11 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1299
1294
List * all_child_pathkeys = NIL ;
1300
1295
List * all_child_outers = NIL ;
1301
1296
ListCell * l ;
1302
- List * partitioned_rels = NIL ;
1303
- List * partial_partitioned_rels = NIL ;
1304
- List * pa_partitioned_rels = NIL ;
1305
1297
double partial_rows = -1 ;
1306
- bool flatten_partitioned_rels ;
1307
1298
1308
1299
/* If appropriate, consider parallel append */
1309
1300
pa_subpaths_valid = enable_parallel_append && rel -> consider_parallel ;
1310
1301
1311
- /* What we do with the partitioned_rels list is different for UNION ALL */
1312
- flatten_partitioned_rels = (rel -> rtekind != RTE_SUBQUERY );
1313
-
1314
- /*
1315
- * For partitioned tables, we accumulate a list of Relids of each
1316
- * partitioned table which has at least one of its subpartitions directly
1317
- * present as a subpath in this Append. This is used later for run-time
1318
- * partition pruning. We must maintain separate lists for each Append
1319
- * Path that we create as some paths that we create here can't flatten
1320
- * sub-Appends and sub-MergeAppends into the top-level Append. We needn't
1321
- * bother doing this for join rels as no run-time pruning is done on
1322
- * those.
1323
- */
1324
- if (rel -> reloptkind != RELOPT_JOINREL && rel -> part_scheme != NULL )
1325
- {
1326
- partitioned_rels = list_make1 (bms_make_singleton (rel -> relid ));
1327
- partial_partitioned_rels = list_make1 (bms_make_singleton (rel -> relid ));
1328
-
1329
- /* skip this one if we're not going to make a Parallel Append path */
1330
- if (pa_subpaths_valid )
1331
- pa_partitioned_rels = list_make1 (bms_make_singleton (rel -> relid ));
1332
- }
1333
-
1334
1302
/*
1335
1303
* For every non-dummy child, remember the cheapest path. Also, identify
1336
1304
* all pathkeys (orderings) and parameterizations (required_outer sets)
@@ -1353,8 +1321,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1353
1321
if (childrel -> pathlist != NIL &&
1354
1322
childrel -> cheapest_total_path -> param_info == NULL )
1355
1323
accumulate_append_subpath (childrel -> cheapest_total_path ,
1356
- & subpaths , NULL , & partitioned_rels ,
1357
- flatten_partitioned_rels );
1324
+ & subpaths , NULL );
1358
1325
else
1359
1326
subpaths_valid = false;
1360
1327
@@ -1363,9 +1330,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1363
1330
{
1364
1331
cheapest_partial_path = linitial (childrel -> partial_pathlist );
1365
1332
accumulate_append_subpath (cheapest_partial_path ,
1366
- & partial_subpaths , NULL ,
1367
- & partial_partitioned_rels ,
1368
- flatten_partitioned_rels );
1333
+ & partial_subpaths , NULL );
1369
1334
}
1370
1335
else
1371
1336
partial_subpaths_valid = false;
@@ -1394,10 +1359,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1394
1359
Assert (cheapest_partial_path != NULL );
1395
1360
accumulate_append_subpath (cheapest_partial_path ,
1396
1361
& pa_partial_subpaths ,
1397
- & pa_nonpartial_subpaths ,
1398
- & pa_partitioned_rels ,
1399
- flatten_partitioned_rels );
1400
-
1362
+ & pa_nonpartial_subpaths );
1401
1363
}
1402
1364
else
1403
1365
{
@@ -1416,9 +1378,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1416
1378
*/
1417
1379
accumulate_append_subpath (nppath ,
1418
1380
& pa_nonpartial_subpaths ,
1419
- NULL ,
1420
- & pa_partitioned_rels ,
1421
- flatten_partitioned_rels );
1381
+ NULL );
1422
1382
}
1423
1383
}
1424
1384
@@ -1495,7 +1455,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1495
1455
if (subpaths_valid )
1496
1456
add_path (rel , (Path * ) create_append_path (root , rel , subpaths , NIL ,
1497
1457
NIL , NULL , 0 , false,
1498
- partitioned_rels , -1 ));
1458
+ -1 ));
1499
1459
1500
1460
/*
1501
1461
* Consider an append of unordered, unparameterized partial paths. Make
@@ -1538,7 +1498,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1538
1498
appendpath = create_append_path (root , rel , NIL , partial_subpaths ,
1539
1499
NIL , NULL , parallel_workers ,
1540
1500
enable_parallel_append ,
1541
- partial_partitioned_rels , -1 );
1501
+ -1 );
1542
1502
1543
1503
/*
1544
1504
* Make sure any subsequent partial paths use the same row count
@@ -1587,7 +1547,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1587
1547
appendpath = create_append_path (root , rel , pa_nonpartial_subpaths ,
1588
1548
pa_partial_subpaths ,
1589
1549
NIL , NULL , parallel_workers , true,
1590
- pa_partitioned_rels , partial_rows );
1550
+ partial_rows );
1591
1551
add_partial_path (rel , (Path * ) appendpath );
1592
1552
}
1593
1553
@@ -1597,8 +1557,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1597
1557
*/
1598
1558
if (subpaths_valid )
1599
1559
generate_orderedappend_paths (root , rel , live_childrels ,
1600
- all_child_pathkeys ,
1601
- partitioned_rels );
1560
+ all_child_pathkeys );
1602
1561
1603
1562
/*
1604
1563
* Build Append paths for each parameterization seen among the child rels.
@@ -1617,10 +1576,6 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1617
1576
{
1618
1577
Relids required_outer = (Relids ) lfirst (l );
1619
1578
ListCell * lcr ;
1620
- List * part_rels = NIL ;
1621
-
1622
- if (rel -> reloptkind != RELOPT_JOINREL && rel -> part_scheme != NULL )
1623
- part_rels = list_make1 (bms_make_singleton (rel -> relid ));
1624
1579
1625
1580
/* Select the child paths for an Append with this parameterization */
1626
1581
subpaths = NIL ;
@@ -1646,15 +1601,14 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1646
1601
subpaths_valid = false;
1647
1602
break ;
1648
1603
}
1649
- accumulate_append_subpath (subpath , & subpaths , NULL , & part_rels ,
1650
- flatten_partitioned_rels );
1604
+ accumulate_append_subpath (subpath , & subpaths , NULL );
1651
1605
}
1652
1606
1653
1607
if (subpaths_valid )
1654
1608
add_path (rel , (Path * )
1655
1609
create_append_path (root , rel , subpaths , NIL ,
1656
1610
NIL , required_outer , 0 , false,
1657
- part_rels , -1 ));
1611
+ -1 ));
1658
1612
}
1659
1613
1660
1614
/*
@@ -1681,7 +1635,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1681
1635
appendpath = create_append_path (root , rel , NIL , list_make1 (path ),
1682
1636
NIL , NULL ,
1683
1637
path -> parallel_workers , true,
1684
- partitioned_rels , partial_rows );
1638
+ partial_rows );
1685
1639
add_partial_path (rel , (Path * ) appendpath );
1686
1640
}
1687
1641
}
@@ -1717,26 +1671,13 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
1717
1671
static void
1718
1672
generate_orderedappend_paths (PlannerInfo * root , RelOptInfo * rel ,
1719
1673
List * live_childrels ,
1720
- List * all_child_pathkeys ,
1721
- List * partitioned_rels )
1674
+ List * all_child_pathkeys )
1722
1675
{
1723
1676
ListCell * lcp ;
1724
1677
List * partition_pathkeys = NIL ;
1725
1678
List * partition_pathkeys_desc = NIL ;
1726
1679
bool partition_pathkeys_partial = true;
1727
1680
bool partition_pathkeys_desc_partial = true;
1728
- List * startup_partitioned_rels = NIL ;
1729
- List * total_partitioned_rels = NIL ;
1730
- bool flatten_partitioned_rels ;
1731
-
1732
- /* Set up the method for building the partitioned rels lists */
1733
- flatten_partitioned_rels = (rel -> rtekind != RTE_SUBQUERY );
1734
-
1735
- if (rel -> reloptkind != RELOPT_JOINREL && rel -> part_scheme != NULL )
1736
- {
1737
- startup_partitioned_rels = list_make1 (bms_make_singleton (rel -> relid ));
1738
- total_partitioned_rels = list_make1 (bms_make_singleton (rel -> relid ));
1739
- }
1740
1681
1741
1682
/*
1742
1683
* Some partitioned table setups may allow us to use an Append node
@@ -1878,13 +1819,9 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
1878
1819
* child paths for the MergeAppend.
1879
1820
*/
1880
1821
accumulate_append_subpath (cheapest_startup ,
1881
- & startup_subpaths , NULL ,
1882
- & startup_partitioned_rels ,
1883
- flatten_partitioned_rels );
1822
+ & startup_subpaths , NULL );
1884
1823
accumulate_append_subpath (cheapest_total ,
1885
- & total_subpaths , NULL ,
1886
- & total_partitioned_rels ,
1887
- flatten_partitioned_rels );
1824
+ & total_subpaths , NULL );
1888
1825
}
1889
1826
}
1890
1827
@@ -1900,7 +1837,6 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
1900
1837
NULL ,
1901
1838
0 ,
1902
1839
false,
1903
- startup_partitioned_rels ,
1904
1840
-1 ));
1905
1841
if (startup_neq_total )
1906
1842
add_path (rel , (Path * ) create_append_path (root ,
@@ -1911,7 +1847,6 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
1911
1847
NULL ,
1912
1848
0 ,
1913
1849
false,
1914
- total_partitioned_rels ,
1915
1850
-1 ));
1916
1851
}
1917
1852
else
@@ -1921,15 +1856,13 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
1921
1856
rel ,
1922
1857
startup_subpaths ,
1923
1858
pathkeys ,
1924
- NULL ,
1925
- startup_partitioned_rels ));
1859
+ NULL ));
1926
1860
if (startup_neq_total )
1927
1861
add_path (rel , (Path * ) create_merge_append_path (root ,
1928
1862
rel ,
1929
1863
total_subpaths ,
1930
1864
pathkeys ,
1931
- NULL ,
1932
- total_partitioned_rels ));
1865
+ NULL ));
1933
1866
}
1934
1867
}
1935
1868
}
@@ -2008,54 +1941,6 @@ get_cheapest_parameterized_child_path(PlannerInfo *root, RelOptInfo *rel,
2008
1941
return cheapest ;
2009
1942
}
2010
1943
2011
- /*
2012
- * accumulate_partitioned_rels
2013
- * Record 'sub_partitioned_rels' in the 'partitioned_rels' list,
2014
- * flattening as appropriate.
2015
- */
2016
- static List *
2017
- accumulate_partitioned_rels (List * partitioned_rels ,
2018
- List * sub_partitioned_rels ,
2019
- bool flatten )
2020
- {
2021
- if (flatten )
2022
- {
2023
- /*
2024
- * We're only called with flatten == true when the partitioned_rels
2025
- * list has at most 1 element. So we can just add the members from
2026
- * sub list's first element onto the first element of
2027
- * partitioned_rels. Only later in planning when doing UNION ALL
2028
- * Append processing will we see flatten == false. partitioned_rels
2029
- * may end up with more than 1 element then, but we never expect to be
2030
- * called with flatten == true again after that, so we needn't bother
2031
- * doing anything here for anything but the initial element.
2032
- */
2033
- if (partitioned_rels != NIL && sub_partitioned_rels != NIL )
2034
- {
2035
- Relids partrels = (Relids ) linitial (partitioned_rels );
2036
- Relids subpartrels = (Relids ) linitial (sub_partitioned_rels );
2037
-
2038
- /* Ensure the above comment holds true */
2039
- Assert (list_length (partitioned_rels ) == 1 );
2040
- Assert (list_length (sub_partitioned_rels ) == 1 );
2041
-
2042
- linitial (partitioned_rels ) = bms_add_members (partrels , subpartrels );
2043
- }
2044
- }
2045
- else
2046
- {
2047
- /*
2048
- * Handle UNION ALL to partitioned tables. This always occurs after
2049
- * we've done the accumulation for sub-partitioned tables, so there's
2050
- * no need to consider how adding multiple elements to the top level
2051
- * list affects the flatten == true case above.
2052
- */
2053
- partitioned_rels = list_concat (partitioned_rels , sub_partitioned_rels );
2054
- }
2055
-
2056
- return partitioned_rels ;
2057
- }
2058
-
2059
1944
/*
2060
1945
* accumulate_append_subpath
2061
1946
* Add a subpath to the list being built for an Append or MergeAppend.
@@ -2076,24 +1961,9 @@ accumulate_partitioned_rels(List *partitioned_rels,
2076
1961
* children to subpaths and the rest to special_subpaths. If the latter is
2077
1962
* NULL, we don't flatten the path at all (unless it contains only partial
2078
1963
* paths).
2079
- *
2080
- * When pulling up sub-Appends and sub-Merge Appends, we also gather the
2081
- * path's list of partitioned tables and store in 'partitioned_rels'. The
2082
- * exact behavior here depends on the value of 'flatten_partitioned_rels'.
2083
- *
2084
- * When 'flatten_partitioned_rels' is true, 'partitioned_rels' will contain at
2085
- * most one element which is a Relids of the partitioned relations which there
2086
- * are subpaths for. In this case, we just add the RT indexes for the
2087
- * partitioned tables for the subpath we're pulling up to the single entry in
2088
- * 'partitioned_rels'. When 'flatten_partitioned_rels' is false we
2089
- * concatenate the path's partitioned rel list onto the top-level list. This
2090
- * done for UNION ALLs which could have a partitioned table in each union
2091
- * branch.
2092
1964
*/
2093
1965
static void
2094
- accumulate_append_subpath (Path * path , List * * subpaths , List * * special_subpaths ,
2095
- List * * partitioned_rels ,
2096
- bool flatten_partitioned_rels )
1966
+ accumulate_append_subpath (Path * path , List * * subpaths , List * * special_subpaths )
2097
1967
{
2098
1968
if (IsA (path , AppendPath ))
2099
1969
{
@@ -2102,9 +1972,6 @@ accumulate_append_subpath(Path *path, List **subpaths, List **special_subpaths,
2102
1972
if (!apath -> path .parallel_aware || apath -> first_partial_path == 0 )
2103
1973
{
2104
1974
* subpaths = list_concat (* subpaths , apath -> subpaths );
2105
- * partitioned_rels = accumulate_partitioned_rels (* partitioned_rels ,
2106
- apath -> partitioned_rels ,
2107
- flatten_partitioned_rels );
2108
1975
return ;
2109
1976
}
2110
1977
else if (special_subpaths != NULL )
@@ -2120,9 +1987,6 @@ accumulate_append_subpath(Path *path, List **subpaths, List **special_subpaths,
2120
1987
apath -> first_partial_path );
2121
1988
* special_subpaths = list_concat (* special_subpaths ,
2122
1989
new_special_subpaths );
2123
- * partitioned_rels = accumulate_partitioned_rels (* partitioned_rels ,
2124
- apath -> partitioned_rels ,
2125
- flatten_partitioned_rels );
2126
1990
return ;
2127
1991
}
2128
1992
}
@@ -2131,9 +1995,6 @@ accumulate_append_subpath(Path *path, List **subpaths, List **special_subpaths,
2131
1995
MergeAppendPath * mpath = (MergeAppendPath * ) path ;
2132
1996
2133
1997
* subpaths = list_concat (* subpaths , mpath -> subpaths );
2134
- * partitioned_rels = accumulate_partitioned_rels (* partitioned_rels ,
2135
- mpath -> partitioned_rels ,
2136
- flatten_partitioned_rels );
2137
1998
return ;
2138
1999
}
2139
2000
@@ -2195,7 +2056,7 @@ set_dummy_rel_pathlist(RelOptInfo *rel)
2195
2056
/* Set up the dummy path */
2196
2057
add_path (rel , (Path * ) create_append_path (NULL , rel , NIL , NIL ,
2197
2058
NIL , rel -> lateral_relids ,
2198
- 0 , false, NIL , -1 ));
2059
+ 0 , false, -1 ));
2199
2060
2200
2061
/*
2201
2062
* We set the cheapest-path fields immediately, just in case they were
0 commit comments