• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Execution plan on Oracle

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Execution plan on Oracle

    I've got these results from an EXPLAIN on SQL on Oracle:

    Code:
    SELECT
      "BUKRS", "BELNR", "GJAHR"
    FROM
      "BKPF"
    WHERE
      "MANDT" = :A0 AND ( "CPUDT" > :A1 AND "CPUDT" < :A2 OR "CPUDT" = :A3 AND "CPUTM" >= :A4 OR
        "CPUDT" = :A5 AND "CPUTM" <= :A6 OR "AEDAT" >= :A7 AND "AEDAT" <= :A8 OR UPDDT >= :A9 AND "UPDDT"  <= :A10 ) AND "AWTYP" = :A11
    
    
    Execution Plan
    
    ---------------------------------------------------------------------------
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)|
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |        |  2223K|   137M|   391K  (2)|
    |*  1 |  TABLE ACCESS BY INDEX ROWID| BKPF   |  2223K|   137M|   391K  (2)|
    |*  2 |   INDEX RANGE SCAN          | BKPF~4 |  2223K|       |  5181   (4)|
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("UPDDT">=:A9 AND "UPDDT"<=:A10 OR "CPUDT">:A1 AND
                  "CPUDT"<:A2 OR "AEDAT">=:A7 AND "AEDAT"<=:A8 OR "CPUDT"=:A3 AND
                  "CPUTM">=:A4 OR "CPUDT"=:A5 AND "CPUTM"<=:A6)
       2 - access("MANDT"=:A0 AND "AWTYP"=:A11)
    )
    This looks to me like rather a bad access path. It certainly takes a long time.

    If I pull out the AEDAT and UPDDT field out, I get this:

    Code:
    SELECT
      "BUKRS", "BELNR", "GJAHR"
    FROM
      "BKPF"
    WHERE
      "MANDT" = :A0 AND ( "CPUDT" > :A1 AND "CPUDT" < :A2 OR "CPUDT" = :A3 AND "CPUTM" >= :A4 OR
      "CPUDT" = :A5 AND "CPUTM" <= :A6 ) AND "AWTYP" = :A11
    
    
    Execution Plan
    
    ----------------------------------------------------------------------------
    | Id  | Operation                    | Name   | Rows  | Bytes | Cost (%CPU)|
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |        |  5647 |   259K| 81617  (10)|
    |   1 |  CONCATENATION               |        |       |       |            |
    |*  2 |   TABLE ACCESS BY INDEX ROWID| BKPF   |    44 |  2068 |  3700  (57)|
    |*  3 |    INDEX SKIP SCAN           | BKPF~5 | 14808 |       |  3083  (68)|
    |*  4 |   TABLE ACCESS BY INDEX ROWID| BKPF   |    44 |  2068 |  3700  (57)|
    |*  5 |    INDEX SKIP SCAN           | BKPF~5 | 14808 |       |  3083  (68)|
    |*  6 |   TABLE ACCESS BY INDEX ROWID| BKPF   |  5559 |   255K| 74217   (5)|
    |*  7 |    INDEX RANGE SCAN          | BKPF~5 |   170K|       | 67134   (5)|
    ----------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter("CPUTM"<=:A6 AND "AWTYP"=:A11)
       3 - access("MANDT"=:A0 AND "CPUDT"=:A5)
           filter("CPUDT"=:A5)
       4 - filter("CPUTM">=:A4 AND "AWTYP"=:A11 AND (LNNVL("CPUDT"=:A5) OR
                  LNNVL("CPUTM"<=:A6)))
       5 - access("MANDT"=:A0 AND "CPUDT"=:A3)
           filter("CPUDT"=:A3)
       6 - filter("AWTYP"=:A11 AND (LNNVL("CPUDT"=:A5) OR
                  LNNVL("CPUTM"<=:A6)) AND (LNNVL("CPUDT"=:A3) OR LNNVL("CPUTM">=:A4)))
       7 - access("MANDT"=:A0 AND "CPUDT">:A1 AND "CPUDT"<:A2)
           filter("CPUDT">:A1 AND "CPUDT"<:A2)
    Which looks a lot better. Trouble is I can't find anything I can understand on the various oracle sites, what the Rows column mean. So I'm not sure my analysis is correct.
    Down with racism. Long live miscegenation!

    #2
    Ah, never mind. It's just an indication of the number of rows likely to be returned according to database statistics.
    Down with racism. Long live miscegenation!

    Comment

    Working...
    X