Created
June 17, 2022 15:55
-
-
Save hhudson/8755719ce7a6cc71519b861346b5819d to your computer and use it in GitHub Desktop.
query used in AIT episode 78 to retrieve the dbms_hprof results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace force view v_execution_stats as | |
with execution_stats as ( | |
select fi.runid, | |
fi.symbolid, | |
pci.parentsymid, | |
rtrim(fi.module || '.' || nullif(fi.function,fi.module), '.') as unit, | |
nvl(pci.subtree_elapsed_time, fi.subtree_elapsed_time)/1000000 as subtree_elapsed_time_seconds, | |
nvl(pci.function_elapsed_time, fi.function_elapsed_time)/1000000 as function_elapsed_time_seconds, | |
fi.line#, | |
nvl(pci.calls, fi.calls) as calls, | |
namespace, | |
sql_id, | |
sql_text | |
from dbmshp_function_info fi | |
left join dbmshp_parent_child_info pci | |
on fi.runid = pci.runid | |
and fi.symbolid = pci.childsymid | |
where fi.module != 'DBMS_HPROF' | |
), execution_tree as ( | |
select rownum execution_order, | |
runid, | |
rpad('.', (level-1)*2, '.') || unit as unit, | |
line#, | |
subtree_elapsed_time_seconds, | |
function_elapsed_time_seconds, | |
calls, | |
namespace, | |
sql_id, | |
sql_text, | |
level cb_level | |
from execution_stats | |
start with parentsymid is null | |
connect by parentsymid = prior symbolid | |
and runid = prior runid | |
) | |
select runid, | |
execution_order, | |
unit, | |
line#, | |
subtree_elapsed_time_seconds, | |
function_elapsed_time_seconds, | |
calls, | |
namespace, | |
sql_id, | |
sql_text, | |
cb_level, | |
rank() over (partition by runid order by subtree_elapsed_time_seconds desc) as time_rank | |
from execution_tree | |
order by execution_order |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credit to Chris Saxon for the basis of this view : https://devgym.oracle.com/pls/apex/dg/class/databases-for-developers-performance.html