postgresql 中join的选项
Nested Loops(O(n2))
1
2
3
4
5
6for x in table1:
for y in table2:
if x.field == y.field
issue row
else
keep doingHash joins
1
2
3Hash join
Sequentialscan table 1
Sequentialscan table 2Merge joins(O(n * log(n)))
1
2
3
4
5
6
7
8
9Merge join
Sort table 1
Sequetial scan table 1
Sort table 2
Sequetial scan table 2
---
Merge join
Index scan table 1
Index scan table 2