Oracle

性能問題:PL/SQL

  • July 28, 2022
SELECT
 NULL AS TRX_NUMBER ,
 NULL AS CUSTOMER_TRX_ID ,
 VW_SAP_MPP_INV1.DOCENTRY AS DOCENTRY ,
 VW_SAP_MPP_INV1.LINENUM AS LINENUM ,
 VW_SAP_MPP_INV1.ITEMCODE AS ITEMCODE ,
 VW_SAP_MPP_INV1.U_ALTDESC AS U_ALTDESC ,
 VW_SAP_MPP_INV1.DESCRIPTION AS DESCRIPTION ,
 VW_SAP_MPP_INV1.PRICE AS PRICE ,
 VW_SAP_MPP_INV1.QUANTITY AS QUANTITY ,
 VW_SAP_MPP_INV1.LINETOTAL AS LINETOTAL ,
 VW_SAP_MPP_INV1.TAXSTATUS AS TAXSTATUS ,
 VW_SAP_MPP_INV1.TAX AS TAX ,
 VW_SAP_MPP_INV1.WHSCODE AS WHSCODE ,
 VW_SAP_MPP_INV1.U_WP AS U_WP ,
 VW_SAP_MPP_INV1.U_CASENUM AS U_CASENUM ,
 VW_SAP_MPP_INV1.U_FACILITY AS U_FACILITY ,
 VW_SAP_MPP_INV1.U_OPENED AS U_OPENED ,
 VW_SAP_MPP_INV1.U_CLOSED AS U_CLOSED ,
 VW_SAP_MPP_INV1.U_CONTACTPERSON AS U_CONTACTPERSON ,
 VW_SAP_MPP_INV1.LINETYPE AS LINETYPE ,
 VW_SAP_MPP_INV1.VISORDER AS VISORDER ,
 VW_SAP_MPP_INV1."DATECREATEPORTAL" AS DATECREATEPORTAL ,
 NULL AS DATEMODIFYPORTAL ,
 NULL AS HDR_UPDATEDATE ,
 NULL AS LINE_UPDATEDATE ,
 NULL AS INV_CURR_CODE ,
 NULL AS HDR_ETL_UPDATE_DT ,
 VW_SAP_MPP_INV1.LINE_ETL_UPDATE_DT AS LINE_ETL_UPDATE_DT ,
 NULL AS WO_ETL_UPDATE_DT ,
 VW_SAP_MPP_INV1.ITEM_DESC AS ITEM_DESC ,
 VW_SAP_MPP_INV1.SOURCEID AS SOURCEID  
FROM
 ODS.VW_SAP_MPP_INV1 VW_SAP_MPP_INV1
WHERE
 (VW_SAP_MPP_INV1.LINE_ETL_UPDATE_DT >= TO_DATE(SUBSTR('2022-07-26 15:35:19.0',0,19),'YYYY-MM-DD HH24:MI:SS'))
 The `View` is a simple select from a `table`

0.50 sec它在(沒有“WHERE”條件)內"WHERE" condition獲取50 行80 seconds.

請就如何提高此性能提出建議。解釋計劃

這不是從表中簡單地選擇。您有 2 個帶有連接的表。

在沒有條件的情況下隨機獲取前 50 行與獲取由條件指定的前 50 行不同。

  1. 用於連接的列的數據類型不匹配,由計劃中的 SYS_OP_C2C 內部轉換函式指示。這應該被修復,因為它永遠不會像這樣是最佳的。
  2. 即使您使用 Exadata(由 STORAGE FULL 表示),儲存索引也不是可以在所有場景中替代標準索引的某種魔法。索引在這裡可能會有所幫助,但我們不知道您的表、數據的數量和分佈。嘗試在 SAP_INV1(ETL_UPDATE_DT) 上創建索引,或者如果存在這樣的索引,請檢查統計資訊以了解為什麼不使用它。
  3. 最後,並行查詢可能是不必要的成本,具體取決於數據量,我們也不知道。

引用自:https://dba.stackexchange.com/questions/314967