oracle distict 效率,为什么用distinct时很慢?解决方法

当前位置:我的异常网» Oracle管理 » 为什么用distinct时很慢?解决方法

为什么用distinct时很慢?解决方法

www.myexceptions.net  网友分享于:2013-05-09  浏览:451次

为什么用distinct时很慢?

为什么用distinct时很慢?

以下select语句很快就得到结果,共有十几万行,但是有很多重复行,

select

J030.* from

(

select wip_entity_name,

msi.inventory_item_id,

msi.segment1,

we.organization_id,

msi.description,

wdj.START_QUANTITY,

wdj.QUANTITY_completed,

wdj.QUANTITY_SCRAPPED,

wdj.creation_date,

max(WMT.TRANSACTION_DATE) last_date,

wdj.COMPLETION_SUBINVENTORY,

wdj.DATE_COMPLETED,

TO_OPERATION_SEQ_NUM,

wdj.wip_entity_id,

mmt.TRANSACTION_REFERENCE REFERENCE,

mmt.transaction_type_id,

decode(substr(wdj.class_code, 1, 2),

'FX',

msi.attribute1,

msi.WIP_SUPPLY_SUBINVENTORY) WIP_SUPPLY_SUBINVENTORY

from wip.wip_move_transactions wmt,

wip.WIP_DISCRETE_JOBS wdj,

wip.wip_entities we,

inv.mtl_material_transactions mmt,

inv.mtl_system_items msi

where

--TRANSACTION_DATE >= nvl(:p_fm_date, to_date('20000101', 'yyyymmdd'))

--and TRANSACTION_DATE < nvl(:p_to_date, to_date('20200101', 'yyyymmdd')) + 1

WMT.TRANSACTION_DATE >= nvl(to_date('&p_fm_date','YYMMDD'), to_date('20000101', 'yyyymmdd'))

and WMT.TRANSACTION_DATE < nvl(to_date('&p_to_date','YYMMDD'), to_date('20200101', 'yyyymmdd')) + 1

and TO_OPERATION_SEQ_NUM =

(select max(OPERATION_SEQ_NUM)

from APPS.WIP_OPERATIONS wo

where wo.wip_entity_id = wmt.wip_entity_id

and wo.organization_id = wmt.organization_id)

and to_INTRAOPERATION_STEP_TYPE = 3

and wdj.wip_entity_id = wmt.wip_entity_id

and wdj.COMPLETION_SUBINVENTORY = 'J030半成品'

and wdj.organization_id = wmt.organization_id

and we.wip_entity_id = wmt.wip_entity_id

--AND we.wip_entity_name not like '%W%'

--AND WE.WIP_ENTITY_NAME || '' LIKE :P_1

AND WE.WIP_ENTITY_NAME || '' LIKE '&P_1'

--and ((wdj.class_code not like 'FX%' and

-- msi.WIP_SUPPLY_SUBINVENTORY || '' like :P_SUB_CODE || '%') or

-- (wdj.class_code like 'FX%' and

-- msi.attribute1 || '' like :P_SUB_CODE || '%'))

and ((wdj.class_code not like 'FX%' and

msi.WIP_SUPPLY_SUBINVENTORY || '' like '&P_SUB_CODE' || '%') or

(wdj.class_code like 'FX%' and

msi.attribute1 || '' like '&P_SUB_CODE' || '%'))

and msi.inventory_item_id = we.primary_item_id

and msi.organization_id = we.organization_id

--and mmt.inventory_item_id=msi.inventory_item_id

and mmt.inventory_item_id=we.primary_item_id

and mmt.organization_id=we.organization_id

and SUBINVENTORY_code||'' ='J030半成品'

and mmt.transaction_date>=we.creation_date

and mmt.TRANSACTION_SOURCE_ID=we.wip_entity_id

--and mmt.transaction_type_id not in (128)

and we.wip_entity_name like '%JM%'

group by wip_entity_name,

msi.inventory_item_id,

msi.segment1,

we.organization_id,

msi.description,

文章评论

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值