- 论坛徽章:
- 1
|
本人小白,请教个sql语句优化的问题
SQL:
- select platform, user_name, min(user_ip) ip, min(login_time) time from ( select * from login_201510 union all select * from login_201511 union all select * from login_201512 union all select * from login_201601 union all select * from login_201602 union all select * from login_201603 union all select * from login_201604 union all select * from login_201605 union all select * from login_201606 ) t where user_name is not null group by platform, user_name having min(login_time) >= unix_timestamp('2011-01-01') + -3600 and min(login_time) < unix_timestamp('2016-07-01') + -3600 limit 100;
复制代码
其中 UNION ALL 这块
- select * from login_201510 union all select * from login_201511 union all select * from login_201512 union all select * from login_201601 union all select * from login_201602 union all select * from login_201603 union all select * from login_201604 union all select * from login_201605 union all select * from login_201606
复制代码 执行约26秒,有960W左右记录数,但是整体执行会error~~ ENGINE=BRIGHTHOUSE ,有人能点拨一下吗?谢谢! |
|