Skip to content

Instantly share code, notes, and snippets.

@TakahashiIkki
Last active November 25, 2019 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TakahashiIkki/57f9c9d888e00ee858b49e81338d2a66 to your computer and use it in GitHub Desktop.
Save TakahashiIkki/57f9c9d888e00ee858b49e81338d2a66 to your computer and use it in GitHub Desktop.
PostgreSQL's Join.md

JOINのアルゴリズム

MySQLとPostgreSQLで採用されている 結合処理のアルゴリズムに違いがある異なる。

MySQLでは Nested Loop JOINのみだけど、
PostgreSQLでは
Nested Loop JOIN、Hash JOIN、Merge JOINの
三種類がサポートされている。


結合ノードの違い

Nested Loop Join

  • 駆動表(JOIN元)を1行毎に内部表(JOIN先)の全レコードと付き合わせて該当のものを結合していく。

nlj


結合ノードの違い

Hash Join

  • 内部表の結合キーのハッシュリストを作成して、その後、駆動表と結合を行う。

hash join


結合ノードの違い

Merge Join

  • 駆動表と内部表を結合キーで、 ソートした後で 順番に付き合わせて結合していく。

merge join

@TakahashiIkki
Copy link
Author

コメント
key1_edit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment