慢sql
查询某个时间点之前有交易的用户
3万用户,4万多条订单记录,查询出来数据3046条,耗时600多秒,
SELECT username FROM `user` WHERE id in((SELECT user_id FROM shop_order WHERE created_at>1523631128))
优化
耗时0.055秒 查询结果同上
SELECT b.username FROM (SELECT DISTINCT user_id FROM shop_order WHERE created_at>1523631128) a INNER JOIN `user` b ON b.id=a.user_id