Now that hashjoin is reliable for large joins (knock on wood),
remove optimizer's arbitrary limit on how large a join it will use hashing for. (The limit was too large to prevent the problems we'd been seeing, anyway...)
This commit is contained in:
parent
353d36f979
commit
c2f0d565f3
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.35 1999/05/16 19:45:37 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.36 1999/05/18 21:36:10 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -37,7 +37,6 @@ static List *match_unsorted_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, Rel
|
|||||||
List *mergeinfo_list);
|
List *mergeinfo_list);
|
||||||
static List *match_unsorted_inner(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
|
static List *match_unsorted_inner(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
|
||||||
List *innerpath_list, List *mergeinfo_list);
|
List *innerpath_list, List *mergeinfo_list);
|
||||||
static bool EnoughMemoryForHashjoin(RelOptInfo *hashrel);
|
|
||||||
static List *hash_inner_and_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
|
static List *hash_inner_and_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
|
||||||
List *hashinfo_list);
|
List *hashinfo_list);
|
||||||
|
|
||||||
@ -490,27 +489,6 @@ match_unsorted_inner(RelOptInfo *joinrel,
|
|||||||
return mp_list;
|
return mp_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
EnoughMemoryForHashjoin(RelOptInfo *hashrel)
|
|
||||||
{
|
|
||||||
int ntuples;
|
|
||||||
int tupsize;
|
|
||||||
int pages;
|
|
||||||
|
|
||||||
ntuples = hashrel->size;
|
|
||||||
if (ntuples == 0)
|
|
||||||
ntuples = 1000;
|
|
||||||
tupsize = hashrel->width + sizeof(HeapTupleData);
|
|
||||||
pages = page_size(ntuples, tupsize);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* if amount of buffer space below hashjoin threshold, return false
|
|
||||||
*/
|
|
||||||
if (ceil(sqrt((double) pages)) > NBuffers)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hash_inner_and_outer-- XXX HASH
|
* hash_inner_and_outer-- XXX HASH
|
||||||
* Create hashjoin join paths by explicitly hashing both the outer and
|
* Create hashjoin join paths by explicitly hashing both the outer and
|
||||||
@ -530,17 +508,17 @@ hash_inner_and_outer(RelOptInfo *joinrel,
|
|||||||
RelOptInfo *innerrel,
|
RelOptInfo *innerrel,
|
||||||
List *hashinfo_list)
|
List *hashinfo_list)
|
||||||
{
|
{
|
||||||
HashInfo *xhashinfo = (HashInfo *) NULL;
|
|
||||||
List *hjoin_list = NIL;
|
List *hjoin_list = NIL;
|
||||||
HashPath *temp_node = (HashPath *) NULL;
|
List *i;
|
||||||
List *i = NIL;
|
|
||||||
List *outerkeys = NIL;
|
|
||||||
List *innerkeys = NIL;
|
|
||||||
List *hash_pathkeys = NIL;
|
|
||||||
|
|
||||||
foreach(i, hashinfo_list)
|
foreach(i, hashinfo_list)
|
||||||
{
|
{
|
||||||
xhashinfo = (HashInfo *) lfirst(i);
|
HashInfo *xhashinfo = (HashInfo *) lfirst(i);
|
||||||
|
List *outerkeys;
|
||||||
|
List *innerkeys;
|
||||||
|
List *hash_pathkeys;
|
||||||
|
HashPath *temp_node;
|
||||||
|
|
||||||
outerkeys = make_pathkeys_from_joinkeys(
|
outerkeys = make_pathkeys_from_joinkeys(
|
||||||
((JoinMethod *) xhashinfo)->jmkeys,
|
((JoinMethod *) xhashinfo)->jmkeys,
|
||||||
outerrel->targetlist,
|
outerrel->targetlist,
|
||||||
@ -549,26 +527,31 @@ hash_inner_and_outer(RelOptInfo *joinrel,
|
|||||||
((JoinMethod *) xhashinfo)->jmkeys,
|
((JoinMethod *) xhashinfo)->jmkeys,
|
||||||
innerrel->targetlist,
|
innerrel->targetlist,
|
||||||
INNER);
|
INNER);
|
||||||
|
/* We cannot assume that the output of the hashjoin appears in any
|
||||||
|
* particular order, so it should have NIL pathkeys.
|
||||||
|
*/
|
||||||
|
#ifdef NOT_USED
|
||||||
hash_pathkeys = new_join_pathkeys(outerkeys,
|
hash_pathkeys = new_join_pathkeys(outerkeys,
|
||||||
joinrel->targetlist,
|
joinrel->targetlist,
|
||||||
((JoinMethod *) xhashinfo)->clauses);
|
((JoinMethod *) xhashinfo)->clauses);
|
||||||
|
#else
|
||||||
|
hash_pathkeys = NIL;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (EnoughMemoryForHashjoin(innerrel))
|
temp_node = create_hashjoin_path(joinrel,
|
||||||
{
|
outerrel->size,
|
||||||
temp_node = create_hashjoin_path(joinrel,
|
innerrel->size,
|
||||||
outerrel->size,
|
outerrel->width,
|
||||||
innerrel->size,
|
innerrel->width,
|
||||||
outerrel->width,
|
(Path *) outerrel->cheapestpath,
|
||||||
innerrel->width,
|
(Path *) innerrel->cheapestpath,
|
||||||
(Path *) outerrel->cheapestpath,
|
hash_pathkeys,
|
||||||
(Path *) innerrel->cheapestpath,
|
xhashinfo->hashop,
|
||||||
hash_pathkeys,
|
((JoinMethod *) xhashinfo)->clauses,
|
||||||
xhashinfo->hashop,
|
outerkeys,
|
||||||
((JoinMethod *) xhashinfo)->clauses,
|
innerkeys);
|
||||||
outerkeys,
|
hjoin_list = lappend(hjoin_list, temp_node);
|
||||||
innerkeys);
|
|
||||||
hjoin_list = lappend(hjoin_list, temp_node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hjoin_list;
|
return hjoin_list;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user