如下:
有一张表user_action_log(id,user,action_time,action_desc),数据量有点大。
现在要查询某个月用户的记录,展示如下:(用户,时间,第一次操作时间)
user,action_time,first_time,如何比较高效的查询呢?
我的做法如下,但是太慢了:
select a.*,(select min(b.action_time) from user_action_log b where a.user=b.user and b.action_time!=a.action_time) as first_time from user_action_log a where substr(action_time,0,6)='201507'
oracle大表查询优化问题
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
叶之秋 2017-06-27 02:25关注select a.*, min(b.action_time) as first_time
from user_action_log a, user_action_log b
where substr(action_time, 0, 6) = '201507'
and a.user = b.user
and b.action_time != a.action_time解决 无用评论 打赏 举报