Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc2f0d56

Browse files
committed
Now that hashjoin is reliable for large joins (knock on wood),
remove optimizer's arbitrary limit on how large a join it will use hashingfor. (The limit was too large to prevent the problems we'd been seeing,anyway...)
1 parent353d36f commitc2f0d56

File tree

1 file changed

+30
-47
lines changed

1 file changed

+30
-47
lines changed

‎src/backend/optimizer/path/joinpath.c

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.35 1999/05/16 19:45:37 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.36 1999/05/18 21:36:10 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -37,7 +37,6 @@ static List *match_unsorted_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, Rel
3737
List*mergeinfo_list);
3838
staticList*match_unsorted_inner(RelOptInfo*joinrel,RelOptInfo*outerrel,RelOptInfo*innerrel,
3939
List*innerpath_list,List*mergeinfo_list);
40-
staticboolEnoughMemoryForHashjoin(RelOptInfo*hashrel);
4140
staticList*hash_inner_and_outer(RelOptInfo*joinrel,RelOptInfo*outerrel,RelOptInfo*innerrel,
4241
List*hashinfo_list);
4342

@@ -490,27 +489,6 @@ match_unsorted_inner(RelOptInfo *joinrel,
490489
returnmp_list;
491490
}
492491

493-
staticbool
494-
EnoughMemoryForHashjoin(RelOptInfo*hashrel)
495-
{
496-
intntuples;
497-
inttupsize;
498-
intpages;
499-
500-
ntuples=hashrel->size;
501-
if (ntuples==0)
502-
ntuples=1000;
503-
tupsize=hashrel->width+sizeof(HeapTupleData);
504-
pages=page_size(ntuples,tupsize);
505-
506-
/*
507-
* if amount of buffer space below hashjoin threshold, return false
508-
*/
509-
if (ceil(sqrt((double)pages))>NBuffers)
510-
return false;
511-
return true;
512-
}
513-
514492
/*
515493
* hash_inner_and_outer--XXX HASH
516494
* Create hashjoin join paths by explicitly hashing both the outer and
@@ -530,17 +508,17 @@ hash_inner_and_outer(RelOptInfo *joinrel,
530508
RelOptInfo*innerrel,
531509
List*hashinfo_list)
532510
{
533-
HashInfo*xhashinfo= (HashInfo*)NULL;
534511
List*hjoin_list=NIL;
535-
HashPath*temp_node= (HashPath*)NULL;
536-
List*i=NIL;
537-
List*outerkeys=NIL;
538-
List*innerkeys=NIL;
539-
List*hash_pathkeys=NIL;
512+
List*i;
540513

541514
foreach(i,hashinfo_list)
542515
{
543-
xhashinfo= (HashInfo*)lfirst(i);
516+
HashInfo*xhashinfo= (HashInfo*)lfirst(i);
517+
List*outerkeys;
518+
List*innerkeys;
519+
List*hash_pathkeys;
520+
HashPath*temp_node;
521+
544522
outerkeys=make_pathkeys_from_joinkeys(
545523
((JoinMethod*)xhashinfo)->jmkeys,
546524
outerrel->targetlist,
@@ -549,26 +527,31 @@ hash_inner_and_outer(RelOptInfo *joinrel,
549527
((JoinMethod*)xhashinfo)->jmkeys,
550528
innerrel->targetlist,
551529
INNER);
530+
/* We cannot assume that the output of the hashjoin appears in any
531+
* particular order, so it should have NIL pathkeys.
532+
*/
533+
#ifdefNOT_USED
552534
hash_pathkeys=new_join_pathkeys(outerkeys,
553535
joinrel->targetlist,
554536
((JoinMethod*)xhashinfo)->clauses);
555-
556-
if (EnoughMemoryForHashjoin(innerrel))
557-
{
558-
temp_node=create_hashjoin_path(joinrel,
559-
outerrel->size,
560-
innerrel->size,
561-
outerrel->width,
562-
innerrel->width,
563-
(Path*)outerrel->cheapestpath,
564-
(Path*)innerrel->cheapestpath,
565-
hash_pathkeys,
566-
xhashinfo->hashop,
567-
((JoinMethod*)xhashinfo)->clauses,
568-
outerkeys,
569-
innerkeys);
570-
hjoin_list=lappend(hjoin_list,temp_node);
571-
}
537+
#else
538+
hash_pathkeys=NIL;
539+
#endif
540+
541+
temp_node=create_hashjoin_path(joinrel,
542+
outerrel->size,
543+
innerrel->size,
544+
outerrel->width,
545+
innerrel->width,
546+
(Path*)outerrel->cheapestpath,
547+
(Path*)innerrel->cheapestpath,
548+
hash_pathkeys,
549+
xhashinfo->hashop,
550+
((JoinMethod*)xhashinfo)->clauses,
551+
outerkeys,
552+
innerkeys);
553+
hjoin_list=lappend(hjoin_list,temp_node);
572554
}
555+
573556
returnhjoin_list;
574557
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp