sql如下:
SELECT 
  BEGINTIME, 
  ENDTIME, 
  GRANULARITY, 
  NEDN, 
  MODN, 
  ' ' MONAME, 
  1 ISBELIEVE, 
  sysCallAttempt c0, 
  sysCallSeizure c1, 
  sysCallComplete c2, 
  sysCallAnswer c3, 
  durCallingSeizure c4, 
  durCalledSeizure c5, 
  durCallComplete c6, 
  durCallAnswer c7, 
  failUserRel c8  
FROM 
  cnwcnmscs40719 
WHERE 
  (BEGINTIME>=TO_DATE('2008-1-1 0:0:0','yyyy-mm-dd hh24:mi:ss') 
  AND BEGINTIME<TO_DATE('2008-1-5 0:0:0','yyyy-mm-dd hh24:mi:ss') ) 
  AND  
    (
      (NEDN='cn.wcn.cs.mscs=1000' AND MODN='cn.wcn.cs.mscs=1000,cn.wcn.cs.50101=1') 
      OR (NEDN='cn.wcn.cs.mscs=1000' AND MODN='cn.wcn.cs.mscs=1000,cn.wcn.cs.50101=10') 
      OR (NEDN='cn.wcn.cs.mscs=1000' AND MODN='cn.wcn.cs.mscs=1000,cn.wcn.cs.50101=100') 
      OR (NEDN='cn.wcn.cs.mscs=1000' AND MODN='cn.wcn.cs.mscs=1000,cn.wcn.cs.50101=101') 
      OR (NEDN='cn.wcn.cs.mscs=1000' AND MODN='cn.wcn.cs.mscs=1000,cn.wcn.cs.50101=102') 
      OR (NEDN='cn.wcn.cs.mscs=1000' AND MODN='cn.wcn.cs.mscs=1000,cn.wcn.cs.50101=103') 
      OR (NEDN='cn.wcn.cs.mscs=1000' AND MODN='cn.wcn.cs.mscs=1000,cn.wcn.cs.50101=104')
      OR (NEDN='cn.wcn.cs.mscs=1000' AND MODN='cn.wcn.cs.mscs=1000,cn.wcn.cs.50101=105') 
      OR (NEDN='cn.wcn.cs.mscs=1000' AND MODN='cn.wcn.cs.mscs=1000,cn.wcn.cs.50101=106') )
ORDER BY BEGINTIME, GRANULARITY, NEDN, MODN数据环境如下:
表中数据量为500w左右,时间跨度也比较大,每个时间点的nedn少,modn很多,这里的ne mo过滤只写了一部分,多的情况可能上百个,表通过begintime做了分区。
出现的问题:
表中建立了索引X(begintime)和索引Y(nedn,modn)
通过查询计划看出,这个sql用了索引Y,而没有使用索引X,不知道是什么原因
我的想法是应该使用到索引X,Y

解决方案 »

  1.   

    我已经在时间字段加上了索引,但是在查看查询计划的时候,没有用上
    是否oracle的一句sql只能用一个索引?
      

  2.   

    组合索引:
    create index idx_empnoanddepno on emp(empno,deptno);
    如何使用:
    select * from emp where empno=7899 and deptno=10;
      

  3.   

    当然不是只能有一个索引了。估计是你分区的问题。BEGINTIME你创建的是全局索引还是分区索引?
      

  4.   

    我对oracle不怎么熟悉
    我创建索引时用的sql是 create  index 
    怎么判断begintime是全局索引还是分区索引?