tang_jian_dong 2020-04-30 20:13 采纳率: 50%
浏览 303
已结题

oracle 时间字段区间查询卡顿

这一条语句查询几十毫秒, 解释器看是走时间字段索引的。
select * from table1 where 1=1
and createtime
between to_date('2020-04-30 00:00:00','yyyy-MM-dd hh24:mi:ss')

and to_date('2020-04-30 23:59:59','yyyy-MM-dd hh24:mi:ss')

如下语句就是三天, 就会卡顿很久, 加上hint强制索引就很快。 不加hint就很慢。 只有04-27 会卡, 04-26, 04-28 就不卡

select * from table1 where 1=1
and createtime
between to_date('2020-04-27 00:00:00','yyyy-MM-dd hh24:mi:ss')

and to_date('2020-04-30 23:59:59','yyyy-MM-dd hh24:mi:ss')

如下 开始时间加一个小时又没问题。
或者开始时间为 2020-04-26等前几天的时间查询都没问题, 就是卡顿在 2020-04-27 00:00:00
这是为什么呢
select * from table1 where 1=1
and createtime
between to_date('2020-04-27 01:00:00','yyyy-MM-dd hh24:mi:ss')

and to_date('2020-04-30 23:59:59','yyyy-MM-dd hh24:mi:ss')

  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2020-04-30 23:43
    关注
    评论

报告相同问题?