mirror of
https://github.com/postgres/postgres.git
synced 2025-11-15 03:41:20 +03:00
Repair planning bugs caused by my misguided removal of restrictinfo link
fields in JoinPaths --- turns out that we do need that after all :-(. Also, rearrange planner so that only one RelOptInfo is created for a particular set of joined base relations, no matter how many different subsets of relations it can be created from. This saves memory and processing time compared to the old method of making a bunch of RelOptInfos and then removing the duplicates. Clean up the jointree iteration logic; not sure if it's better, but I sure find it more readable and plausible now, particularly for the case of 'bushy plans'.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: geqo_eval.c,v 1.46 2000/01/26 05:56:33 momjian Exp $
|
||||
* $Id: geqo_eval.c,v 1.47 2000/02/07 04:40:58 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "optimizer/cost.h"
|
||||
#include "optimizer/geqo.h"
|
||||
#include "optimizer/pathnode.h"
|
||||
#include "optimizer/paths.h"
|
||||
#include "utils/portal.h"
|
||||
|
||||
@@ -121,7 +122,6 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old
|
||||
{
|
||||
RelOptInfo *inner_rel; /* current relation */
|
||||
int base_rel_index;
|
||||
List *new_rels;
|
||||
RelOptInfo *new_rel;
|
||||
|
||||
if (rel_count < num_gene)
|
||||
@@ -130,7 +130,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old
|
||||
/* tour[0] = 3; tour[1] = 1; tour[2] = 2 */
|
||||
base_rel_index = (int) tour[rel_count];
|
||||
|
||||
inner_rel = (RelOptInfo *) nth(base_rel_index - 1, root->base_rel_list);
|
||||
inner_rel = (RelOptInfo *) nth(base_rel_index-1, root->base_rel_list);
|
||||
|
||||
if (rel_count == 0)
|
||||
{ /* processing first join with
|
||||
@@ -140,54 +140,23 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old
|
||||
}
|
||||
else
|
||||
{ /* tree main part */
|
||||
if (!(new_rels = make_rels_by_clause_joins(root, old_rel,
|
||||
old_rel->joininfo,
|
||||
inner_rel->relids)))
|
||||
List *acceptable_rels = lcons(inner_rel, NIL);
|
||||
|
||||
new_rel = make_rels_by_clause_joins(root, old_rel,
|
||||
acceptable_rels);
|
||||
if (! new_rel)
|
||||
{
|
||||
new_rels = make_rels_by_clauseless_joins(old_rel,
|
||||
lcons(inner_rel, NIL));
|
||||
|
||||
/*
|
||||
* we don't do bushy plans in geqo, do we? bjm 02/18/1999
|
||||
* new_rels = append(new_rels,
|
||||
* make_rels_by_clauseless_joins(old_rel,
|
||||
* lcons(old_rel,NIL));
|
||||
*/
|
||||
new_rel = make_rels_by_clauseless_joins(root, old_rel,
|
||||
acceptable_rels);
|
||||
if (! new_rel)
|
||||
elog(ERROR, "gimme_tree: failed to construct join rel");
|
||||
}
|
||||
|
||||
/* process new_rel->pathlist */
|
||||
update_rels_pathlist_for_joins(root, new_rels);
|
||||
|
||||
/* prune new_rels */
|
||||
/* MAU: is this necessary? */
|
||||
|
||||
/*
|
||||
* what's the matter if more than one new rel is left till
|
||||
* now?
|
||||
*/
|
||||
|
||||
/*
|
||||
* joinrels in newrels with different ordering of relids are
|
||||
* not possible
|
||||
*/
|
||||
if (length(new_rels) > 1)
|
||||
merge_rels_with_same_relids(new_rels);
|
||||
|
||||
if (length(new_rels) > 1)
|
||||
{ /* should never be reached ... */
|
||||
elog(DEBUG, "gimme_tree: still %d relations left", length(new_rels));
|
||||
}
|
||||
|
||||
rels_set_cheapest(root, new_rels);
|
||||
|
||||
/* get essential new relation */
|
||||
new_rel = (RelOptInfo *) lfirst(new_rels);
|
||||
rel_count++;
|
||||
Assert(length(new_rel->relids) == rel_count);
|
||||
|
||||
/* processing of other new_rel attributes */
|
||||
set_rel_rows_width(root, new_rel);
|
||||
|
||||
root->join_rel_list = lcons(new_rel, NIL);
|
||||
/* Find and save the cheapest path for this rel */
|
||||
set_cheapest(new_rel, new_rel->pathlist);
|
||||
|
||||
return gimme_tree(root, tour, rel_count, num_gene, new_rel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user