diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-11-28 00:46:19 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-11-28 00:46:19 +0000 |
commit | 1a95f12702b4e535b5e26ed9c3fcd0b2a1b1a20f (patch) | |
tree | c56c54fce5968c874b21fb902c1090b486da4719 /src/backend/optimizer/util/relnode.c | |
parent | fe83b975b2bdfa9b553872aa9a5dc959ca89a51f (diff) | |
download | postgresql-1a95f12702b4e535b5e26ed9c3fcd0b2a1b1a20f.tar.gz postgresql-1a95f12702b4e535b5e26ed9c3fcd0b2a1b1a20f.zip |
Eliminate a lot of list-management overhead within join_search_one_level
by adding a requirement that build_join_rel add new join RelOptInfos to the
appropriate list immediately at creation. Per report from Robert Haas,
the list_concat_unique_ptr() calls that this change eliminates were taking
the lion's share of the runtime in larger join problems. This doesn't do
anything to fix the fundamental combinatorial explosion in large join
problems, but it should push out the threshold of pain a bit further.
Note: because this changes the order in which joinrel lists are built,
it might result in changes in selected plans in cases where different
alternatives have exactly the same costs. There is one example in the
regression tests.
Diffstat (limited to 'src/backend/optimizer/util/relnode.c')
-rw-r--r-- | src/backend/optimizer/util/relnode.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index 58505949331..70c3dc81ab4 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.95 2009/10/12 18:10:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.96 2009/11/28 00:46:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -402,6 +402,20 @@ build_join_rel(PlannerInfo *root, hentry->join_rel = joinrel; } + /* + * Also, if dynamic-programming join search is active, add the new joinrel + * to the appropriate sublist. Note: you might think the Assert on + * number of members should be for equality, but some of the level 1 + * rels might have been joinrels already, so we can only assert <=. + */ + if (root->join_rel_level) + { + Assert(root->join_cur_level > 0); + Assert(root->join_cur_level <= bms_num_members(joinrel->relids)); + root->join_rel_level[root->join_cur_level] = + lappend(root->join_rel_level[root->join_cur_level], joinrel); + } + return joinrel; } |