select * from student where student.id in (1,3,5)
外表和內表hash連接,hash(id),到內表get(hash(1))
--------------------------------id
1 hash(1)--------------join 1
2
3 hash(3)--------------join 3
4
5 hash(5)--------------join 5
select * from student where student exsits ()
對外表做loop循環,每次循環再對內表循環查詢
表連接分爲三種,
hash join,對連接字段hash,遍歷匹配連接
nested loop,嵌套查詢,先查外表,再查子表內表
sort merge join,用在沒有索引,數據已經排序好的情況
表間連接,本質是對錶間每行數據遍歷匹配,連之前都要做好準備,要麼用索引,要麼排序表,最次用hash算法
不存在什麼都不用的純遍歷查詢
優先用排序表sort merge join----->都有索引nested loop----->hash算法