4

看下面的执行计划。它说 Oracle 将从索引范围扫描开始......但这是不可能的,因为他没有任何值可查找,因为它从 ENI_TAVOLO_ETL_DETT 表中读取这些值。

执行计划不是说实话吗?

在此处输入图像描述

查询是:

 SELECT DISTINCT
          DTSC.TSC_ETL_ID "Tavolo ETL",
          DTSC.TIPO_PROCESSO_COD "TIPO_PROCESSO",
          dtsc.PUNTO_EROGAZIONE_COD "PUNTO_EROGAZIONE",
          DTSC.FORNITURA_OLD_COD "FORNITURA",
          DTSC.SOGGETTO_COD "SOGGETTO",
          DTSC.CONTO_CLIENTE_COD "CONTO_CLIENTE",
          (SELECT f1.eif_campo24
             FROM etl_elab_interf_flat f1
            WHERE     f1.eif_campo198 = DTSC.id_messaggio
                  AND f1.idde_identif_dati_ext_id = DTSC.idde_identif_dati_ext_id
                  AND f1.eif_campo200 = 'FORNITURA_ENI'
                  AND f1.eif_campo29 = 'Nuovo')
             "C_ORD_IT",
          (SELECT TO_CHAR (
                     TRUNC (DataCompetenzaProcesso (dtsc.id_messaggio,
                                                    dtsc.idde_identif_dati_ext_id,
                                                    dtsc.tipo_processo_cod,
                                                    c.pia_pod_attesa_id)),
                     'DD/MM/YYYY')
             FROM eni_flussi_hub c
            WHERE     c.flh_id_messaggio = dtsc.id_messaggio
                  AND dtsc.idde_identif_dati_ext_id = c.idde_identif_dati_ext_id)
             "DATA COMPETENZA",
          DTSC.id_messaggio "ID_MESSAGGIO",
          --       ParseError (dtsc.mon_desc_errore_siu) "Tipo errore",
          REPLACE (REGEXP_REPLACE (dtsc.mon_desc_errore_siu,
                                   '
- StackTrace
.*',
                                   '',
                                   1,
                                   0,
                                   'imn'),
                   '
',
                   ' ')
             "Errore",
          dtsc.IDDE_IDENTIF_DATI_EXT_ID
     FROM SIUINTEGRA.ENI_TAVOLO_ETL_DETT DTSC
    WHERE     1 = 1
          AND DTSC.DTSC_TAVOLO_DETT_ID = DTSC.DTSC_STORICO_ID
          AND DTSC.DTSC_DATA_FIN = TO_TIMESTAMP ('31-DIC-9999 00:00:00')
          --
          AND dtsc.tipo_processo_cod IN
                 ('CC',
                  'NUOVA_ATT_ENI',
                  'VOLTURA_ATT',
                  'VOLTURA_ENI',
                  'AT',
                  'VT',
                  'CC_POWER',
                  'VOLTURA_ATT_PWR')
          AND EXISTS
                 (SELECT 1
                    FROM NETATEMP.TMP_BACKLOG_NOBILLING2013_UFF p
                   WHERE p.id_messaggio = DTSC.id_messaggio);

文本格式的计划

