Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

why does dbms_xplan.display_awr return two plan hash values for one sql_id?

Simon SouvAug 25 2020 — edited Aug 31 2020

Hello community,

-- Oracle version 11.2.0.4.0 --

Our application is showing a slowness at a function we were able to spot.

Behind this funtion we have a sql statement that is shown as top 1 in our AWR report with this metrics:

"Elapsed Time (s)" = 24,596.43

"Executions" = 39,936

"Elapsed Time per Exec (s)" = 0.62

"SQL ID" = 0hcvs0hp7ty6t

I want to see the plan behind this sql so I executed:

select * from table(dbms_xplan.display_awr('0hcvs0hp7ty6t',null,null,'all'));

but this returns me two plans?

Plan hash value: 604695398

----------------------------------------------------------------------------------------------------------------

| Id  | Operation                        | Name                        | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT                 |                             |       |       |     4 (100)|          |

|   1 |  SORT AGGREGATE                  |                             |     1 |    13 |            |          |

|   2 |   VIEW                           |                             |     1 |    13 |     2   (0)| 00:00:01 |

|   3 |    TABLE ACCESS FULL             | SYS_TEMP_0FD9D84A7_B3BEE4AA |     1 |    37 |     2   (0)| 00:00:01 |

|   4 |    SORT AGGREGATE                |                             |     1 |    20 |            |          |

|   5 |     VIEW                         |                             |     1 |    20 |     2   (0)| 00:00:01 |

|   6 |      TABLE ACCESS FULL           | SYS_TEMP_0FD9D84A7_B3BEE4AA |     1 |    37 |     2   (0)| 00:00:01 |

|   7 |  TEMP TABLE TRANSFORMATION       |                             |       |       |            |          |

|   8 |   LOAD AS SELECT                 |                             |       |       |            |          |

|   9 |    SORT ORDER BY                 |                             |     1 |    37 |     2  (50)| 00:00:01 |

|  10 |     VIEW                         |                             |     1 |    37 |     1   (0)| 00:00:01 |

|  11 |      WINDOW SORT                 |                             |     1 |    36 |     1   (0)| 00:00:01 |

|  12 |       TABLE ACCESS BY INDEX ROWID| MY_TABLE                    |     1 |    36 |     1   (0)| 00:00:01 |

|  13 |        INDEX RANGE SCAN          | MY_TABLE_FO1                |    10 |       |     1   (0)| 00:00:01 |

|  14 |   FAST DUAL                      |                             |     1 |       |     2   (0)| 00:00:01 |

----------------------------------------------------------------------------------------------------------------

Plan hash value: 3011532279

----------------------------------------------------------------------------------------------------------------

| Id  | Operation                        | Name                        | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT                 |                             |       |       |     4 (100)|          |

|   1 |  SORT AGGREGATE                  |                             |     1 |    13 |            |          |

|   2 |   VIEW                           |                             |     1 |    13 |     2   (0)| 00:00:01 |

|   3 |    TABLE ACCESS FULL             | SYS_TEMP_0FD9D6A14_B3BEE4AA |     1 |    58 |     2   (0)| 00:00:01 |

|   4 |    SORT AGGREGATE                |                             |     1 |    20 |            |          |

|   5 |     VIEW                         |                             |     1 |    20 |     2   (0)| 00:00:01 |

|   6 |      TABLE ACCESS FULL           | SYS_TEMP_0FD9D6A14_B3BEE4AA |     1 |    58 |     2   (0)| 00:00:01 |

|   7 |  TEMP TABLE TRANSFORMATION       |                             |       |       |            |          |

|   8 |   LOAD AS SELECT                 |                             |       |       |            |          |

|   9 |    SORT ORDER BY                 |                             |     1 |    58 |     2  (50)| 00:00:01 |

|  10 |     VIEW                         |                             |     1 |    58 |     1   (0)| 00:00:01 |

|  11 |      WINDOW SORT                 |                             |     1 |    72 |     1   (0)| 00:00:01 |

|  12 |       TABLE ACCESS BY INDEX ROWID| MY_TABLE                    |     1 |    72 |     1   (0)| 00:00:01 |

|  13 |        INDEX RANGE SCAN          | MY_TABLE_I5                 |     1 |       |     1   (0)| 00:00:01 |

|  14 |   FAST DUAL                      |                             |     1 |       |     2   (0)| 00:00:01 |

----------------------------------------------------------------------------------------------------------------

So how can I know which plan was actually executed?

Thank you for your feedbacks

Message was edited by: 3666083

Comments
Post Details
Added on Aug 25 2020
10 comments
894 views