diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-03-24 21:40:43 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-03-24 21:40:43 +0000 |
commit | 8cbeb5f131a4339aaf69c34a874922d79c0fe585 (patch) | |
tree | 70c85541d801ca324266069b03bcd879925b288b /src | |
parent | c07118b3b326537525bd5b834fb2849bc3ba9eba (diff) | |
download | postgresql-8cbeb5f131a4339aaf69c34a874922d79c0fe585.tar.gz postgresql-8cbeb5f131a4339aaf69c34a874922d79c0fe585.zip |
Save a few cycles in simple cases: no need to call cost_sort() when there
is no presorted path to compare with.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/plan/planmain.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index acc4eb5d938..4377359ddcc 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.53 2000/03/21 05:11:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.54 2000/03/24 21:40:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -174,7 +174,6 @@ subplanner(Query *root, { RelOptInfo *final_rel; Path *cheapestpath; - Path sort_path; /* dummy for result of cost_sort */ Path *presortedpath; /* @@ -288,21 +287,22 @@ subplanner(Query *root, * cheaper than doing an explicit sort on the cheapest-total-cost path. */ cheapestpath = final_rel->cheapest_total_path; - cost_sort(&sort_path, root->query_pathkeys, - final_rel->rows, final_rel->width); - sort_path.startup_cost += cheapestpath->total_cost; - sort_path.total_cost += cheapestpath->total_cost; - presortedpath = get_cheapest_fractional_path_for_pathkeys(final_rel->pathlist, root->query_pathkeys, tuple_fraction); if (presortedpath) { + Path sort_path; /* dummy for result of cost_sort */ + + cost_sort(&sort_path, root->query_pathkeys, + final_rel->rows, final_rel->width); + sort_path.startup_cost += cheapestpath->total_cost; + sort_path.total_cost += cheapestpath->total_cost; if (compare_fractional_path_costs(presortedpath, &sort_path, tuple_fraction) <= 0) { - /* Found a better presorted path, use it */ + /* Presorted path is cheaper, use it */ root->query_pathkeys = presortedpath->pathkeys; return create_plan(root, presortedpath); } |