一个奇怪的sql查询问题

zlwork_84 2014-12-01 11:07:06
两个sql语句内容完全一样。 只是查询时间不一样。一个3秒就ok。 一个等了1分钟报错。
select count(*) from (
select d.outid,d.customerunitcode from rec_electtron_consume e inner join base_customers d on e.cardno=d.cardno and e.customerunitcode=d.customerunitcode where
e.buslineid=9999 and e.cardtype=34 and e.customerunitcode =
'08600000001' and e.uploaddate between to_date('2014-11-26','yyyy-mm-dd') and
to_date('2014-11-26','yyyy-mm-dd')+1 and cstaccfc<= 6175500) x inner join base_emp emp on x.outid=emp.outid and x.customerunitcode = emp.customerunitcode

11月26日的要等1分钟


select count(*) from (
select d.outid,d.customerunitcode from rec_electtron_consume e inner join base_customers d on e.cardno=d.cardno and e.customerunitcode=d.customerunitcode where
e.buslineid=9999 and e.cardtype=34 and e.customerunitcode =
'08600000001' and e.uploaddate between to_date('2014-11-25','yyyy-mm-dd') and
to_date('2014-11-25','yyyy-mm-dd')+1 and cstaccfc<= 6175500) x inner join base_emp emp on x.outid=emp.outid and x.customerunitcode = emp.customerunitcode
11月25日的3秒钟就ok了。

rec_electtron_consume 有6百万数据。
base_customers 有10万数据。
base_emp 有1万数据。

实际需要的数据有5000条左右。

但是就因为时间不一样, 差别很大。
本来想着是 rec_electtron_consume 数据有问题。 我 把rec_electtron_consume的buslineid=9999 的独立查出来放到另外一个表里。 有100万数据。 然后再来关联。 反而25号的也慢了。 再往前查 ,22号到25号的也慢。 21号以前的不慢。

问题很奇怪。 不知道往哪里查了? 请各位大神帮帮忙,给点建议。 100分散了。
...全文
540 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ABC19890124 2015-03-15
  • 打赏
  • 举报
回复
你是怎么解决的,请问是什么问题?
zlwork_84 2015-03-15
  • 打赏
  • 举报
回复
已经用其他方法解决了。 结贴
qq_26588905 2015-03-15
  • 打赏
  • 举报
回复
请问,楼主怎么解决的呢?
whhwch1986 2014-12-08
  • 打赏
  • 举报
回复
查询的时候快可能是因为数据已经加载到内存了,具体的应该通过执行计划来具体分析
bw555 2014-12-01
  • 打赏
  • 举报
回复
报的什么错?
小灰狼W 2014-12-01
  • 打赏
  • 举报
回复
提供: 错误信息; 两个语句分别的执行计划

3,490

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