|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
视图优化求助,请大家帮忙看下这个视图怎么优化
请大家帮忙看下这个视图怎么优化, 在查询时class_code='RT001'时速度很慢,1200行数据要60秒钟时间,打家帮忙分下下
代码如下:
create or replace view cux_wip_cjpgpt_view as
Select wdj.wip_entity_id --任务ID
,wdj.scheduled_start_date --计划开始时间
,wdj.scheduled_completion_date --计划完工时间
,hcaz.account_number --客户编码
,hzps.party_name --客户名称
,oola.shipping_instructions --最终客户
,msib.segment1 --产品编码
,msib.Description --产品描述(物料描述)
,wpes.wip_entity_name --任务号
,wdj.start_quantity --任务数量
,wdj.class_code --工单类型
,wdj.creation_date --创建日期
,decode(wdj.status_type,12,'关闭',1,'未释放',3,'已释放',4,'完成') status_type --工单状态
,msib.Attribute11 --辅助计划员1
,msib.Attribute12 --辅助计划员2
,cux_wip_mtwgsl(wdj.attribute1,wdj.primary_item_id,wdj.organization_id) complete_quantity --面套完工数量
,Case When instr(msib.segment1,'.P') >= 1 Or instr(msib.segment1,'.X') >= 1 Or instr(msib.segment1,'.FG') >= 1 Then '皮' Else '布' End pbsort --皮布分类
,wdj.organization_id
,cwth.print_time --打印次数
,wdj.attribute7 -- 备注
From wip_entities wpes --生产任务
,wip_discrete_jobs wdj --生产任务
,cux_wip_task_history cwth
,oe_order_headers_all ooha --订单头
,oe_order_lines_all oola --订单行
,hz_cust_accounts hcaz
,hz_parties hzps
,mtl_system_items_b msib --物料
Where wdj.wip_entity_id = wpes.wip_entity_id
And wdj.organization_id = wpes.organization_id
And wdj.organization_id = msib.organization_id
And wdj.attribute1 = oola.line_id
And wdj.wip_entity_id = cwth.wip_entity_id(+)
And wdj.organization_id = cwth.organization_Id(+)
And wdj.primary_item_id = msib.inventory_item_id
And oola.header_id = ooha.header_id
And ooha.sold_to_org_id = hcaz.cust_account_id
And hcaz.party_id = hzps.party_id
And wdj.attribute1 Is Not Null
And wdj.status_type In(3,1)
Union All
Select wdj.wip_entity_id --任务ID
,wdj.scheduled_start_date --计划开始时间
,wdj.scheduled_completion_date --计划完工时间
,Null account_number --客户编码
,Null party_name --客户名称
,Null shipping_instructions --最终客户
,msib.segment1 --产品编码
,msib.Description --产品描述(物料描述)
,wpes.wip_entity_name --任务号
,wdj.start_quantity --任务数量
,wdj.class_code --工单类型
,wdj.creation_date --创建日期
,decode(wdj.status_type,12,'关闭',1,'未释放',3,'已释放',4,'完成') status_type --工单状态
,msib.Attribute11 --辅助计划员1
,msib.Attribute12 --辅助计划员2
,cux_wip_mtwgsl(wdj.attribute1,wdj.primary_item_id,wdj.organization_id) complete_quantity --面套完工数量
,Case When instr(msib.segment1,'.P') >= 1 Or instr(msib.segment1,'.X') >= 1 Or instr(msib.segment1,'.FG') >= 1 Then '皮' Else '布' End pbsort --皮布分类
,wdj.organization_id
,cwth.print_time --打印次数
,wdj.attribute7 -- 备注
From wip_entities wpes --生产任务
,wip_discrete_jobs wdj --生产任务
,cux_wip_task_history cwth
,mtl_system_items_b msib --物料
Where wdj.wip_entity_id = wpes.wip_entity_id
And wdj.organization_id = wpes.organization_id
And wdj.attribute1 Is Null
And wdj.organization_id = msib.organization_id
And wdj.primary_item_id = msib.inventory_item_id
And wdj.wip_entity_id = cwth.wip_entity_id(+)
And wdj.organization_id = cwth.organization_Id(+)
And wdj.status_type In(3,1);
执行计划如下:
Execution Plan
----------------------------------------------------------
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
---------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1003 | 1859K| 5640 (1)|
| 1 | VIEW | CUX_WIP_CJPGPT_VIEW | 1003 | 1859K| 5640 (1)|
| 2 | UNION-ALL | | | | |
| 3 | NESTED LOOPS | | 726 | 157K| 4314 (1)|
|* 4 | HASH JOIN | | 726 | 112K| 2860 (2)|
|* 5 | HASH JOIN | | 726 | 101K| 2401 (2)|
| 6 | TABLE ACCESS FULL | HZ_PARTIES | 1575 | 36225 | 18 (0)|
|* 7 | HASH JOIN | | 726 | 87120 | 2383 (2)|
| 8 | TABLE ACCESS FULL | HZ_CUST_ACCOUNTS | 232 | 3712 | 5 (0)|
|* 9 | HASH JOIN | | 726 | 75504 | 2377 (2)|
|* 10 | HASH JOIN RIGHT OUTER | | 726 | 68244 | 2102 (2)|
| 11 | TABLE ACCESS FULL | CUX_WIP_TASK_HISTORY | 2140 | 23540 | 5 (0)|
| 12 | NESTED LOOPS | | 726 | 60258 | 2096 (2)|
|* 13 | TABLE ACCESS FULL | WIP_DISCRETE_JOBS | 940 | 54520 | 1154 (2)|
| 14 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_LINES_ALL | 1 | 25 | 1 (0)|
|* 15 | INDEX UNIQUE SCAN | OE_ORDER_LINES_U1 | 1 | | 0 (0)|
| 16 | TABLE ACCESS FULL | OE_ORDER_HEADERS_ALL | 18854 | 184K | 275 (2)|
| 17 | TABLE ACCESS FULL | WIP_ENTITIES | 88928 | 1302K| 457 (2)|
| 18 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_B | 1 | 64 | 2 (0)|
|* 19 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_B_U1 | 1 | | 1 (0)|
| 20 | NESTED LOOPS | | 277 | 40996 | 1326 (1)|
| 21 | NESTED LOOPS | | 277 | 23268 | 771 (1)|
|* 22 | HASH JOIN OUTER | | 277 | 19113 | 494 (1)|
| 23 | INLIST ITERATOR | | | | |
|* 24 | TABLE ACCESS BY INDEX ROWID | WIP_DISCRETE_JOBS | 277 | 16066 | 488 (0)|
|* 25 | INDEX RANGE SCAN | WIP_DISCRETE_JOBS_N7 | 563 | | 20 (0)|
| 26 | TABLE ACCESS FULL | CUX_WIP_TASK_HISTORY | 2140 | 23540 | 5 (0)|
|* 27 | TABLE ACCESS BY INDEX ROWID | WIP_ENTITIES | 1 | 15 | 1 (0)|
|* 28 | INDEX UNIQUE SCAN | WIP_ENTITIES_U1 | 1 | | 0 (0)|
| 29 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_B | 1 | 64 | 2 (0)|
|* 30 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_B_U1 | 1 | | 1 (0)|
---------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("WDJ"."WIP_ENTITY_ID"="WPES"."WIP_ENTITY_ID" AND
"WDJ"."ORGANIZATION_ID"="WPES"."ORGANIZATION_ID")
5 - access("HCAZ"."PARTY_ID"="HZPS"."PARTY_ID")
7 - access("OOHA"."SOLD_TO_ORG_ID"="HCAZ"."CUST_ACCOUNT_ID")
9 - access("OOLA"."HEADER_ID"="OOHA"."HEADER_ID")
10 - access("WDJ"."WIP_ENTITY_ID"="CWTH"."WIP_ENTITY_ID"(+) AND
"WDJ"."ORGANIZATION_ID"="CWTH"."ORGANIZATION_ID"(+))
13 - filter("WDJ"."ATTRIBUTE1" IS NOT NULL AND "WDJ"."CLASS_CODE"='RT001' AND
("WDJ"."STATUS_TYPE"=1 OR "WDJ"."STATUS_TYPE"=3))
15 - access("OOLA"."LINE_ID"=TO_NUMBER("WDJ"."ATTRIBUTE1"))
19 - access("WDJ"."PRIMARY_ITEM_ID"="MSIB"."INVENTORY_ITEM_ID" AND
"WDJ"."ORGANIZATION_ID"="MSIB"."ORGANIZATION_ID")
22 - access("WDJ"."WIP_ENTITY_ID"="CWTH"."WIP_ENTITY_ID"(+) AND
"WDJ"."ORGANIZATION_ID"="CWTH"."ORGANIZATION_ID"(+))
24 - filter("WDJ"."CLASS_CODE"='RT001')
25 - access(("WDJ"."STATUS_TYPE"=1 OR "WDJ"."STATUS_TYPE"=3) AND "WDJ"."ATTRIBUTE1" IS
NULL)
filter("WDJ"."ATTRIBUTE1" IS NULL)
27 - filter("WDJ"."ORGANIZATION_ID"="WPES"."ORGANIZATION_ID")
28 - access("WDJ"."WIP_ENTITY_ID"="WPES"."WIP_ENTITY_ID")
30 - access("WDJ"."PRIMARY_ITEM_ID"="MSIB"."INVENTORY_ITEM_ID" AND
"WDJ"."ORGANIZATION_ID"="MSIB"."ORGANIZATION_ID")
Note
-----
- 'PLAN_TABLE' is old version
Statistics
----------------------------------------------------------
7589 recursive calls
0 db block gets
3322617 consistent gets
0 physical reads
0 redo size
166624 bytes sent via SQL*Net to client
1324 bytes received via SQL*Net from client
86 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1266 rows processed
谢谢大家了
|
|