From db436adf761bd5cb7990745ceba2959ac4bfca7c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 21 Aug 1999 03:49:17 +0000 Subject: Major revision of sort-node handling: push knowledge of query sort order down into planner, instead of handling it only at the very top level of the planner. This fixes many things. An explicit sort is now avoided if there is a cheaper alternative (typically an indexscan) not only for ORDER BY, but also for the internal sort of GROUP BY. It works even when there is no other reason (such as a WHERE condition) to consider the indexscan. It works for indexes on functions. It works for indexes on functions, backwards. It's just so cool... CAUTION: I have changed the representation of SortClause nodes, therefore THIS UPDATE BREAKS STORED RULES. You will need to initdb. --- src/backend/optimizer/path/joinpath.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/backend/optimizer/path/joinpath.c') diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index 55891d87a95..c1ac6a2c4d8 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.45 1999/08/16 02:17:51 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.46 1999/08/21 03:49:00 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -408,7 +408,8 @@ match_unsorted_outer(RelOptInfo *joinrel, trialinnerpath = get_cheapest_path_for_pathkeys(innerrel->pathlist, ltruncate(clausecount, - trialsortkeys)); + trialsortkeys), + false); if (trialinnerpath != NULL && trialinnerpath->path_cost < cheapest_cost) { @@ -488,7 +489,8 @@ match_unsorted_inner(RelOptInfo *joinrel, /* Look for an outer path already ordered well enough to merge */ mergeouterpath = get_cheapest_path_for_pathkeys(outerrel->pathlist, - outersortkeys); + outersortkeys, + false); /* Should we use the mergeouter, or sort the cheapest outer? */ if (mergeouterpath != NULL && -- cgit v1.2.3