How to Extract SQL Text Using Parallel in Oracle

How to find the query using parallel operator in Oracle


SELECT DISTINCT
    p.sql_id,
    DBMS_LOB.SUBSTR(t.sql_text, 4000, 1) AS sql_text,
    s.executions_delta AS executions,
    s.cpu_time_delta / 1000000 AS cpu_seconds,
    s.elapsed_time_delta / 1000000 AS elapsed_seconds,
    p.other_tag
FROM dba_hist_sql_plan p
JOIN dba_hist_sqltext t ON p.sql_id = t.sql_id
JOIN dba_hist_sqlstat s ON p.sql_id = s.sql_id
WHERE p.other_tag LIKE '%PARALLEL%'
  AND s.parsing_schema_name = 'HR';

How to find the SQL Text using the parallel in Oracle


SELECT DISTINCT
    p.sql_id,
    t.sql_text,
    s.executions_delta AS executions,
    s.cpu_time_delta / 1000000 AS cpu_seconds,
    s.elapsed_time_delta / 1000000 AS elapsed_seconds,
    p.other_tag
FROM dba_hist_sql_plan p
JOIN dba_hist_sqltext t ON p.sql_id = t.sql_id
JOIN dba_hist_sqlstat s ON p.sql_id = s.sql_id
WHERE p.other_tag LIKE '%PARALLEL%'
  AND s.parsing_schema_name = 'HR';

How to fine the SQL Query currently using parallel operator in Oracle

SELECT px.qcsid AS coordinator_sid,
       px.sid AS slave_sid,
       px.req_degree AS requested_dop,
       px.degree AS actual_dop,
       s.sql_id
FROM v$px_session px
JOIN v$session s ON px.sid = s.sid
WHERE s.username = 'HR';

Leave a Reply