比如一个查询 select  a.x ,b.y,c.z             
             from  a,b,c
            where ````````
条件里为b表新建了个索引,但是默认的索引不是这个新建的,怎么指定,
网上搜索了下,
写成SELECT /*+ index(索引名) */ a.x ,b.y,c.z             from  a,b,c
            where ````````
没有效果

解决方案 »

  1.   

    where b 这里的表达式是怎么写的,贴出来看看,是不是你在B上做了转换、?
    如果可以贴执行计划出来看看,是否走了全表扫描
      

  2.   

      select  
       /*+ index(MTL_MATERIAL_TRANSACTIONS_N26) */
       to_char(mmt.creation_date,'yyyymmdd') 日期,
               msi.segment1 物料编码,
               msi.description 物料描述,
              -sum(mtl.transaction_quantity) 数量,
              mtl.lot_number 批次,
                PV.SEGMENT1 供应商代码,
               pv.vendor_name 供应商名称
          from mtl_system_items_b          msi,
               po_vendors                  pv,
               mtl_transaction_lot_numbers mtl,
               mtl_material_transactions   mmt
    where  mmt.creation_date between to_date(p_from_date,'yyyymmdd') and   to_date(p_to_date,'yyyymmdd')
    and  mmt.organization_id=84
    and  mmt.transaction_type_id =100
    and  msi.organization_id=mmt.organization_id
    and  msi.inventory_item_id=mmt.inventory_item_id
    and  mtl.transaction_id=mmt.transaction_id
    and  mtl.inventory_item_id=mmt.inventory_item_id
    --and  mtl.transaction_quantity<=0
    and   substr(mmt.subinventory_code,3,1) <='7'
    and substr(mmt.subinventory_code,1,1)=1
    and substr(mtl.lot_number, 1, 5) = pv.segment1(+)
    --AND pv.vendor_name = decode(p_vendor_name,null, pv.vendor_name,p_vendor_name)
    group by 
     to_char(mmt.creation_date,'yyyymmdd') ,
              mmt.transaction_id,
              mmt.subinventory_code,
               msi.segment1 ,
               msi.description ,
             
              mtl.lot_number ,
                PV.SEGMENT1 ,
               pv.vendor_name 
      

  3.   

    mtl_material_transactions 
    按F5默认的索引是N9 但是把参数p_to_date和p_from_date换成日期运行一次后再按F5索引就是N26了,不过报表第一次提交运行速度很慢,应该是默认索引的问题吧
      

  4.   

    where mmt.creation_date between to_date(p_from_date,'yyyymmdd') and to_date(p_to_date,'yyyymmdd')
    and substr(mmt.subinventory_code,3,1) <='7'
    and substr(mmt.subinventory_code,1,1)=1
    and substr(mtl.lot_number, 1, 5) = pv.segment1(+)你的索引是那个字段的?如果是以上字段,说明不走索引是正常的,因为你的字段经过了转换参数p_to_date和p_from_date换成日期运行一次后再按F5索引就是N26了,好像索引是日期,
    where mmt.creation_date between to_date(p_from_date,'yyyymmdd') and to_date(p_to_date,'yyyymmdd')你说这里的字段改成值,会走索引?你的索引是哪个字段啊,昏倒了
      

  5.   

    ····字段是creation_date  没有转换啊