日期用between and超慢,怎么办?

[复制链接]
查看11 | 回复9 | 2006-5-30 08:00:00 | 显示全部楼层 |阅读模式
where displ_date between to_date('2006-5-30 8:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2006-5-30 17:30:00','yyyy-mm-dd hh24:mi:ss')
还有一些其他条件,这样查询反应很慢啊,请问有没有什么好的办法
回复

使用道具 举报

千问 | 2006-5-30 08:00:00 | 显示全部楼层
加索引了吗?
回复

使用道具 举报

千问 | 2006-5-30 08:00:00 | 显示全部楼层
用LIKE ‘年月%’
回复

使用道具 举报

千问 | 2006-5-30 08:00:00 | 显示全部楼层
最初由 cc5258 发布
[B]where displ_date between to_date('2006-5-30 8:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2006-5-30 17:30:00','yyyy-mm-dd hh24:mi:ss')
还有一些其他条件,这样查询反应很慢啊,请问有没有什么好的办法 [/B]

最好贴出全部sql 和相关信息及计划等


回复

使用道具 举报

千问 | 2006-5-30 08:00:00 | 显示全部楼层
数据库不清楚,,displ_date是date型,我要查询 '2006-5-30 8:00:00', 到'2006-5-30 17:30:00', 的数据是不是只能用between and 或者了?
回复

使用道具 举报

千问 | 2006-5-30 08:00:00 | 显示全部楼层
select * from orders a
where a.order_type_id = 3 and a.displ_date between to_date('2006-5-30 8:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2006-5-30 17:30:00','yyyy-mm-dd hh24:mi:ss')
当然,还join了其他一些表
回复

使用道具 举报

千问 | 2006-5-30 08:00:00 | 显示全部楼层
a.displ_date > to_date('2006-5-30 8:00:00','yyyy-mm-dd hh24:mi:ss') 会不会快点
有没有其他更好的写法了
回复

使用道具 举报

千问 | 2006-5-30 08:00:00 | 显示全部楼层
where后面条件的顺序都可能会影响你查询所需要的时间
最好把表结构和整个SQL贴出来看看
回复

使用道具 举报

千问 | 2006-5-30 08:00:00 | 显示全部楼层
select * from inte_order io
join job_spec js on js.job_spec_id = io.job_spec_id
join crm_for_sa cfs on cfs.order_id =io.order_id
where cfs.area_id =75 and cfs.sts ='N'
and io.job_spec_id = '000030'
and io.displ_date between to_date('2006-5-30 8:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2006-5-30 17:30:00','yyyy-mm-dd hh24:mi:ss')
回复

使用道具 举报

千问 | 2006-5-30 08:00:00 | 显示全部楼层
select * from inte_order io
join job_spec js on js.job_spec_id = io.job_spec_id
join crm_for_sa cfs on cfs.order_id =io.order_id
where cfs.area_id =75 and cfs.sts ='N'
and io.job_spec_id in ( '000030','000040')
and io.displ_date between to_date('2006-5-30 8:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2006-5-30 17:30:00','yyyy-mm-dd hh24:mi:ss')
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行