Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Oracle, what is the difference between a hash join and a sort-merge join?

Tags:

join

oracle

In Oracle, I can use the hints USE_HASH or USE_MERGE to instruct the optimizer to do a hash join or a sort-merge join. How are those types of joins different and when/why should I use one or the other?

like image 928
Matthew Avatar asked Dec 28 '22 05:12

Matthew


1 Answers

Jonathan Lewis posted a really good explanation of how hash joins and merge joins work:

  • Hash Joins - http://jonathanlewis.wordpress.com/2010/08/10/joins-hj/
  • Merge Joins - http://jonathanlewis.wordpress.com/2010/08/15/joins-mj/

and for good measure...

  • Nested Loop Joins - http://jonathanlewis.wordpress.com/2010/08/09/joins-nlj/
like image 196
Craig Avatar answered Jan 13 '23 14:01

Craig