select * from(
select *
from T_NB_COPY t
order by create_time desc
) b where rownum <= 5
去重及时间段获取
select distinct t.device_id from T_RECEIVE_LOG t where t.receive_time <= to_date('2018-02-28 00:00:00','yyyy-mm-dd hh24:mi:ss') and t.receive_time >= to_date('2018-02-27 00:00:00','yyyy-mm-dd hh24:mi:ss')
使用倒序索引提升ORDER BY DESC性能使用倒序索引(INDEX DESC),可以大幅提升带有order by desc子句的SQL语句性能。
举例
1、表名:test_t,有一字段名为object_id
2、总数据量:580000行,segment_size:72MB
3、Where条件(Owner=’SYS’ and Object_id>50000)的行数:32472行
4、SQL语句:select * from test_t where owner='SYS' and object_id >50000 order by object_id desc
5、希望借助倒序索引,提升order by object_id desc的性能
希望能帮到你。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)