@@ -97,7 +97,6 @@ static void set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
9797Index rti ,RangeTblEntry * rte );
9898static void set_append_rel_pathlist (PlannerInfo * root ,RelOptInfo * rel ,Index rti ,RangeTblEntry * rte );
9999static List * accumulate_append_subpath (List * subpaths ,Path * path );
100- static void set_pathkeys (PlannerInfo * root ,RelOptInfo * childrel ,Path * path );
101100static void generate_mergeappend_paths (PlannerInfo * root ,RelOptInfo * rel ,
102101List * live_childrels ,
103102List * all_child_pathkeys );
@@ -482,7 +481,6 @@ pathman_set_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, Ran
482481foreach (lc ,root -> eq_classes )
483482{
484483EquivalenceClass * cur_ec = (EquivalenceClass * )lfirst (lc );
485- ListCell * lc2 ;
486484
487485if (list_length (cur_ec -> ec_members )> 1 )
488486{
@@ -521,22 +519,19 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
521519double parent_rows = 0 ;
522520double parent_size = 0 ;
523521ListCell * l ;
524- int i ;
525522
526523foreach (l ,root -> append_rel_list )
527524{
528525AppendRelInfo * appinfo = (AppendRelInfo * )lfirst (l );
529526int childRTindex ,
530527parentRTindex = rti ;
531- RangeTblEntry * childRTE ;
532528RelOptInfo * childrel ;
533529
534530/* append_rel_list contains all append rels; ignore others */
535531if (appinfo -> parent_relid != parentRTindex )
536532continue ;
537533
538534childRTindex = appinfo -> child_relid ;
539- childRTE = root -> simple_rte_array [childRTindex ];
540535
541536childrel = find_base_rel (root ,childRTindex );
542537Assert (childrel -> reloptkind == RELOPT_OTHER_MEMBER_REL );
@@ -639,12 +634,12 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
639634root -> append_rel_list = lappend (root -> append_rel_list ,appinfo );
640635root -> total_table_pages += (double )childrel -> pages ;
641636
642- /* Addto equivalence members */
637+ /* Add equivalence members */
643638foreach (lc ,root -> eq_classes )
644639{
645640EquivalenceClass * cur_ec = (EquivalenceClass * )lfirst (lc );
646- ListCell * lc2 ;
647641
642+ /* Copy equivalence member from parent and make some modifications */
648643if (list_length (cur_ec -> ec_members )> 0 )
649644{
650645EquivalenceMember * cur_em = (EquivalenceMember * )linitial (cur_ec -> ec_members );
@@ -665,6 +660,9 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
665660rel -> relids = bms_add_member (rel -> relids ,childRTindex );
666661root -> all_baserels = bms_add_member (root -> all_baserels ,childRTindex );
667662
663+ /* Recalc parent relation tuples count */
664+ rel -> tuples += childrel -> tuples ;
665+
668666heap_close (newrelation ,NoLock );
669667}
670668
@@ -1507,19 +1505,6 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
15071505all_child_pathkeys );
15081506}
15091507
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-
15231508static List *
15241509accumulate_append_subpath (List * subpaths ,Path * path )
15251510{