现在有一个表,表数据上百万,需要查询某一天的新增用户数统计 。目前写的是,根据某天的时间查然后在查询之前的,相互比对今天的时间用户不在之前用户里面,用到了 not in 查询结果慢的不行,跪求高手有什么优化方案!
解决方案
20
select ca_user_id, max(order_time),min(order_time) from order_info_ref group by ca_user_id
having max(order_time) between “2016-03-02 00:01:00” and “2016-03-02 23:59:59”
and min(order_time) between “2016-03-02 00:01:00” and “2016-03-02 23:59:59”
having max(order_time) between “2016-03-02 00:01:00” and “2016-03-02 23:59:59”
and min(order_time) between “2016-03-02 00:01:00” and “2016-03-02 23:59:59”