17,090
社区成员
发帖
与我相关
我的任务
分享
select a.curr_time, a.sms_num
from (select t.*,
row_number() over(partition by t.curr_time, t.sms_num order by t.curr_time, t.sms_num) rw
from (select t1.curr_time, t1.sms_num
from itf_sms t1, bomc.tfa_alarm_his t2
where t1.alarm_id = t2.s_fp_id
and t2.event_time between
to_date('2014-02-14 10:21:52', 'YYYY-MM-DD hh24:mi:ss') and
to_date('2014-02-17 10:21:57', 'YYYY-MM-DD hh24:mi:ss')
and t1.curr_time between
to_date('2014-02-14 10:21:52', 'YYYY-MM-DD hh24:mi:ss') and
to_date('2014-02-17 10:21:57', 'YYYY-MM-DD hh24:mi:ss')
union all
select t1.curr_time, t1.sms_num
from itf_sms_bak t1, bomc.tfa_alarm_his t2
where t1.alarm_id = t2.s_fp_id
and t2.event_time between
to_date('2014-02-14 10:21:52', 'YYYY-MM-DD hh24:mi:ss') and
to_date('2014-02-17 10:21:57', 'YYYY-MM-DD hh24:mi:ss')
and t1.curr_time between
to_date('2014-02-14 10:21:52', 'YYYY-MM-DD hh24:mi:ss') and
to_date('2014-02-17 10:21:57', 'YYYY-MM-DD hh24:mi:ss')) t) a
where a.rw = 1
order by a.curr_time desc
select *
from (select a,
b,
c,
row_number() over(partition by a, b, c order by a, b, c) rw
from tab)
where rw = 1
减少磁盘排序,增加内存排序,性能提高