mirror of
https://github.com/postgres/postgres.git
synced 2025-11-15 03:41:20 +03:00
Major optimizer improvement for joining a large number of tables.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.39 1999/02/08 04:29:08 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.40 1999/02/09 03:51:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1290,8 +1290,9 @@ index_innerjoin(Query *root, RelOptInfo * rel, List *clausegroup_list,
|
||||
|
||||
pathnode->path.pathtype = T_IndexScan;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.path_order.ordtype = SORTOP_ORDER;
|
||||
pathnode->path.path_order.ord.sortop = index->ordering;
|
||||
pathnode->path.path_order = makeNode(PathOrder);
|
||||
pathnode->path.path_order->ordtype = SORTOP_ORDER;
|
||||
pathnode->path.path_order->ord.sortop = index->ordering;
|
||||
pathnode->path.keys = NIL; /* not sure about this, bjm 1998/09/21 */
|
||||
|
||||
pathnode->indexid = index->relids;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.15 1999/02/08 04:29:11 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.16 1999/02/09 03:51:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -324,11 +324,11 @@ match_unsorted_outer(RelOptInfo * joinrel,
|
||||
List *clauses = NIL;
|
||||
List *matchedJoinKeys = NIL;
|
||||
List *matchedJoinClauses = NIL;
|
||||
MergeInfo *xmergeinfo = (MergeInfo *) NULL;
|
||||
MergeInfo *xmergeinfo = (MergeInfo *) NULL;
|
||||
|
||||
outerpath = (Path *) lfirst(i);
|
||||
|
||||
outerpath_ordering = &outerpath->path_order;
|
||||
outerpath_ordering = outerpath->path_order;
|
||||
|
||||
if (outerpath_ordering)
|
||||
{
|
||||
@@ -464,14 +464,14 @@ match_unsorted_inner(RelOptInfo * joinrel,
|
||||
|
||||
foreach(i, innerpath_list)
|
||||
{
|
||||
MergeInfo *xmergeinfo = (MergeInfo *) NULL;
|
||||
MergeInfo *xmergeinfo = (MergeInfo *) NULL;
|
||||
List *clauses = NIL;
|
||||
List *matchedJoinKeys = NIL;
|
||||
List *matchedJoinClauses = NIL;
|
||||
|
||||
innerpath = (Path *) lfirst(i);
|
||||
|
||||
innerpath_ordering = &innerpath->path_order;
|
||||
innerpath_ordering = innerpath->path_order;
|
||||
|
||||
if (innerpath_ordering)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.11 1999/02/08 04:29:12 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.12 1999/02/09 03:51:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -218,8 +218,7 @@ match_paths_joinkeys(List *joinkeys,
|
||||
|
||||
key_match = every_func(joinkeys, path->keys, which_subkey);
|
||||
|
||||
if (equal_path_ordering(ordering,
|
||||
&path->path_order) &&
|
||||
if (equal_path_ordering(ordering, path->path_order) &&
|
||||
length(joinkeys) == length(path->keys) &&
|
||||
key_match)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.14 1999/02/08 04:29:12 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.15 1999/02/09 03:51:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,16 +52,17 @@ group_clauses_by_order(List *restrictinfo_list,
|
||||
* Create a new mergeinfo node and add it to 'mergeinfo-list'
|
||||
* if one does not yet exist for this merge ordering.
|
||||
*/
|
||||
PathOrder path_order;
|
||||
MergeInfo *xmergeinfo;
|
||||
PathOrder *path_order;
|
||||
MergeInfo *xmergeinfo;
|
||||
Expr *clause = restrictinfo->clause;
|
||||
Var *leftop = get_leftop(clause);
|
||||
Var *rightop = get_rightop(clause);
|
||||
JoinKey *keys;
|
||||
|
||||
path_order.ordtype = MERGE_ORDER;
|
||||
path_order.ord.merge = merge_ordering;
|
||||
xmergeinfo = match_order_mergeinfo(&path_order, mergeinfo_list);
|
||||
path_order = makeNode(PathOrder);
|
||||
path_order->ordtype = MERGE_ORDER;
|
||||
path_order->ord.merge = merge_ordering;
|
||||
xmergeinfo = match_order_mergeinfo(path_order, mergeinfo_list);
|
||||
if (inner_relid == leftop->varno)
|
||||
{
|
||||
keys = makeNode(JoinKey);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.15 1999/02/08 04:29:12 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.16 1999/02/09 03:51:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -104,13 +104,14 @@ create_or_index_paths(Query *root,
|
||||
|
||||
pathnode->path.pathtype = T_IndexScan;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.path_order.ordtype = SORTOP_ORDER;
|
||||
pathnode->path.path_order = makeNode(PathOrder);
|
||||
pathnode->path.path_order->ordtype = SORTOP_ORDER;
|
||||
/*
|
||||
* This is an IndexScan, but it does index lookups based
|
||||
* on the order of the fields specified in the WHERE clause,
|
||||
* not in any order, so the sortop is NULL.
|
||||
*/
|
||||
pathnode->path.path_order.ord.sortop = NULL;
|
||||
pathnode->path.path_order->ord.sortop = NULL;
|
||||
pathnode->path.keys = NIL; /* not sure about this, bjm 1998/09/21 */
|
||||
|
||||
pathnode->indexqual = lcons(clausenode, NIL);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.24 1999/02/08 04:29:12 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.25 1999/02/09 03:51:21 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -109,7 +109,7 @@ prune_rel_paths(List *rel_list)
|
||||
{
|
||||
path = (Path *) lfirst(y);
|
||||
|
||||
if (!path->path_order.ord.sortop)
|
||||
if (!path->path_order->ord.sortop)
|
||||
break;
|
||||
}
|
||||
cheapest = (JoinPath *) prune_rel_path(rel, path);
|
||||
|
||||
Reference in New Issue
Block a user