Plan
SELECT STATEMENT  ALL_ROWSCost: 205  Bytes: 758  Cardinality: 1  CPU Cost: 82.337.155  IO Cost: 199  Time: 3                    
    2 TABLE ACCESS BY INDEX ROWID TABLE SIUETL.ETL_ELAB_INTERF_FLAT Object Instance: 1  Filter Predicates: "F1"."EIF_CAMPO198"=:B1 AND "F1"."EIF_CAMPO200"='FORNITURA_ENI' AND "F1"."EIF_CAMPO29"='Nuovo'  Cost: 6  Bytes: 27  Cardinality: 1  CPU Cost: 103.802  IO Cost: 6  Time: 1               
        1 INDEX RANGE SCAN INDEX SIUETL.ETL_EIF_FK_IDX4 Search Columns: 1  Access Predicates: "F1"."IDDE_IDENTIF_DATI_EXT_ID"=:B1  Cost: 4  Cardinality: 9  CPU Cost: 40.772  IO Cost: 4  Time: 1           
    4 TABLE ACCESS BY INDEX ROWID TABLE SIUINTEGRA.ENI_FLUSSI_HUB Object Instance: 2  Filter Predicates: "C"."IDDE_IDENTIF_DATI_EXT_ID"=:B1  Cost: 4  Bytes: 21  Cardinality: 1  CPU Cost: 40.070  IO Cost: 4  Time: 1                  
        3 INDEX RANGE SCAN INDEX SIUINTEGRA.ENI_FLH_IDX6 Search Columns: 1  Access Predicates: "C"."FLH_ID_MESSAGGIO"=:B1  Cost: 3  Cardinality: 1  CPU Cost: 29.429  IO Cost: 3  Time: 1           
    12 HASH UNIQUE  Cost: 205  Bytes: 758  Cardinality: 1  CPU Cost: 82.337.155  IO Cost: 199  Time: 3                  
        11 NESTED LOOPS             
            9 NESTED LOOPS  Cost: 204  Bytes: 758  Cardinality: 1  CPU Cost: 69.141.535  IO Cost: 199  Time: 3          
                6 SORT UNIQUE  Cost: 35  Bytes: 611.020  Cardinality: 61.102  CPU Cost: 8.113.248  IO Cost: 34  Time: 1     
                    5 INDEX FAST FULL SCAN INDEX NETATEMP.TMP_BACKLOG_NOBILLING2013_UFF2 Cost: 35  Bytes: 611.020  Cardinality: 61.102  CPU Cost: 8.113.248  IO Cost: 34  Time: 1  
                8 INLIST ITERATOR   
                    7 INDEX RANGE SCAN INDEX SIUINTEGRA.ENI_DTSC_UK4_IDX Search Columns: 2  Access Predicates: "P"."ID_MESSAGGIO"="DTSC"."ID_MESSAGGIO" AND ("DTSC"."TIPO_PROCESSO_COD"='AT' OR "DTSC"."TIPO_PROCESSO_COD"='CC' OR "DTSC"."TIPO_PROCESSO_COD"='CC_POWER' OR "DTSC"."TIPO_PROCESSO_COD"='NUOVA_ATT_ENI' OR "DTSC"."TIPO_PROCESSO_COD"='VOLTURA_ATT' OR "DTSC"."TIPO_PROCESSO_COD"='VOLTURA_ATT_PWR' OR "DTSC"."TIPO_PROCESSO_COD"='VOLTURA_ENI' OR "DTSC"."TIPO_PROCESSO_COD"='VT')  Cost: 9  Cardinality: 1  CPU Cost: 162.886  IO Cost: 9  Time: 1  
            10 TABLE ACCESS BY INDEX ROWID TABLE SIUINTEGRA.ENI_TAVOLO_ETL_DETT Object Instance: 3  Filter Predicates: "DTSC"."DTSC_TAVOLO_DETT_ID"="DTSC"."DTSC_STORICO_ID" AND "DTSC"."DTSC_DATA_FIN"=TO_TIMESTAMP('31-DIC-9999 00:00:00')  Cost: 10  Bytes: 748  Cardinality: 1  CPU Cost: 173.206  IO Cost: 10  Time: 1         
4

2 回答 2

1

现在在这里的评论是正确的。

查询计划首先显示标量子查询,尽管它们是在从驱动查询中获取记录后执行的。今天我了解到这些子查询的成本甚至不考虑在总成本中,因为Oracle不知道它们执行了多少次,请参阅Scalar Subselect Costing

于 2013-09-26T13:58:07.970 回答
0

Oracle 引擎现在使用基于成本的优化器,它根据统计数据收集创建其执行计划。基于这些统计数据,oracle 引擎获取它必须处理的数据量,并相应地创建计划。我要说的是执行计划永远不会固定,除非你强制执行,它将基于 oracle 收集的表统计信息。如果您的统计数据过时,那么执行计划就会变得混乱。

DBA 通过运行后台作业收集统计信息,或者您也可以手动触发它。

早期的 oracle 曾经有基于规则的优化器,所以统计数据不在图片中。

总结一下,我的观点是执行计划不是固定的,并且严重依赖于统计数据。

您可以在此处阅读有关统计信息的更多信息:http: //docs.oracle.com/cd/B10500_01/server.920/a96533/stats.htm

于 2013-09-27T15:15:53.257 回答