SELECT NOR.calling_nbr,NOR.called_nbr,NOR.start_time,FEE.Charge,Nor.event_type_id,NOR.serv_id, NOR.EVENT_TYPE_ID FROM EVENT_CDR_14_351009 NOR,EVENT_CDR_FEE_14_351009 FEE WHERE NOR.SERV_ID IN ( 935000887304 , 935000887302 , 935000779966 , 935000525640 , 935000779952 , 935000779950 , 935000779954 , 935000779945 , 935000782178 , 935000779938 , 935000903710 , 935000779728 , 935021851818 , 935000752871 , 935000779724 , 935000878698 , 935006191678 , 935000878697 , 935000752873 , 935000780864 , 935000780867 , 935000780860 , 935000779928 , 935000779718 , 935000752360 , 935000752361 , 935000780869 , 935000780878 , 935000780877 , 935000780876 , 935000780875 , 935000780874 , 935000780873 , 935000779913 , 935000780872 , 935000780871 , 935000780870 , 935000779919 , 935000853091 , 935000752350 , 935022426576 , 935000780835 , 935000780838 , 935000779700 , 935000853093 , 935000780841 , 935000780842 , 935000418963 , 935000752359 , 935000780844 , 935000752358 , 935000752357 , 935000752356 , 935000752355 , 935000781656 , 935000752354 , 935000779904 , 935000781657 , 935000752353 , 935000781658 , 935000752352 , 935000769810 , 935021401719 , 935000780849 , 935000780846 , 935000780847 , 935000780851 , 935000780850 , 935000878682 , 935000752349 , 935000878684 , 935000781660 , 935000781663 , 935000780822 , 935000780823 , 935000780820 , 935000780819 , 935000780818 , 935000779763 , 935000769402 , 935000780817 , 935000779769 , 935000780816 , 935000780815 , 935000780813 , 935000769409 , 935006262278 , 935000780831 , 935000780833 , 935000779752 , 935000780825 , 935000779756 , 935000780824 , 935000779758 , 935000780827 , 935000780800 , 935000883147 , 935000779747 , 935000779745 , 935000779743 , 935000779744 , 935021716529 , 935021606319 , 935021397333 , 935000421772 , 935000779749 , 935000421773 , 935000780810 , 935000780803 , 935000780802 , 935000780807 , 935000780809 , 935000779739 , 935000327999 , 935000327998 , 935000837446 , 935000837441 , 935000525606 , 935000525600 , 935000779992 , 935021085267 , 935000779784 , 935000837435 , 935000779981 , 935000779789 , 935000779787 , 935000779770 , 935000779773 , 935000328001 , 935000328000 , 935000328002 , 935022361179 , 935000381687 , 935000762251 , 935000762253 , 935000762254 , 935000762255 , 935000762257 , 935000615941 , 935000762052 , 935000762053 , 935000762055 , 935000762250 , 935000762248 , 935000762249 , 935000421575 , 935000421576 , 935000421577 , 935000421578 , 935000421579 , 935000762246 , 935000762244 , 935000579149 , 935000762048 , 935000421588 , 935000421584 , 935000421581 , 935000421582 , 935000421589 , 935000421580 , 935000896206 , 935000769451 , 935000769452 , 935023588147 , 935000421596 , 935000421597 , 935000421599 , 935000421592 , 935000421593 , 935000421594 , 935000341114 , 935000421591 , 935000796533 , 935000769437 , 935000769434 , 935000769435 , 935000769433 , 935000769432 , 935000769430 , 935000786535 , 935000819133 , 935000769445 , 935000769446 , 935000769447 , 935000769442 , 935000519157 , 935000769441 , 935000769444 , 935000769440 , 935000615929 , 935000769418 , 935024213793 , 935000781008 , 935000762269 , 935000781007 , 935000762268 , 935000762266 , 935000762264 , 935000615934 , 935000781006 , 935000762262 , 935000902183 , 935000769423 , 935000781002 , 935000769426 , 935000769420 , 935000842154 , 935000762260 , 935000784229 , 935000784226 , 935000630570 , 935000784223 , 935000784220 , 935000674599 , 935000454645 , 935000781013 , 935000771702 , 935000781014 , 935000781015 , 935000781017 , 935000781018 , 935000771700 , 935000784230 , 935000781027 , 935000781028 , 935000781026 , 935000369903 , 935000369906 , 935000369907 , 935000369904 , 935000781032 , 935000781033 , 935000781035 , 935000818141 , 935020749324 , 935020802716 , 935000781036 , 935000781037 , 935000781038 , 935000771707 , 935000784216 , 935000784217 , 935000771705 , 935000784218 , 935000771709 , 935000781046 , 935000781044 , 935000781042 , 935000781047 , 935000771712 , 935000781048 , 935000762096 , 935000762094 , 935020902798 , 935000762089 , 935000704328 , 935022520003 , 935020573983 , 935000781182 , 935000782242 , 935000781183 , 935000781184 , 935000782244 , 935000781186 , 935000781187 , 935000781189 , 935000421808 , 935000779827 , 935000779826 , 935000781180 , 935000781173 , 935000781174 , 935000782254 , 935000781171 , 935000781172 , 935000782252 , 935000781177 , 935000781178 , 935000782250 , 935000781179 , 935000795552 , 935000769392 , 935000779810 , 935000779818 , 935000769393 , 935000795549 , 935000782223 , 935000782225 , 935005980204 , 935000795541 , 935000782226 , 935000359860 , 935000795539 , 935000781199 , 935000782234 , 935000781195 , 935000781193 , 935000782231 , 935000781194 , 935000795530 , 935000359859 , 935000781192 , 935000781191 , 935000781190 , 935000780956 , 935000781146 , 935000780957 , 935000781149 , 935000780958 , 935000780959 , 935000781148 , 935000781142 , 935000781144 , 935000544010 , 935000780960 , 935000780966 , 935000780969 , 935000780967 , 935000780968 , 935000781135 , 935000780777 , 935000781130 , 935000763029 , 935000781133 , 935000781132 , 935000781131 , 935000780971 , 935000780970 , 935000780977 , 935000780975 , 935000780974 , 935000780787 , 935000537134 , 935000780789 , 935000537133 , 935000781169 , 935000780978 , 935000779602 , 935000780784 , 935000780979 , 935000780785 , 935000781165 , 935000781164 , 935000780781 , 935000781163 , 935000781162 , 935000780980 , 935000779809 , 935000780986 , 935000780985 , 935000780988 , 935000780982 , 935000779800 , 935000537139 , 935000537138 , 935000780984 , 935000537137 , 935000537136 , 935000319749 , 935000537145 , 935000780799 , 935000537146 , 935000780797 , 935000537140 , 935000780794 , 935000780795 , 935000781157 , 935000537142 , 935000780792 , 935000781156 , 935000780790 , 935000781154 , 935000781152 , 935000781151 , 935000781150 , 935000780991 , 935000780990 , 935000780998 , 935000780997 , 935000780994 , 935000780992 , 935000780922 , 935000780920 , 935000537192 , 935000769508 , 935000769507 , 935000780913 , 935000780912 , 935000779625 , 935000780919 , 935000781108 , 935000780918 , 935000781109 , 935000780917 , 935000769500 , 935000780916 , 935000779899 , 935000357499 , 935000357498 , 935000780930 , 935000357497 , 935000780931 , 935000780932 , 935000357495 , 935000780933 , 935000372808 , 935000780924 , 935000780923 , 935000780926 , 935000780925 , 935000780928 , 935000779610 , 935000780927 , 935000780929 , 935000763030 , 935000763031 , 935000780941 , 935000780942 , 935000769521 , 935023174663 , 935000781122 , 935000781123 , 935000781120 , 935000781121 , 935000763039 , 935000769525 , 935000763038 , 935000780939 , 935000769523 , 935000780938 , 935000780937 , 935000781126 , 935000780936 , 935000781127 , 935000781124 , 935000780934 , 935000781125 , 935000763040 , 935000780954 , 935000763041 , 935000763042 , 935000780950 , 935000780951 , 935000769510 , 935021716438 , 935000781110 , 935000780949 , 935000779632 , 935000769511 , 935000763047 , 935025722191 , 935025722192 , 935000763049 , 935000769513 , 935025722193 , 935000780946 , 935000781113 , 935000763044 , 935000769515 , 935000780945 , 935000781114 , 935000763043 , 935000780948 , 935000769518 , 935000763045 , 935000544216 , 935006262396 , 935000413896 , 935000779883 , 935000769763 , 935000780911 , 935000779875 , 935000780910 , 935000779878 , 935000779879 , 935000780906 , 935000780907 , 935000780908 , 935000780909 , 935000891261 , 935000837465 , 935000593280 , 935000762900 , 935000762104 , 935000771692 , 935000771695 , 935006191728 , 935000357513 , 935000357518 , 935000357514 , 935000891257 , 935005631294 , 935020749683 , 935000878706 , 935000878701 , 935000878703 , 935000421622 , 935000421623 , 935000421624 , 935000421625 ) AND NOR.event_inst_id = FEE.event_inst_id AND NOR.event_type_id in (21010,68033,22030,80050,22010,80110,22000,20010,21040,20050,21060,21030,20030,80001,22040,68045,67003,22020,80049,80048,20020,21020,21050,20060,20040) ORDER BY NOR.serv_id,NOR.start_time上面这个sql执行起来比较慢。NOR.serv_id、NOR.event_inst_id、FEE.event_inst_id、NOR.event_type_id上面都有索引。如果sql不能优化的话,这么多serv_in in (...)该怎么用程序去优化呢?(如果需要多次执行数据库操作)
谢谢了。
谢谢了。
把NOR.event_inst_id = FEE.event_inst_id 放在第一个会好点么?不是说oracle都是从右向左的解析的么?我试试看先。
2、in后面的数据是程序算出来的,不是从其他表得到的。另外也应该不可能重新新建一张表吧,这个是程序算出来的,是变化的呀。
我测试的就是如果 in条件中的数据大于一千条就报错的
1、超过1K条的时候的确会报错。这个我程序有控制的哦。呵呵。
2、楼上各位,这个怎么改为exist,或者用临时表呢?..求..
2 (
3 A NUMBER(2)
4 )
5 on commit delete rows;
Table created
SQL> set serveroutput on
SQL>
SQL> declare
2 v_num number(10);
3 begin
4 insert into T_TMP_T1(A)
5 select rownum from dual connect by rownum<=10;
6 select count(*) into v_num from dept t where exists (select 1 from t_tmp_t1 b where t.deptno=b.a);
7 dbms_output.put_line('the number of dept which deptno between 1 and 100:'||v_num);
8 end;
9 /
the number of dept which deptno between 1 and 100:1
PL/SQL procedure successfully completed
SQL>
顺便深入了解一下,用exist会比in要快么?具体的区别是啥..google过了,可能还没得到精髓..哈。谢谢了。
http://topic.csdn.net/t/20040401/11/2912186.html