立即学习:https://edu.csdn.net/course/play/8005/164135?utm_source=blogtoedu
左半连接left semi-join, select 和 where 子句不能引用到右边表字段。
左表的记录在右表中一旦找到对应的记录,右侧表立即停止,效率比内连接效率高
hive不支持右半连接操作
select c.id,c.name from customers c left semi join orders o on c.id = o.cidmap端连接,通过mapper的手段,将一张小表完全载入内存中。
Hive中的 Map Join 即map side join
工作原理是在Map端把小表加载到内存中,然后读取大表,和内存中的小表完成连接操作。MapJoin使用了分布式缓存技术。
Map Join的优点:
不消耗集群的reduce资源。减少了reduce操作,加快了程序执行。降低网络负载。Map Join的缺点:
占用内存(所以加载到内存中的表不能过大,因为每个计算节点都会加载一次)。生成较多的小文件。 select /*+mapjoin(c)*/ c.id,c.name,o.orderno from customers c join orders o; select /*+mapjoin(o)*/ c.id,c.name,o.orderno from customers c join orders o; set hive.mapjoin.smalltable.filesize=25000000; --设置小表阀值注意: set 命令只对当前会话有用,要持久化需要修改 hive-site.xml
