@@ -97,7 +97,6 @@ static void set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
97
97
Index rti ,RangeTblEntry * rte );
98
98
static void set_append_rel_pathlist (PlannerInfo * root ,RelOptInfo * rel ,Index rti ,RangeTblEntry * rte );
99
99
static List * accumulate_append_subpath (List * subpaths ,Path * path );
100
- static void set_pathkeys (PlannerInfo * root ,RelOptInfo * childrel ,Path * path );
101
100
static void generate_mergeappend_paths (PlannerInfo * root ,RelOptInfo * rel ,
102
101
List * live_childrels ,
103
102
List * all_child_pathkeys );
@@ -482,7 +481,6 @@ pathman_set_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, Ran
482
481
foreach (lc ,root -> eq_classes )
483
482
{
484
483
EquivalenceClass * cur_ec = (EquivalenceClass * )lfirst (lc );
485
- ListCell * lc2 ;
486
484
487
485
if (list_length (cur_ec -> ec_members )> 1 )
488
486
{
@@ -521,22 +519,19 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
521
519
double parent_rows = 0 ;
522
520
double parent_size = 0 ;
523
521
ListCell * l ;
524
- int i ;
525
522
526
523
foreach (l ,root -> append_rel_list )
527
524
{
528
525
AppendRelInfo * appinfo = (AppendRelInfo * )lfirst (l );
529
526
int childRTindex ,
530
527
parentRTindex = rti ;
531
- RangeTblEntry * childRTE ;
532
528
RelOptInfo * childrel ;
533
529
534
530
/* append_rel_list contains all append rels; ignore others */
535
531
if (appinfo -> parent_relid != parentRTindex )
536
532
continue ;
537
533
538
534
childRTindex = appinfo -> child_relid ;
539
- childRTE = root -> simple_rte_array [childRTindex ];
540
535
541
536
childrel = find_base_rel (root ,childRTindex );
542
537
Assert (childrel -> reloptkind == RELOPT_OTHER_MEMBER_REL );
@@ -639,12 +634,12 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
639
634
root -> append_rel_list = lappend (root -> append_rel_list ,appinfo );
640
635
root -> total_table_pages += (double )childrel -> pages ;
641
636
642
- /* Addto equivalence members */
637
+ /* Add equivalence members */
643
638
foreach (lc ,root -> eq_classes )
644
639
{
645
640
EquivalenceClass * cur_ec = (EquivalenceClass * )lfirst (lc );
646
- ListCell * lc2 ;
647
641
642
+ /* Copy equivalence member from parent and make some modifications */
648
643
if (list_length (cur_ec -> ec_members )> 0 )
649
644
{
650
645
EquivalenceMember * cur_em = (EquivalenceMember * )linitial (cur_ec -> ec_members );
@@ -665,6 +660,9 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
665
660
rel -> relids = bms_add_member (rel -> relids ,childRTindex );
666
661
root -> all_baserels = bms_add_member (root -> all_baserels ,childRTindex );
667
662
663
+ /* Recalc parent relation tuples count */
664
+ rel -> tuples += childrel -> tuples ;
665
+
668
666
heap_close (newrelation ,NoLock );
669
667
}
670
668
@@ -1507,19 +1505,6 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
1507
1505
all_child_pathkeys );
1508
1506
}
1509
1507
1510
- void
1511
- set_pathkeys (PlannerInfo * root ,RelOptInfo * childrel ,Path * path )
1512
- {
1513
- ListCell * lc ;
1514
- PathKey * pathkey ;
1515
-
1516
- foreach (lc ,root -> sort_pathkeys )
1517
- {
1518
- pathkey = (PathKey * )lfirst (lc );
1519
- path -> pathkeys = lappend (path -> pathkeys ,pathkey );
1520
- }
1521
- }
1522
-
1523
1508
static List *
1524
1509
accumulate_append_subpath (List * subpaths ,Path * path )
1525
1510
{