How to get current SQL Running in Database
=============================================
First findout for which Action you are going to query.
SQL>select distinct(action) from v$session;
==>If you are interested for Concurrent Request then run below query to get the SQL_TEXT.
SQL>col action format a20
col module form a30
select sid,sql_id,action,module from v$session where action like '%Conc%';
select SQL_TEXT from v$sqlarea where sql_id='SQL_ID';
To Get Details from sql_text:
select DBID, SQL_ID, SQL_TEXT from dba_hist_sqltext where sql_text like 'SELECT TRANSACTION_ID FROM XXINT.XXINT_SOA_OUTBOUND_MESG WHERE%';
==>To compare with the data volumes previous when it was executed is less time and current which is taking longer than previous
select s.begin_interval_time, s.end_interval_time , q.snap_id, q.dbid, q.sql_id, q.plan_hash_value,
q.optimizer_cost, q.optimizer_mode from dba_hist_sqlstat q, dba_hist_snapshot s
where q.dbid = 1234567890 and q.sql_id = ‘12345xxxxxxxx’
and q.snap_id = s.snap_id and s.begin_interval_time between sysdate-2 and sysdate
order by s.snap_id desc;
Note::Observe PLAN_HASH_VALUE for both.
These 3 values needed to run the above query.
DBID
SQL_ID
PLAN_HASH_VALUE
==>Now check execution plan by running the below query.
select id, operation, options, object_name, cost
from dba_hist_sql_plan
where dbid = 1234567890 and sql_id = ‘12345xxxxxxxx’
and plan_hash_value = <plan_hash_value1>
-->COMPARE THAT WITH THE SECOND ONE
select id, operation, options, object_name, cost
from dba_hist_sql_plan
where dbid = 1234567890 and sql_id = ‘12345xxxxxxxx’
and plan_hash_value = <plan_hash_value2>
=============================================
First findout for which Action you are going to query.
SQL>select distinct(action) from v$session;
==>If you are interested for Concurrent Request then run below query to get the SQL_TEXT.
SQL>col action format a20
col module form a30
select sid,sql_id,action,module from v$session where action like '%Conc%';
select SQL_TEXT from v$sqlarea where sql_id='SQL_ID';
To Get Details from sql_text:
select DBID, SQL_ID, SQL_TEXT from dba_hist_sqltext where sql_text like 'SELECT TRANSACTION_ID FROM XXINT.XXINT_SOA_OUTBOUND_MESG WHERE%';
==>To compare with the data volumes previous when it was executed is less time and current which is taking longer than previous
select s.begin_interval_time, s.end_interval_time , q.snap_id, q.dbid, q.sql_id, q.plan_hash_value,
q.optimizer_cost, q.optimizer_mode from dba_hist_sqlstat q, dba_hist_snapshot s
where q.dbid = 1234567890 and q.sql_id = ‘12345xxxxxxxx’
and q.snap_id = s.snap_id and s.begin_interval_time between sysdate-2 and sysdate
order by s.snap_id desc;
Note::Observe PLAN_HASH_VALUE for both.
These 3 values needed to run the above query.
DBID
SQL_ID
PLAN_HASH_VALUE
==>Now check execution plan by running the below query.
select id, operation, options, object_name, cost
from dba_hist_sql_plan
where dbid = 1234567890 and sql_id = ‘12345xxxxxxxx’
and plan_hash_value = <plan_hash_value1>
-->COMPARE THAT WITH THE SECOND ONE
select id, operation, options, object_name, cost
from dba_hist_sql_plan
where dbid = 1234567890 and sql_id = ‘12345xxxxxxxx’
and plan_hash_value = <plan_hash_value2>
Comments
Post a Comment