create table temp_01_200 as (
select we.WIP_ENTITY_NAME,msi.SEGMENT1 item_no,msi.DESCRIPTION,wdj.SCHEDULED_COMPLETION_DATE start_date,
wdj.START_QUANTITY,wdj.QUANTITY_COMPLETED qty
from wip_discrete_jobs wdj,
mtl_system_items msi,
wip_entities we,
WIP_OPERATIONS_V wo,
...(略)
以Toad來執行時間非常的久,過了15分鐘還沒有完成。
但是單獨執行Select的SQL語法卻不到1秒就出來了,而且筆數只有200筆。
所以我重新執行一次Create Table,並找出執行計畫,發現Buffer Sort有Full Scan Table的情況
檢查WIP_OPERATIONS_V的SQL語法,發現這個View有使用order by語法。
... (略)
FROM BOM_DEPARTMENTS BD,
BOM_STANDARD_OPERATIONS BSO,
WIP_OPERATIONS WO,
MFG_LOOKUPS LU1
WHERE BD.DEPARTMENT_ID = WO.DEPARTMENT_ID
AND BSO.STANDARD_OPERATION_ID(+) = WO.STANDARD_OPERATION_ID
AND NVL (BSO.OPERATION_TYPE, 1) = 1
AND BSO.LINE_ID IS NULL
AND LU1.LOOKUP_TYPE(+) = 'BOM_EAM_SHUTDOWN_TYPE'
AND LU1.LOOKUP_CODE(+) = WO.SHUTDOWN_TYPE
ORDER BY WO.OPERATION_SEQ_NUM;
於是改寫Create Table語法,直接以SQL取代View,並將order by刪掉,重新執行Create Table很快就完成了