1、只取需要的列,尽量减少用select *;
2、如果有,尽量使用分区字段过滤;
1 | --查看table分区字段 |
3、join时,将条件写入子查询或写在on中;
1 | >select a.id from table_a a left outer join table_b b on a.id = b.id where b.day='2017-12-13'; |
4、当数据量较大时,用group by代替count(distinct);
1 | >select day,count(distinct id) as uv from table_a group by day; |
5、MapJoin
1 | MapJoin通常用于一个小表和一个大表进行join的场景。0.7版本之后,默认自动会转换MapJoin。 |
6、并行job
在不存在依赖关系的情况下,是可以并行执行job的,比如以下情况。
1 | select * from ( |