hive性能问题
最近通过hadoop+hbase+hive分析日志
有两张表:
f 表 和 r 表
表结构如下:
f 表(1000万条记录): r 表(300万条记录):
ip -> ip ip -〉ip
n -> 用户名
d -> 目标ip tag -> 上下线标示(1-下线;0-上线)
t -> 时间 t -> 时间(用户的上下线时间)
业务逻辑:根据目标IP和时间段查询用户名,
我的sql文如下:
select f.sip, f.sp, f.tip, f.tp, f.dip, f.dp, f.u, r1.n, f.d from (select r1.ip, r1.n from rd r1 join rd r2 on (r1.ip = r2.ip and r1.t <= '1398148807000' and r1.tag = '0' and r2.t >= '1398148623000' and r2.tag = '1') group by r1.ip, r1.n) r1 join ft f on (f.sip = r1.ip and f.d >= '1398148623000' and f.d <= '1398148807000')
(思路:先根据时间段查询 r 表,查出这段时间的在线IP和用户名,再查询 f 表,根据之前的用户名和ip列表查询过滤出访问了目标IP的用户列表)
结果能查询出来,但是要花费近半小时的时间,哪位大侠能否指导一下如何优化?