刚碰到一个问题
两个句子分别执行都很快
select sum(money) as paymoney, date
          from [email protected] 
           and fee.date between date '2009-05-24' and date
         '2009-05-24'
         group by dateselect sum(money) as money, date
          from temp
         where date between date '2009-05-24' and date '2009-05-24'
         group by date
基本都在5秒以内
但是如下面的写法就超慢
难道这样的查询是将所有数据传送到一端再做计算
不是只计算结果吗
select date
  from (select sum(money) as paymoney, date
          from [email protected] 
           and fee.date between date '2009-05-24' and date
         '2009-05-24'
         group by date
        minus
        select sum(money) as money, date
          from temp
         where date between date '2009-05-24' and date '2009-05-24'
         group by date)
 order by date大牛出下手,有其他解决方法没有啊
数据量在20w条左右

解决方案 »

  1.   

    我昨天在oracle中插入oracle数据到sqlserver不成功。。
    你这个查询能直接minus?难道异构数据库不能直接相互操作?
    偶也不懂,帮你up了。
      

  2.   

    我是两端都是oracle
    只是远端的oracle我们只有查询权限
    所以只能在本地想办法
      

  3.   

    这个原因不是很清楚。不过你可以考虑把远端数据拿过来
    create table test1 as 
    select sum(money) as paymoney, date 
              from [email protected] 
              and fee.date between date '2009-05-24' and date 
            '2009-05-24' 
            group by date ;create table test2 as 
    select sum(money) as money, date 
              from temp 
            where date between date '2009-05-24' and date '2009-05-24' 
            group by date ;然后比较test1和test2……另:有点不明白的地方,fee.date是什么?
      

  4.   

    改用with as 语法即可,具体原因你自己慢慢学习吧
      

  5.   


    可以使用视图吧,估计是因为20w 数据的minus太慢了,跟远程关系不大吧
    试试a.date=b.date(+) and b.date is null
      

  6.   


    把minus用not exist代替试试