Use get_relation_data_width() to get average data width.
authorShigeru Hanada <hanada@metrosystems.co.jp>
Fri, 25 Feb 2011 02:36:40 +0000 (11:36 +0900)
committerShigeru Hanada <hanada@metrosystems.co.jp>
Fri, 25 Feb 2011 02:36:40 +0000 (11:36 +0900)
contrib/postgresql_fdw/postgresql_fdw.c

index 89b579012348d6770d2ca0b4a260738a73153f4a..39bd1be49f9aa63a097ec0873e12fdea25a1cc48 100644 (file)
@@ -715,26 +715,21 @@ static void
 estimate_costs(PlannerInfo *root, RelOptInfo *baserel, Cost *startup_cost, Cost *total_cost)
 {
    RangeTblEntry  *rte;
-   int             width;
    double          connection_cost = 0.0;
    double          transfer_cost = 0.0;
 
    elog(DEBUG3, "%s() called", __FUNCTION__);
 
-   /*
-    * Use cost_seqscan() to get approximate value.
-    */
+   /* get avarage width estimation */
    rte = planner_rt_fetch(baserel->relid, root);
-// cost_seqscan(&path->path, root, baserel);
-
-   width = get_relation_data_width(rte->relid, NULL);
+   baserel->width = get_relation_data_width(rte->relid, baserel->attr_widths);
 
    /* XXX arbitrary guesses */
    connection_cost = 10.0;
    transfer_cost = 1.0;
    *startup_cost += connection_cost;
    *total_cost += connection_cost;
-   *total_cost += transfer_cost * width * baserel->tuples;
+   *total_cost += transfer_cost * baserel->width * baserel->tuples;
 }
 
 /* ============================================================================