2026-05-01 07:25:46

This commit is contained in:
2026-05-01 09:25:48 +02:00
parent ea39d398ae
commit b2358a2f1b
60 changed files with 5675 additions and 4109 deletions
-1
View File
@@ -128,4 +128,3 @@ SELECT to_char(trunc(COMPLETION_TIME),'DD-Mon-YY') "Date",
group by trunc(COMPLETION_TIME), to_char(COMPLETION_TIME, 'Dy')
order by trunc(COMPLETION_TIME)
/
+1
View File
@@ -90,3 +90,4 @@ group by trunc(COMPLETION_TIME,'HH24'), to_char(COMPLETION_TIME, 'Dy')
order by trunc(COMPLETION_TIME,'HH24')
;
+34 -46
View File
@@ -6,22 +6,20 @@
-- | Copyright (c) 1998-2011 Jeffrey M. Hunter. All rights reserved. |
-- |----------------------------------------------------------------------------|
-- | DATABASE : Oracle |
-- | FILE : perf_log_switch_history_count_daily_7.sql |
-- | FILE : perf_log_switch_history_count_daily_all.sql |
-- | CLASS : Tuning |
-- | PURPOSE : Reports on how often log switches occur in your database on a |
-- | daily basis. This script is to be used with an Oracle 7 |
-- | database. |
-- | daily basis. It will query all records contained in |
-- | v$log_history. This script is to be used with an Oracle 8 |
-- | database or higher. |
-- | NOTE : As with any code, ensure to test this script in a development |
-- | environment before attempting to run it in production. |
-- +----------------------------------------------------------------------------+
-- SET LINESIZE 145
SET LINESIZE 145
SET PAGESIZE 9999
SET VERIFY off
ACCEPT startDate PROMPT 'Enter start date (DD-MON-YYYY): '
ACCEPT endDate PROMPT 'Enter end date (DD-MON-YYYY): '
COLUMN H00 FORMAT 999 HEADING '00'
COLUMN H01 FORMAT 999 HEADING '01'
COLUMN H02 FORMAT 999 HEADING '02'
@@ -50,44 +48,34 @@ COLUMN TOTAL FORMAT 999,999 HEADING 'Total'
SELECT
SUBSTR(time,1,5) DAY
, SUM(DECODE(SUBSTR(time,10,2),'00',1,0)) H00
, SUM(DECODE(SUBSTR(time,10,2),'01',1,0)) H01
, SUM(DECODE(SUBSTR(time,10,2),'02',1,0)) H02
, SUM(DECODE(SUBSTR(time,10,2),'03',1,0)) H03
, SUM(DECODE(SUBSTR(time,10,2),'04',1,0)) H04
, SUM(DECODE(SUBSTR(time,10,2),'05',1,0)) H05
, SUM(DECODE(SUBSTR(time,10,2),'06',1,0)) H06
, SUM(DECODE(SUBSTR(time,10,2),'07',1,0)) H07
, SUM(DECODE(SUBSTR(time,10,2),'08',1,0)) H08
, SUM(DECODE(SUBSTR(time,10,2),'09',1,0)) H09
, SUM(DECODE(SUBSTR(time,10,2),'10',1,0)) H10
, SUM(DECODE(SUBSTR(time,10,2),'11',1,0)) H11
, SUM(DECODE(SUBSTR(time,10,2),'12',1,0)) H12
, SUM(DECODE(SUBSTR(time,10,2),'13',1,0)) H13
, SUM(DECODE(SUBSTR(time,10,2),'14',1,0)) H14
, SUM(DECODE(SUBSTR(time,10,2),'15',1,0)) H15
, SUM(DECODE(SUBSTR(time,10,2),'16',1,0)) H16
, SUM(DECODE(SUBSTR(time,10,2),'17',1,0)) H17
, SUM(DECODE(SUBSTR(time,10,2),'18',1,0)) H18
, SUM(DECODE(SUBSTR(time,10,2),'19',1,0)) H19
, SUM(DECODE(SUBSTR(time,10,2),'20',1,0)) H20
, SUM(DECODE(SUBSTR(time,10,2),'21',1,0)) H21
, SUM(DECODE(SUBSTR(time,10,2),'22',1,0)) H22
, SUM(DECODE(SUBSTR(time,10,2),'23',1,0)) H23
, COUNT(*) TOTAL
SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH:MI:SS'),1,5) DAY
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'00',1,0)) H00
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'01',1,0)) H01
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'02',1,0)) H02
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'03',1,0)) H03
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'04',1,0)) H04
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'05',1,0)) H05
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'06',1,0)) H06
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'07',1,0)) H07
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'08',1,0)) H08
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'09',1,0)) H09
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'10',1,0)) H10
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'11',1,0)) H11
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'12',1,0)) H12
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'13',1,0)) H13
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'14',1,0)) H14
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'15',1,0)) H15
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'16',1,0)) H16
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'17',1,0)) H17
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'18',1,0)) H18
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'19',1,0)) H19
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'20',1,0)) H20
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'21',1,0)) H21
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'22',1,0)) H22
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'23',1,0)) H23
, COUNT(*) TOTAL
FROM
v$log_history a
WHERE
(TO_DATE(SUBSTR(time, 1,8), 'MM/DD/RR')
>=
TO_DATE('&startDate', 'DD-MON-YYYY')
)
AND
(TO_DATE(SUBSTR(time, 1,8), 'MM/DD/RR')
<=
TO_DATE('&endDate', 'DD-MON-YYYY')
)
GROUP BY SUBSTR(time,1,5)
v$log_history a
GROUP BY SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH:MI:SS'),1,5)
ORDER BY SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH:MI:SS'),1,5)
/
+2
View File
@@ -1,3 +1,4 @@
/*
*
* Author : Vishal Gupta
@@ -127,3 +128,4 @@ ORDER BY s.end_interval_time
, ss.instance_number
;
+6 -4
View File
@@ -43,11 +43,13 @@ from
join dba_hist_snapshot snap using (snap_id,instance_number)
join gv$instance i using (instance_number)
where
snap.begin_interval_time>=&&2
and snap.end_interval_time<=&&3
and force_matching_signature='&&1'
and executions_delta>0
snap.begin_interval_time>=&&2
and snap.end_interval_time<=&&3
and force_matching_signature='&&1'
and executions_delta>0
order by
snap_id asc
/
+6 -4
View File
@@ -41,11 +41,13 @@ from
join dba_hist_snapshot snap using (snap_id,instance_number)
join gv$instance i using (instance_number)
where
snap.begin_interval_time>=&&2
and snap.end_interval_time<=&&3
and sql_id='&&1'
and executions_delta>0
snap.begin_interval_time>=&&2
and snap.end_interval_time<=&&3
and sql_id='&&1'
and executions_delta>0
order by
snap_id asc
/
+48
View File
@@ -0,0 +1,48 @@
-- https://blogs.oracle.com/optimizer/post/check-sql-stale-statistics
set pagesize 100
set linesize 150
set trims off
set tab off
set verify off
column table_name format a50
column index_name format a50
column object_type format a40
column owner format a40
with plan_tables as (
select distinct object_name,object_owner, object_type
from dba_hist_sql_plan
where object_type like 'TABLE%'
and sql_id = '&1')
select t.object_owner owner,
t.object_name table_name,
t.object_type object_type,
decode(stale_stats,'NO','OK',NULL, 'NO STATS!', 'STALE!') staleness
from dba_tab_statistics s,
plan_tables t
where s.table_name = t.object_name
and s.owner = t.object_owner
and s.partition_name is null
and s.subpartition_name is null
order by t.object_owner, t.object_name;
PROMPT ==========
PROMPT Indexes
PROMPT ==========
with plan_indexes as (
select distinct object_name,object_owner, object_type
from dba_hist_sql_plan
where object_type like 'INDEX%'
and sql_id = '&1')
select i.object_owner owner,
i.object_name index_name,
i.object_type object_type,
decode(stale_stats,'NO','OK',NULL, 'NO STATS!', 'STALE!') staleness
from dba_ind_statistics s,
plan_indexes i
where s.index_name = i.object_name
and s.owner = i.object_owner
and s.partition_name is null
and s.subpartition_name is null
order by i.object_owner, i.object_name;
+65
View File
@@ -0,0 +1,65 @@
/*
Syntax: @blockers <where clause> <w.COL1,COL2,...,b.COL1,b.COL2,...,f.COL1,f.COL2...>
w.COLx for waiter cols
b.COLx for blocker cols
f.COLx for final blocker cols
vplesnila 2025-08-29 - creation
*/
col event for a25 trunc
col username for a20
col machine for a30
col osuser for a20
col action for a30
col module for a30
col program2 for a15 trunc heading "Program2"
col program for a25 trunc heading "Program"
col inst_id for 9 head "I#"
col blocking_instance for 9 head "B|I#"
col blocking_session for 9999999 head "B|SID"
col blocking_session_status for a10 head "Blocking|status"
col final_blocking_instance for 9 head "FB|I#"
col final_blocking_session for 9999999 head "FB|SID"
col final_blocking_session_status for a10 head "Final|Blocking|status"
col blocking_serial head "B|serial#"
col final_blocking_serial head "FB|serial#"
col blocked_sess_str for a15 heading "Blocked" justify left
col blocking_sess_str for a15 heading "Blocking" justify left
col final_blocking_sess_str for a15 heading "Final|Blocking" justify left
select
&&2
,w.sid||','||w.serial#||'@'||w.inst_id blocked_sess_str
,w.blocking_session||','||w.blocking_serial||'@'||w.blocking_instance blocking_sess_str
,case
when w.blocking_session=w.final_blocking_session and w.blocking_instance=w.final_blocking_instance then null
else w.final_blocking_session||','||w.final_blocking_serial||'@'||w.final_blocking_instance
end final_blocking_sess_str
from (
select
s1.*
,s2.serial# blocking_serial
,s3.serial# final_blocking_serial
,CASE WHEN s1.type = 'BACKGROUND' OR REGEXP_LIKE(s1.program, '.*\([PJ]\d+\)') THEN
REGEXP_REPLACE(SUBSTR(s1.program,INSTR(s1.program,'(')), '\d', 'n')
ELSE
'('||REGEXP_REPLACE(REGEXP_REPLACE(s1.program, '(.*)@(.*)(\(.*\))', '\1'), '\d', 'n')||')'
END || ' ' program2
from
gv$session s1
inner join gv$session s2 on s1.blocking_session=s2.sid and s1.blocking_instance=s2.inst_id
inner join gv$session s3 on s1.final_blocking_session=s3.sid and s1.final_blocking_instance=s3.inst_id
where
s1.blocking_session is not null
) w
inner join gv$session b on b.sid=w.blocking_session and b.inst_id=w.inst_id
inner join gv$session f on f.sid=w.final_blocking_session and f.inst_id=w.inst_id
where
&&1
order by
final_blocking_sess_str desc,
blocking_sess_str desc
/
+27 -12
View File
@@ -1,13 +1,12 @@
-- Transfer (copy) a SQL Profile from PDBx on CDBa into PDBy on CDBb
SPO coe_xfr_sql_profile.log;
SET DEF ON TERM OFF ECHO ON FEED OFF VER OFF HEA ON LIN 2000 PAGES 100 LONG 8000000 LONGC 800000 TRIMS ON TI OFF TIMI OFF SERVEROUT ON SIZE 1000000 NUMF "" SQLP SQL>;
SET SERVEROUT ON SIZE UNL;
REM
REM $Header: 215187.1 coe_xfr_sql_profile.sql 11.4.5.5 2013/03/01 carlos.sierra $
REM
REM Copyright (c) 2000-2013, Oracle Corporation. All rights reserved.
REM $Header: coe_xfr_sql_profile.sql 2020/03/10 carlos.sierra $
REM
REM AUTHOR
REM carlos.sierra@oracle.com
REM Carlos Sierra
REM
REM SCRIPT
REM coe_xfr_sql_profile.sql
@@ -51,13 +50,17 @@ REM sqlt/utl/sqltprofile.sql
REM 3. Be aware that using DBMS_SQLTUNE requires a license for
REM Oracle Tuning Pack.
REM 4. Use a DBA user but not SYS.
REM 5. If you get "ORA-06532: Subscript outside of limit, ORA-06512: at line 1"
REM Then you may consider this change (only in a test and disposable system):
REM create or replace TYPE sys.sqlprof_attr AS VARRAY(5000) of VARCHAR2(500);
REM
SET TERM ON ECHO OFF;
PRO
PRO Parameter 1:
PRO SQL_ID (required)
PRO
DEF sql_id = '&1';
DEF sql_id = '&1.';
UNDEF 1;
PRO
WITH
p AS (
@@ -69,10 +72,12 @@ SELECT plan_hash_value
SELECT plan_hash_value
FROM dba_hist_sql_plan
WHERE sql_id = TRIM('&&sql_id.')
AND dbid = (SELECT dbid FROM v$database)
AND other_xml IS NOT NULL ),
m AS (
SELECT plan_hash_value,
SUM(elapsed_time)/SUM(executions) avg_et_secs
SUM(elapsed_time)/SUM(executions) avg_et_secs,
SUM(executions) executions
FROM gv$sql
WHERE sql_id = TRIM('&&sql_id.')
AND executions > 0
@@ -80,27 +85,33 @@ SELECT plan_hash_value,
plan_hash_value ),
a AS (
SELECT plan_hash_value,
SUM(elapsed_time_total)/SUM(executions_total) avg_et_secs
SUM(elapsed_time_delta)/SUM(executions_delta) avg_et_secs,
SUM(executions_delta) executions
FROM dba_hist_sqlstat
WHERE sql_id = TRIM('&&sql_id.')
AND executions_total > 0
AND executions_delta > 0
GROUP BY
plan_hash_value )
SELECT p.plan_hash_value,
ROUND(NVL(m.avg_et_secs, a.avg_et_secs)/1e6, 3) avg_et_secs
SELECT
TO_CHAR(ROUND(m.avg_et_secs/1e6, 6), '999,990.000000') avg_et_secs_mem,
TO_CHAR(ROUND(a.avg_et_secs/1e6, 6), '999,990.000000') avg_et_secs_awr,
p.plan_hash_value,
m.executions executions_mem,
a.executions executions_awr
--TO_CHAR(ROUND(NVL(m.avg_et_secs, a.avg_et_secs)/1e6, 6), '999,990.000000') avg_et_secs
FROM p, m, a
WHERE p.plan_hash_value = m.plan_hash_value(+)
AND p.plan_hash_value = a.plan_hash_value(+)
ORDER BY
avg_et_secs NULLS LAST;
NVL(m.avg_et_secs, a.avg_et_secs) NULLS LAST, a.avg_et_secs;
PRO
PRO Parameter 2:
PRO PLAN_HASH_VALUE (required)
PRO
DEF plan_hash_value = '&2';
UNDEF 2;
PRO
PRO Values passed to coe_xfr_sql_profile:
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PRO SQL_ID : "&&sql_id."
PRO PLAN_HASH_VALUE: "&&plan_hash_value."
PRO
@@ -230,6 +241,7 @@ BEGIN
FROM dba_hist_sql_plan
WHERE sql_id = TRIM('&&sql_id.')
AND plan_hash_value = TO_NUMBER(TRIM('&&plan_hash_value.'))
AND dbid = (SELECT dbid FROM v$database)
AND other_xml IS NOT NULL
ORDER BY
id)
@@ -251,6 +263,7 @@ BEGIN
FOR i IN (SELECT other_xml
FROM gv$sql_plan
WHERE plan_hash_value = TO_NUMBER(TRIM('&&plan_hash_value.'))
--WHERE full_plan_hash_value = TO_NUMBER(TRIM('&&plan_hash_value.'))
AND other_xml IS NOT NULL
ORDER BY
child_number, id)
@@ -272,6 +285,8 @@ BEGIN
FOR i IN (SELECT other_xml
FROM dba_hist_sql_plan
WHERE plan_hash_value = TO_NUMBER(TRIM('&&plan_hash_value.'))
--WHERE full_plan_hash_value = TO_NUMBER(TRIM('&&plan_hash_value.'))
AND dbid = (SELECT dbid FROM v$database)
AND other_xml IS NOT NULL
ORDER BY
id)
-1
View File
@@ -4,4 +4,3 @@ prompt To ADD colored <sql_id>: execute DBMS_WORKLOAD_REPOSITORY.ADD_COLORED_
prompt To REMOVE colored <sql_id>: execute DBMS_WORKLOAD_REPOSITORY.REMOVE_COLORED_SQL(sql_id=>'<sql_id>')
prompt
+2
View File
@@ -45,6 +45,8 @@ SELECT MIN(p.snap_id) begin_snap_id, MAX(p.snap_id) end_snap_id
AND s.dbid = p.dbid
AND s.instance_number = p.instance_number;
PROMPT &&begin_snap_id &&end_snap_id
VAR sqlset_name VARCHAR2(30);
EXEC :sqlset_name := REPLACE('s_&&sql_id._&&plan_hash_value._awr', ' ');
+3 -13
View File
@@ -1,17 +1,7 @@
REM $Header: 215187.1 create_spb_from_cur.sql 12.1.02 2013/09/09 carlos.sierra $
-- Create SQL Plan Baseline from SQL Cursor
ACC sql_text_piece PROMPT 'Enter SQL Text piece: '
PROMPT In RAC environement, be sure to be connected to the instance where the SQL_ID is in library cache
SET PAGES 200 LONG 80000 ECHO ON;
COL sql_text PRI;
SELECT sql_id, sql_text /* exclude_me */
FROM v$sqlarea
WHERE sql_text LIKE '%&&sql_text_piece.%'
AND sql_text NOT LIKE '%/* exclude_me */%';
ACC sql_id PROMPT 'Enter SQL_ID: ';
undefine sql_id
define sql_id=&&1
SELECT plan_hash_value, SUM(executions) executions, SUM(elapsed_time) elapsed_time, /* exclude_me */
CASE WHEN SUM(executions) > 0 THEN ROUND(SUM(elapsed_time)/SUM(executions)/1e6, 3) END avg_secs_per_exec
+11
View File
@@ -0,0 +1,11 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
select
TO_CHAR(sysdate, 'yyyy-mm-dd hh24:mi:ss') as "SYSDATE",
(to_date(sysdate) - to_date('01011970','ddmmyyyy')) * 24*60*60 SECONDS_EPOCH,
to_char((to_date(sysdate) - to_date('01011970','ddmmyyyy')) * 24*60*60, 'XXXXXXXX') SEC_HEX,
q'[TIMESTAMP']'||TO_CHAR(sysdate, 'yyyy-mm-dd hh24:mi:ss')||'''' as "SYSDATE_ANSI_TIMESTAMP_SYNTAX"
from
dual
/
+7 -7
View File
@@ -39,18 +39,18 @@ CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
COLUMN comp_id FORMAT a9 HEADING 'Component|ID'
COLUMN comp_name FORMAT a35 HEADING 'Component|Name'
COLUMN version FORMAT a13 HEADING 'Version'
COLUMN status FORMAT a11 HEADING 'Status'
COLUMN comp_id FORMAT a9 HEADING 'Component|ID'
COLUMN comp_name FORMAT a35 HEADING 'Component|Name'
COLUMN version_full FORMAT a13 HEADING 'Version'
COLUMN status FORMAT a11 HEADING 'Status'
COLUMN modified HEADING 'Modified'
COLUMN Schema FORMAT a15 HEADING 'Schema'
COLUMN procedure FORMAT a45 HEADING 'Procedure'
COLUMN Schema FORMAT a15 HEADING 'Schema'
COLUMN procedure FORMAT a45 HEADING 'Procedure'
SELECT
comp_id
, comp_name
, version
, version_full
, status
, modified
, schema
+16
View File
@@ -0,0 +1,16 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
col dblinks_owner head OWNER for a20
col dblinks_db_link head DB_LINK for a40
col dblinks_username head USERNAME for a20
col dblinks_host head HOST for a40
select
owner dblinks_owner,
db_link dblinks_db_link,
username dblinks_username,
host dblinks_host,
created
from
dba_db_links;
+82
View File
@@ -0,0 +1,82 @@
/*
*
* Author : Vishal Gupta
* Purpose : Display DataGuard Statistics
* Parameters : NONE
*
* Revision History:
* ===================
* Date Author Description
* --------- ------------ -----------------------------------------
* 30-Jul-12 Vishal Gupta Created
*
*/
PROMPT *****************************************************************
PROMPT * DataGuard Stats
PROMPT *****************************************************************
COLUMN name HEADING "Name" FORMAT a23
COLUMN value HEADING "Value" FORMAT a20
COLUMN unit HEADING "Unit" FORMAT a30
COLUMN time_computed HEADING "TimeComputed" FORMAT a20
COLUMN datum_time HEADING "datum_time" FORMAT a20
SELECT ds.name
, ds.value
, ds.unit
, ds.time_computed
, ds.datum_time
FROM v$dataguard_stats ds
;
PROMPT
PROMPT
PROMPT *********************************************
PROMPT * R E C O V E R Y P R O G R E S S *
PROMPT *********************************************
COLUMN inst_id HEADING "I#" FORMAT 99
COLUMN start_time HEADING "Start Time" FORMAT a18
COLUMN type HEADING "Type" FORMAT a20
COLUMN item HEADING "Item" FORMAT a25
COLUMN units HEADING "Units" FORMAT a10
COLUMN sofar HEADING "SoFar" FORMAT a45
COLUMN total HEADING "Total" FORMAT 999,999,999,999
COLUMN timestamp HEADING "Start Time" FORMAT a18
COLUMN comments HEADING "Comments" FORMAT a18
SELECT r.inst_id
--, TO_CHAR(r.start_time,'DD-MON-YY HH24:MI:SS') start_time
--, r.type
, r.item
, CASE r.item
WHEN 'Last Applied Redo' THEN TO_CHAR(r.timestamp,'DD-MON-YY HH24:MI:SS') || ' , ' || r.comments
|| chr(10) || 'ApplyLag - ' || REPLACE(REPLACE(TO_CHAR( CAST(sysdate as TIMESTAMP) - CAST( r.timestamp as TIMESTAMP))
,'+0000000','+')
,'.000000','')
WHEN 'Active Time' THEN FLOOR(r.sofar/3600) || 'h ' || FLOOR(MOD(r.sofar,3600)/60) || 'm ' || MOD(r.sofar,60) || 's'
WHEN 'Elapsed Time' THEN FLOOR(r.sofar/3600) || 'h ' || FLOOR(MOD(r.sofar,3600)/60) || 'm ' || MOD(r.sofar,60) || 's'
|| chr(10) || 'StartTime: ' || TO_CHAR(r.start_time,'DD-MON-YY HH24:MI:SS')
ELSE TRIM(TO_CHAR(r.sofar,'999,999,999,999')) || ' ' || r.units
END SoFar
--, r.total
FROM gv$recovery_progress r
WHERE r.start_time = (SELECT MAX(start_time) from gv$recovery_progress)
ORDER BY DECODE(r.item
,'Last Applied Redo',1
,'Standby Apply Lag',2
,'Active Apply Rate',3
,'Average Apply Rate',4
,'Maximum Apply Rate',5
,'Redo Applied',6
,'Log Files',7
,'Apply Time per Log',8
,'Checkpoint Time per Log',9
,'Active Time',21
,'Elapsed Time',22
,999
)
;
+44
View File
@@ -0,0 +1,44 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
SET LiNeSiZe 10000 PageSize 5000
SET TrimOut ON Head Off
-- /**/
-- SELECT
-- LISTAGG
-- (SUBSTR(s,
-- MOD(r2-1,115)+1,1)) WITHIN GROUP(ORDER BY r)
-- FROM(SELECT rownum r,RPAD(RPAD(RPAD(RPAD(LPAD(LPAD
-- ('(',x,'('),20,' '),x+20,')'),40,' '),40+y,' '),50,'W')s FROM(
-- SELECT CEIL(ABS(SIN(rownum/30)*13))x,CEIL(ABS(COS(rownum/9)*5))y
-- FROM dual CONNECT BY LEVEL<=115)), (SELECT rownum r2 FROM (dual)
-- CONNECT BY LEVEL <= 50) GROUP BY MOD(r2-1, 115) +1;
SELECT
CHR(POWER(3,3))
||'[38;5;0m'||LISTAGG(SUBSTR(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(s ,')',
CHR(POWER(3,3))||'[48;5;'||TRIM(TO_CHAR((POWER(2,4)+CEIL((SIN(r2/5) +
SIN(ROWNUM/150)+1)*3-1)+CEIL((-SIN(ROWNUM/150)+1)*3-1)*6+CEIL((COS(ROWNUM/150)+1)*3-1) *6*6),
'099'))||'m)'),'(',CHR(POWER(3,3))||'[48;5;'||TRIM(TO_CHAR((POWER(2,4)+CEIL((SIN(r2/5)+SIN(ROWNUM/150) +1)*3-1)+
CEIL((-SIN(ROWNUM /150)+1)*3-1)*6+CEIL((COS(ROWNUM/150)+1)*3-1)*6*6),'099'))||'m('),' ',CHR(POWER(3,3))||'[48;5;'||TRIM (TO_CHAR(
(POWER(2,4)+CEIL(4)+CEIL(4)*6+CEIL(5-(r2/8))*6*6),'099'))||'m '),'.',CHR(POWER(3,3))||'[48;5;'||TRIM(TO_CHAR((POWER(2,4)+CEIL(5)+CEIL(4)*6+CEIL
(3)*6*6),'099'))||'m~'),'W',CHR(POWER(3,3))||'[48;5;'||TRIM(TO_CHAR((POWER(2,4)+CEIL(4+ABS(SIN(r/25)))+CEIL(2-ABS(SIN (r/5))*2)
*6+CEIL(2-ABS(SIN(r/5))*2)*6*6),'099'))||'m '),(MOD(r2-1,115)+1)*12+1,12))WITHIN GROUP(ORDER BY r)||CHR(POWER (3,3))
||'[0m' v FROM(SELECT ROWNUM r, RPAD(RPAD(RPAD(RPAD(LPAD(LPAD('(',x,'('),20,' '), x+20,')'),40,' '), 40+y,
'.'),50,'W')s FROM (SELECT CEIL(ABS(SIN(ROWNUM/30)*13))x,CEIL(ABS(COS(ROWNUM *
1/DBMS_RANDOM.VALUE(7,7.5))*7))y FROM dual CONNECT BY LEVEL<=115)),
(SELECT ROWNUM r2 FROM dual CONNECT BY LEVEL<=50)
GROUP BY MOD(r2-1,115)+1;
+28 -7
View File
@@ -1,3 +1,5 @@
DEFINE search_string=&1
COLUMN name FORMAT A28 TRUNC
@@ -10,8 +12,6 @@ COLUMN tag FORMAT A20 WORD_WRAP
WITH q AS (
SELECT *
FROM (
SELECT 'otherxml.sql' AS name, 'Display outline hints from library cache' AS description, '@otherxml <sql_id> <child#>
' AS Usage, '@otherxml 1fbwxvngasv1f 1' AS Example, 'outline hint' AS tag FROM dual UNION ALL
SELECT 'sql_profile_hints.sql' AS name, 'Display SQL profile hints' AS description, '@sql_profile_hints.sql <sql_profile>
' AS Usage, '@sql_profile_hints.sql sqlprof_2v4h21kf9bz0h' AS Example, 'sqlprof hint' AS tag FROM dual UNION ALL
SELECT 'awr_sqlid.sql' AS name, 'Display SQL text from AWR' AS description, '@awr_sqlid <sql_id>
@@ -26,8 +26,10 @@ SELECT 'colored_sql_id.sql' AS name, 'Show colored SQL_ID' AS description, 'colo
' AS Usage, '' AS Example, 'color' AS tag FROM dual UNION ALL
SELECT 'xplan.sql' AS name, 'Explain plan from Library Cache' AS description, '@xplan <sql_id> <child_num>
' AS Usage, '@xplan.sql gy2zd0jzw3w6y 0' AS Example, 'explain' AS tag FROM dual UNION ALL
SELECT 'sqlidtabstat.sql' AS name, 'Staleness for tables/indexes in execution plan' AS description, '@sqlidtabstat.sql <sql_id>
' AS Usage, '@sqlidtabstat.sql 2bu78cxnrm4s7' AS Example, 'stale' AS tag FROM dual UNION ALL
SELECT 'sqlidtabstat.sql' AS name, 'Staleness tables/indexes in execution plan from Library Cache' AS description, '@sqlidtabstat.sql <sql_id>
' AS Usage, '@sqlidtabstat.sql 2bu78cxnrm4s7' AS Example, 'stale library cache' AS tag FROM dual UNION ALL
SELECT 'awrsqlidtabstat.sql' AS name, 'Staleness tables/indexes in execution plan from AWR' AS description, '@awrsqlidtabstat.sql <sql_id>
' AS Usage, '@awrsqlidtabstat.sql 2bu78cxnrm4s7' AS Example, 'stale awr' AS tag FROM dual UNION ALL
SELECT 'stale.sql' AS name, 'List DB stale tables' AS description, '@stale.sql
' AS Usage, '' AS Example, 'stale' AS tag FROM dual UNION ALL
SELECT 'tab_details.sql' AS name, 'Table details' AS description, '@tab_details.sql <owner> <table_name>
@@ -56,8 +58,8 @@ SELECT 'create_spb_from_cur.sql' AS name, 'Create SQL Plan Baseline from Library
' AS Usage, '@create_spb_from_cur.sql g3sm89z3xb4zs' AS Example, 'baseline spb' AS tag FROM dual UNION ALL
SELECT 'create_spb_from_awr.sql' AS name, 'Create SQL Plan Baseline from AWR' AS description, '@create_spb_from_awr.sql <sql_id>
' AS Usage, '@create_spb_from_awr.sql g3sm89z3xb4zs' AS Example, 'baseline spb awr' AS tag FROM dual UNION ALL
SELECT 'sql_plan_baselines.sql' AS name, 'List SQL Plan Baselines' AS description, '@sql_plan_baselines.sql
' AS Usage, '' AS Example, 'baseline spb' AS tag FROM dual UNION ALL
SELECT 'sql_plan_baselines.sql' AS name, 'List SQL Plan Baselines' AS description, '@sql_plan_baselines.sql <where_clause>
' AS Usage, '@sql_plan_baselines.sql "1=1"'||chr(10)||'@sql_plan_baselines.sql "accepted=''YES'' and Last_Modified >(sysdate-1)"'||chr(10)||'@sql_plan_baselines.sql "plan_hash_value=237994299"'||chr(10)||'@sql_plan_baselines.sql "sql_id=''g3gwhhx6r00qc''"' AS Example, 'baseline spb' AS tag FROM dual UNION ALL
SELECT 'sqlid_sign.sql' AS name, 'Display force matching signature of SQL_ID' AS description, '@sqlid_sign.sql <sql_id>
' AS Usage, '' AS Example, 'signature' AS tag FROM dual UNION ALL
SELECT 'awrsign.sql' AS name, 'AWR history for this force matching signature' AS description, '@awrsign.sql <force_matching_signature> <from_date> <to_date>
@@ -129,7 +131,25 @@ SELECT 'tpardef.sql' AS name, 'Table only partitions definition' AS description,
SELECT 'sqlid.sql' AS name, 'SQL_ID details from Library Cache' AS description, '@sqlid.sql <SQL_ID> <CHILD_NUMBER>
' AS Usage, '@sqlid.sql a5ks9fhw2v9s1 %'||chr(10)||'@sqlid.sql a5ks9fhw2v9s1 0' AS Example, 'sqlid cache library' AS tag FROM dual UNION ALL
SELECT 'hint.sql' AS name, 'SQL Hint information' AS description, '@hint.sql <hint_pattern>
' AS Usage, '@hint.sql FULL'||chr(10)||'@hint.sql MERGE' AS Example, 'hint' AS tag FROM dual
' AS Usage, '@hint.sql FULL'||chr(10)||'@hint.sql MERGE' AS Example, 'hint' AS tag FROM dual UNION ALL
SELECT 'dblinks.sql' AS name, 'List database links' AS description, 'dblinks.sql
' AS Usage, '@dblinks.sql' AS Example, 'link' AS tag FROM dual UNION ALL
SELECT 'dg_stats.sql' AS name, 'Dataguard Stats' AS description, '@dg_stats.sql
' AS Usage, '@dg_stats.sql' AS Example, 'dataguard standby' AS tag FROM dual UNION ALL
SELECT 'otherxml.sql' AS name, 'Display other_xml value for a SQL_ID' AS description, '@otherxml.sql <sql_id> <child_number>
' AS Usage, '@otherxml.sql a5ks9fhw2v9s1 0' AS Example, 'other_xml otherxml other' AS tag FROM dual UNION ALL
SELECT 'date.sql' AS name, 'Date (sysdate) in different formats' AS description, 'date.sql
' AS Usage, '@date.sql' AS Example, 'date sysdate' AS tag FROM dual UNION ALL
SELECT 'fish.sql' AS name, 'Famous fish script of Tanel Poder' AS description, '@fish.sql
' AS Usage, '@fish.sql' AS Example, 'fish' AS tag FROM dual UNION ALL
SELECT 'blockers.sql' AS name, 'Show blocked sessions and blockers' AS description, '@blockers <where clause> <w.COL1,COL2,...,b.COL1,b.COL2,...,f.COL1,f.COL2...>
' AS Usage, '@blockers 1=1 w.program2,w.sql_id,w.event,b.event,b.program'||chr(10)||'@blockers "w.sql_id=''23k2zf2urpwq0''" w.event,b.event,b.program,b.osuser' AS Example, 'blocker lock' AS tag FROM dual UNION ALL
SELECT 'sed.sql' AS name, 'Show wait event descriptions' AS description, '@sed <event>
' AS Usage, '@sed "%db file%"'||chr(10)||'@sed "PX Deq: Execute Reply"' AS Example, 'event' AS tag FROM dual UNION ALL
SELECT 'xb.sql' AS name, 'Tanel Poder eXplain Better' AS description, '1) alter session set statistics_level = all; (or user GATHER_PLAN_STATISTICS hint instead) 2) Run the statement you want to explain 3) @xb.sql
' AS Usage, '@xb' AS Example, 'explain plan better' AS tag FROM dual UNION ALL
SELECT 'xbi.sql' AS name, 'Tanel Poder eXplain Better for an SQL_ID' AS description, '@xbi <sql_id> <child_number>
' AS Usage, '@xbi 23k2zf2urpwq0 0' AS Example, 'explain sql_id plan better' AS tag FROM dual
)
)
SELECT name,description,usage,example FROM q
@@ -144,3 +164,4 @@ ORDER BY
UNDEFINE search_string
CLEAR COLUMNS
-1
View File
@@ -20,4 +20,3 @@ from v$sql_hint
where lower(name) like lower('%&1%')
/
+46
View File
@@ -0,0 +1,46 @@
set serveroutput ON
declare
sql_text CLOB;
h SYS.SQLPROF_ATTR;
signature NUMBER;
signaturef NUMBER;
begin
/* Replace values as you wish */
h := SYS.SQLPROF_ATTR(
q'[BEGIN_OUTLINE_DATA]',
q'[IGNORE_OPTIM_EMBEDDED_HINTS]',
q'[OPTIMIZER_FEATURES_ENABLE('19.1.0')]',
q'[DB_VERSION('19.1.0')]',
q'[ALL_ROWS]',
q'[OUTLINE_LEAF(@"SEL$1")]',
q'[FULL(@"SEL$1" "D"@"SEL$1")]',
q'[END_OUTLINE_DATA]'
);
select SQL_FULLTEXT into sql_text from gv$sql where sql_id='&&1' and CHILD_NUMBER=0;
signature := DBMS_SQLTUNE.SQLTEXT_TO_SIGNATURE(sql_text);
signaturef := DBMS_SQLTUNE.SQLTEXT_TO_SIGNATURE(sql_text, TRUE);
DBMS_SQLTUNE.IMPORT_SQL_PROFILE (
sql_text => sql_text,
profile => h,
name => 'sqlprof_&&1',
description => 'sqlprof_&&1 '||signature||' '||signaturef||'',
category => 'DEFAULT',
validate => TRUE,
replace => TRUE,
force_match => FALSE /* TRUE:FORCE (match even when different literals in SQL). FALSE:EXACT (similar to CURSOR_SHARING) */ );
exception
when others then
dbms_output.put_line('Getting error: '||sqlerrm);
end;
/
set serveroutput OFF
-2
View File
@@ -54,8 +54,6 @@ def _tpt_tempdir=&SQLPATH/tmp
define day="sysdate-1 sysdate"
define today="TRUNC(sysdate) sysdate"
set errordetails off
-- you should change linesize to match terminal width - 1 only
-- if you don't have a terminal with horizontal scrolling
-- capability (cmd.exe and Terminator terminal do have horizontal scrolling)
+1
View File
@@ -120,3 +120,4 @@ UNDEFINE owner
UNDEFINE object_name
UNDEFINE object_type
UNDEFINE WHERE_CLAUSE
-3
View File
@@ -1,5 +1,3 @@
@@header
/*
Author : Vishal Gupta
@@ -85,4 +83,3 @@ SELECT /*+ RULE */
ORDER BY lk.block desc, s.lockwait desc , s.sid, ob.object_name
/
@@footer
+377
View File
@@ -0,0 +1,377 @@
[
{
"filename": "arch_size_hourly.sql",
"path": "unpack/arch_size_hourly.sql",
"lines": 130
},
{
"filename": "arch_size_hourly_detail.sql",
"path": "unpack/arch_size_hourly_detail.sql",
"lines": 93
},
{
"filename": "arch_switch_hist.sql",
"path": "unpack/arch_switch_hist.sql",
"lines": 81
},
{
"filename": "ash_wait_chains.sql",
"path": "unpack/ash_wait_chains.sql",
"lines": 143
},
{
"filename": "ashtop.sql",
"path": "unpack/ashtop.sql",
"lines": 133
},
{
"filename": "asqlmon.sql",
"path": "unpack/asqlmon.sql",
"lines": 111
},
{
"filename": "awr_snapshot.sql",
"path": "unpack/awr_snapshot.sql",
"lines": 2
},
{
"filename": "awr_sql_binds.sql",
"path": "unpack/awr_sql_binds.sql",
"lines": 131
},
{
"filename": "awr_sqlid.sql",
"path": "unpack/awr_sqlid.sql",
"lines": 12
},
{
"filename": "awrsign.sql",
"path": "unpack/awrsign.sql",
"lines": 55
},
{
"filename": "awrsqlid.sql",
"path": "unpack/awrsqlid.sql",
"lines": 53
},
{
"filename": "awrsqlidtabstat.sql",
"path": "unpack/awrsqlidtabstat.sql",
"lines": 48
},
{
"filename": "blockers.sql",
"path": "unpack/blockers.sql",
"lines": 65
},
{
"filename": "coe_xfr_sql_profile.sql",
"path": "unpack/coe_xfr_sql_profile.sql",
"lines": 499
},
{
"filename": "colored_sql_id.sql",
"path": "unpack/colored_sql_id.sql",
"lines": 6
},
{
"filename": "create_spb_from_awr.sql",
"path": "unpack/create_spb_from_awr.sql",
"lines": 110
},
{
"filename": "create_spb_from_cur.sql",
"path": "unpack/create_spb_from_cur.sql",
"lines": 25
},
{
"filename": "dash_wait_chains.sql",
"path": "unpack/dash_wait_chains.sql",
"lines": 137
},
{
"filename": "dashtop.sql",
"path": "unpack/dashtop.sql",
"lines": 146
},
{
"filename": "dasqlmon.sql",
"path": "unpack/dasqlmon.sql",
"lines": 107
},
{
"filename": "date.sql",
"path": "unpack/date.sql",
"lines": 11
},
{
"filename": "dba_invalid_objects.sql",
"path": "unpack/dba_invalid_objects.sql",
"lines": 63
},
{
"filename": "dba_registry.sql",
"path": "unpack/dba_registry.sql",
"lines": 62
},
{
"filename": "dblinks.sql",
"path": "unpack/dblinks.sql",
"lines": 16
},
{
"filename": "dg_stats.sql",
"path": "unpack/dg_stats.sql",
"lines": 82
},
{
"filename": "fish.sql",
"path": "unpack/fish.sql",
"lines": 44
},
{
"filename": "h.sql",
"path": "unpack/h.sql",
"lines": 167
},
{
"filename": "hint.sql",
"path": "unpack/hint.sql",
"lines": 22
},
{
"filename": "i.sql",
"path": "unpack/i.sql",
"lines": 95
},
{
"filename": "imp_sql_profile.sql",
"path": "unpack/imp_sql_profile.sql",
"lines": 46
},
{
"filename": "init.sql",
"path": "unpack/init.sql",
"lines": 203
},
{
"filename": "locked_objects.sql",
"path": "unpack/locked_objects.sql",
"lines": 123
},
{
"filename": "locks.sql",
"path": "unpack/locks.sql",
"lines": 85
},
{
"filename": "locks_blocking.sql",
"path": "unpack/locks_blocking.sql",
"lines": 96
},
{
"filename": "log.sql",
"path": "unpack/log.sql",
"lines": 10
},
{
"filename": "login.sql",
"path": "unpack/login.sql",
"lines": 11
},
{
"filename": "nonshared.sql",
"path": "unpack/nonshared.sql",
"lines": 60
},
{
"filename": "o.sql",
"path": "unpack/o.sql",
"lines": 39
},
{
"filename": "otherxml.sql",
"path": "unpack/otherxml.sql",
"lines": 13
},
{
"filename": "pardef.sql",
"path": "unpack/pardef.sql",
"lines": 88
},
{
"filename": "planx.sql",
"path": "unpack/planx.sql",
"lines": 1379
},
{
"filename": "raclocks.sql",
"path": "unpack/raclocks.sql",
"lines": 78
},
{
"filename": "recovery_area_usage.sql",
"path": "unpack/recovery_area_usage.sql",
"lines": 66
},
{
"filename": "s.sql",
"path": "unpack/s.sql",
"lines": 83
},
{
"filename": "sed.sql",
"path": "unpack/sed.sql",
"lines": 35
},
{
"filename": "sess.sql",
"path": "unpack/sess.sql",
"lines": 72
},
{
"filename": "sessa.sql",
"path": "unpack/sessa.sql",
"lines": 76
},
{
"filename": "sid_details.sql",
"path": "unpack/sid_details.sql",
"lines": 679
},
{
"filename": "sql_plan_baselines.sql",
"path": "unpack/sql_plan_baselines.sql",
"lines": 71
},
{
"filename": "sql_profile.sql",
"path": "unpack/sql_profile.sql",
"lines": 47
},
{
"filename": "sql_profile_detail.sql",
"path": "unpack/sql_profile_detail.sql",
"lines": 56
},
{
"filename": "sql_profile_hints.sql",
"path": "unpack/sql_profile_hints.sql",
"lines": 35
},
{
"filename": "sqlbinds.sql",
"path": "unpack/sqlbinds.sql",
"lines": 42
},
{
"filename": "sqlid.sql",
"path": "unpack/sqlid.sql",
"lines": 80
},
{
"filename": "sqlid_sign.sql",
"path": "unpack/sqlid_sign.sql",
"lines": 6
},
{
"filename": "sqlidtabstat.sql",
"path": "unpack/sqlidtabstat.sql",
"lines": 48
},
{
"filename": "sqltt_sqlid.sql",
"path": "unpack/sqltt_sqlid.sql",
"lines": 38
},
{
"filename": "stats_getpref_table.sql",
"path": "unpack/stats_getpref_table.sql",
"lines": 37
},
{
"filename": "stats_history.sql",
"path": "unpack/stats_history.sql",
"lines": 273
},
{
"filename": "tab_details.sql",
"path": "unpack/tab_details.sql",
"lines": 360
},
{
"filename": "tabstat.sql",
"path": "unpack/tabstat.sql",
"lines": 46
},
{
"filename": "tbs.sql",
"path": "unpack/tbs.sql",
"lines": 182
},
{
"filename": "tpardef.sql",
"path": "unpack/tpardef.sql",
"lines": 45
},
{
"filename": "tpstat.sql",
"path": "unpack/tpstat.sql",
"lines": 55
},
{
"filename": "transaction_long_running.sql",
"path": "unpack/transaction_long_running.sql",
"lines": 136
},
{
"filename": "tspstat.sql",
"path": "unpack/tspstat.sql",
"lines": 59
},
{
"filename": "unusable.sql",
"path": "unpack/unusable.sql",
"lines": 19
},
{
"filename": "usess.sql",
"path": "unpack/usess.sql",
"lines": 60
},
{
"filename": "wrka.sql",
"path": "unpack/wrka.sql",
"lines": 48
},
{
"filename": "wrkasum.sql",
"path": "unpack/wrkasum.sql",
"lines": 71
},
{
"filename": "xawr.sql",
"path": "unpack/xawr.sql",
"lines": 4
},
{
"filename": "xb.sql",
"path": "unpack/xb.sql",
"lines": 358
},
{
"filename": "xbi.sql",
"path": "unpack/xbi.sql",
"lines": 365
},
{
"filename": "xlast.sql",
"path": "unpack/xlast.sql",
"lines": 4
},
{
"filename": "xplan.sql",
"path": "unpack/xplan.sql",
"lines": 48
}
]
+36 -1
View File
@@ -1,4 +1,39 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
@@o2 "%&1%"
col o_owner heading owner for a25
col o_object_name heading object_name for a30
col o_object_type heading object_type for a20
col o_status heading status for a9
select
owner o_owner,
object_name o_object_name,
object_type o_object_type,
status o_status,
object_id oid,
data_object_id d_oid,
created,
last_ddl_time
from
dba_objects
where
upper(object_name) LIKE
upper(CASE
WHEN INSTR('&1','.') > 0 THEN
SUBSTR('&1',INSTR('&1','.')+1)
ELSE
'&1'
END
)
AND owner LIKE
CASE WHEN INSTR('&1','.') > 0 THEN
UPPER(SUBSTR('&1',1,INSTR('&1','.')-1))
ELSE
user
END
order by
o_object_name,
o_owner,
o_object_type
/
+13
View File
@@ -0,0 +1,13 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
select
xmltype(other_xml)
from
gv$sql_plan
where
sql_id = '&1'
and child_number = TO_NUMBER('&2')
and other_xml is not null
/
+9 -6
View File
@@ -1,10 +1,14 @@
/*
2024-01-27 vplesnila: script creation
*/
set lines 256 pages 50
col TABLE_OWNER for a25 heading "Owner"
col TABLE_NAME for a30 heading "Table"
col OWNER for a25 heading "Owner"
col INDEX_NAME for a30 heading "Index"
col INDEX_TYPE for a10 heading "Type"
col PARTITIONED for a3 heading "Par"
col PARTITION_POSITION for 999 heading "P#"
col PARTITION_NAME for a30 heading "Partition"
@@ -28,7 +32,7 @@ prompt =====
select
par.TABLE_OWNER
,par.TABLE_NAME
,par.PARTITION_POSITION
,par.PARTITION_POSITION
,par.PARTITION_NAME
,par.NUM_ROWS
,par.HIGH_VALUE PART_HIGHVAL
@@ -38,12 +42,12 @@ select
,sub.HIGH_VALUE SUBPART_HIGHVAL
,sub.INTERVAL SUBPART_INTERVAL
from
dba_tab_partitions par
dba_tab_partitions par
left outer join dba_tab_subpartitions sub
on (par.TABLE_OWNER=sub.TABLE_OWNER) and (par.TABLE_NAME=sub.TABLE_NAME) and(par.PARTITION_NAME=sub.PARTITION_NAME)
where
par.table_owner='&&v_table_owner'
and par.table_name='&&v_table_name'
and par.table_name='&&v_table_name'
order by
par.PARTITION_POSITION asc
,sub.SUBPARTITION_POSITION asc
@@ -55,8 +59,7 @@ prompt =====
select
ind.OWNER
,ind.INDEX_NAME
,ind.INDEX_TYPE
,ind.STATUS
,indpar.STATUS
,ind.PARTITIONED
,ind.NUM_ROWS
,ind.DISTINCT_KEYS
-30
View File
@@ -233,7 +233,6 @@ COL p95_cpu_ms FOR A11 HEA 'CPU 95th|Pctl (ms)';
PRO
PRO PLANS PERFORMANCE
PRO ~~~~~~~~~~~~~~~~~
WITH
pm AS (
SELECT plan_hash_value, operation,
@@ -362,7 +361,6 @@ SELECT
PRO
PRO GV$SQLSTATS (it shows only one row for SQL, with most recent info)
PRO ~~~~~~~~~~~
SPO planx_&&sql_id._&&current_time..txt APP;
SELECT inst_id
, plan_hash_value
@@ -402,7 +400,6 @@ SELECT inst_id
BREAK ON inst_id SKIP PAGE ON obj_sta SKIP PAGE ON obsl SKIP PAGE ON shar SKIP PAGE;
PRO
PRO GV$SQL (ordered by inst_id, object_status, is_obsolete, is_shareable, last_active_time and child_number)
PRO ~~~~~~
SPO planx_&&sql_id._&&current_time..txt APP;
SELECT inst_id
, SUBSTR(object_status, 1, 7) obj_sta
@@ -464,7 +461,6 @@ CLEAR BREAKS;
PRO
PRO GV$SQL (grouped by PHV and ordered by et_secs_per_exec)
PRO ~~~~~~
SELECT plan_hash_value
, TO_CHAR(ROUND(SUM(elapsed_time)/SUM(executions)/1e6,6), '999,990.000000') et_secs_per_exec
, TO_CHAR(ROUND(SUM(cpu_time)/SUM(executions)/1e6,6), '999,990.000000') cpu_secs_per_exec
@@ -493,7 +489,6 @@ SELECT plan_hash_value
BREAK ON inst_id SKIP PAGE ON obj_sta SKIP PAGE ON obsl SKIP PAGE ON shar SKIP PAGE;
PRO
PRO GV$SQL (ordered by inst_id, object_status, is_obsolete, is_shareable, last_active_time and child_number)
PRO ~~~~~~
SELECT inst_id
, SUBSTR(object_status, 1, 7) obj_sta
, is_obsolete obsl
@@ -527,7 +522,6 @@ CLEAR BREAKS;
BREAK ON inst_id SKIP PAGE ON obj_sta SKIP PAGE ON obsl SKIP PAGE ON shar SKIP PAGE;
PRO
PRO GV$SQL (ordered by inst_id, object_status, is_obsolete, is_shareable, last_active_time and child_number)
PRO ~~~~~~
SELECT inst_id
, SUBSTR(object_status, 1, 7) obj_sta
, is_obsolete obsl
@@ -553,7 +547,6 @@ CLEAR BREAKS;
PRO
--PRO GV$SQL_PLAN_STATISTICS_ALL LAST (ordered by inst_id and child_number)
PRO GV$SQL_PLAN_STATISTICS_ALL LAST (ordered by child_number)
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PRO
--BREAK ON inst_child_ff SKIP 2;
SET PAGES 0;
@@ -577,7 +570,6 @@ SELECT plan_table_output FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(:sql_id, NULL, 'AD
PRO
PRO DBA_HIST_SQLSTAT DELTA (ordered by snap_id DESC, instance_number and plan_hash_value)
PRO ~~~~~~~~~~~~~~~~~~~~~~
SET PAGES 50;
SPO planx_&&sql_id._&&current_time..txt APP;
SELECT s.snap_id
@@ -629,7 +621,6 @@ SELECT s.snap_id
PRO
PRO DBA_HIST_SQLSTAT TOTAL (ordered by snap_id DESC, instance_number and plan_hash_value)
PRO ~~~~~~~~~~~~~~~~~~~~~~
SPO planx_&&sql_id._&&current_time..txt APP;
SELECT s.snap_id
, TO_CHAR(s.begin_interval_time, 'YYYY-MM-DD"T"HH24:MI:SS') begin_interval_time_ff
@@ -680,7 +671,6 @@ SELECT s.snap_id
PRO
PRO DBA_HIST_SQLSTAT DELTA (ordered by et_secs_per_exec)
PRO ~~~~~~~~~~~~~~~~~~~~~~
SELECT plan_hash_value
, TO_CHAR(ROUND(SUM(elapsed_time_delta)/SUM(executions_delta)/1e6,6), '999,990.000000') et_secs_per_exec
, TO_CHAR(ROUND(SUM(cpu_time_delta)/SUM(executions_delta)/1e6,6), '999,990.000000') cpu_secs_per_exec
@@ -701,7 +691,6 @@ SELECT plan_hash_value
PRO
PRO DBA_HIST_SQL_PLAN (ordered by plan_hash_value)
PRO ~~~~~~~~~~~~~~~~~
BREAK ON plan_timestamp_ff SKIP 2;
SET PAGES 0;
SPO planx_&&sql_id._&&current_time..txt APP;
@@ -722,7 +711,6 @@ CLEAR BREAK;
PRO
PRO GV$ACTIVE_SESSION_HISTORY
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~
DEF x_slices = '10';
SET PAGES 50;
SPO planx_&&sql_id._&&current_time..txt APP;
@@ -762,7 +750,6 @@ SELECT others samples_ff,
PRO
PRO DBA_HIST_ACTIVE_SESS_HISTORY (past 7 days by timed event)
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEF x_days = '7';
SPO planx_&&sql_id._&&current_time..txt APP;
WITH
@@ -812,17 +799,14 @@ SELECT others samples_ff,
PRO
PRO AWR History range considered: from &&x_minimum_date. to &&x_maximum_date.
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PRO
PRO DBA_HIST_ACTIVE_SESS_HISTORY (past 31 days by timed event)
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEF x_days = '31';
SPO planx_&&sql_id._&&current_time..txt APP;
/
PRO
PRO GV$ACTIVE_SESSION_HISTORY
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~
DEF x_slices = '15';
SPO planx_&&sql_id._&&current_time..txt APP;
WITH
@@ -874,7 +858,6 @@ SELECT others samples_ff,
PRO
PRO DBA_HIST_ACTIVE_SESS_HISTORY (past 7 days by plan line and timed event)
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEF x_days = '7';
SPO planx_&&sql_id._&&current_time..txt APP;
WITH
@@ -937,17 +920,14 @@ SELECT others samples_ff,
PRO
PRO AWR History range considered: from &&x_minimum_date. to &&x_maximum_date.
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PRO
PRO DBA_HIST_ACTIVE_SESS_HISTORY (past 31 days by plan line and timed event)
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEF x_days = '31';
SPO planx_&&sql_id._&&current_time..txt APP;
/
PRO
PRO GV$ACTIVE_SESSION_HISTORY
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~
DEF x_slices = '20';
SPO planx_&&sql_id._&&current_time..txt APP;
WITH
@@ -1006,7 +986,6 @@ SELECT others samples_ff,
PRO
PRO DBA_HIST_ACTIVE_SESS_HISTORY (past 7 days by plan line, obj and timed event)
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEF x_days = '7';
SPO planx_&&sql_id._&&current_time..txt APP;
WITH
@@ -1076,17 +1055,14 @@ SELECT others samples_ff,
PRO
PRO AWR History range considered: from &&x_minimum_date. to &&x_maximum_date.
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PRO
PRO DBA_HIST_ACTIVE_SESS_HISTORY (past 31 days by plan line, obj and timed event)
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEF x_days = '31';
SPO planx_&&sql_id._&&current_time..txt APP;
/
PRO
PRO SQL Plan Baselines
PRO ~~~~~~~~~~~~~~~~~~
SPO planx_&&sql_id._&&current_time..txt APP;
SELECT created, plan_name, origin, enabled, accepted, fixed, reproduced, &&is_10g.&&is_11r1.adaptive,
last_executed, last_modified, description
@@ -1100,7 +1076,6 @@ SET HEA ON PAGES 50;
SPO planx_&&sql_id._&&current_time..txt APP;
PRO get list of tables from execution plan
PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VAR tables_list CLOB;
EXEC :tables_list := NULL;
-- get list of tables from execution plan
@@ -1196,7 +1171,6 @@ COL tables_list NEW_V tables_list FOR A32767;
SET HEAD OFF;
PRO
PRO (owner, table) list
PRO ~~~~~~~~~~~~~~~~~~~
SPO planx_&&sql_id._&&current_time..txt APP;
SELECT :tables_list tables_list FROM DUAL
/
@@ -1204,7 +1178,6 @@ SET HEAD ON;
PRO
PRO Tables Accessed
PRO ~~~~~~~~~~~~~~~
COL table_name FOR A50;
COL degree FOR A10;
SPO planx_&&sql_id._&&current_time..txt APP;
@@ -1228,7 +1201,6 @@ SELECT owner||'.'||table_name table_name,
PRO
PRO Indexes
PRO ~~~~~~~
COL table_and_index_name FOR A70;
SPO planx_&&sql_id._&&current_time..txt APP;
SELECT i.table_owner||'.'||i.table_name||' '||i.owner||'.'||i.index_name table_and_index_name,
@@ -1267,7 +1239,6 @@ COL low_value_translated FOR A32;
COL high_value_translated FOR A32;
PRO
PRO Index Columns
PRO ~~~~~~~~~~~~~
SPO planx_&&sql_id._&&current_time..txt APP;
SELECT i.index_owner||'.'||i.index_name||' '||c.column_name index_and_column_name,
c.data_type,
@@ -1338,7 +1309,6 @@ SELECT i.index_owner||'.'||i.index_name||' '||c.column_name index_and_column_nam
PRO
PRO Table Columns
PRO ~~~~~~~~~~~~~
SPO planx_&&sql_id._&&current_time..txt APP;
SELECT c.owner||'.'||c.table_name||' '||c.column_name table_and_column_name,
c.data_type,
+1 -3
View File
@@ -1,7 +1,5 @@
-- https://easyteam.fr/dealing-with-lock-issues-in-oracle-rac-environnement/
@@myheader.sql
col running_session for a20
col machine for a30
col osuser for a20
@@ -77,4 +75,4 @@ rs
JOIN
s ON ltrim(rs.running_session)=s.inst_id || '-' || s.sid;
@@myfooter.sql
+4 -1
View File
@@ -26,6 +26,9 @@ col sw_p3 head P3 for a19 justify left word_wrap
col sw_blocking_session head BLOCKING_SID for a12
col sqlid_and_child for a20
col seq# for 999999
select
sid sw_sid,
sql_id || ' '|| TO_CHAR( sql_child_number ) sqlid_and_child,
@@ -68,7 +71,7 @@ select
ELSE NULL END
ELSE NULL END AS sw_p1transl
FROM
v$session
gv$session
WHERE
sid IN (&1)
ORDER BY
+35
View File
@@ -0,0 +1,35 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
prompt Show wait event descriptions matching &1...
col sed_name head EVENT_NAME for a55
col sed_p1 head PARAMETER1 for a25
col sed_p2 head PARAMETER2 for a25
col sed_p3 head PARAMETER3 for a25
col sed_event# head EVENT# for 99999
col sed_req_description HEAD REQ_DESCRIPTION for a100 WORD_WRAP
col sed_req_reason HEAD REQ_REASON for a32 WRAP
col sed_wait_class HEAD WAIT_CLASS for a20
col sed_eq_name HEAD ENQUEUE_NAME for a30
SELECT
e.event# sed_event#
, e.name sed_name
, e.wait_class sed_wait_class
, e.parameter1 sed_p1
, e.parameter2 sed_p2
, e.parameter3 sed_p3
, s.eq_name sed_eq_name
, s.req_reason sed_req_reason
, s.req_description sed_req_description
-- , e.display_name sed_display_name -- 12c
FROM
v$event_name e
, v$enqueue_statistics s
WHERE
e.event# = s.event# (+)
AND lower(e.name) like lower('&1')
ORDER BY
sed_name
/
+1 -1
View File
@@ -28,7 +28,7 @@ SET ECHO OFF
SET FEEDBACK 6
SET HEADING ON
-- SET LINESIZE 180
-- SET PAGESIZE 50000
SET PAGESIZE 50000
SET TERMOUT ON
SET TIMING OFF
SET TRIMOUT ON
+1 -1
View File
@@ -29,7 +29,7 @@ SET ECHO OFF
SET FEEDBACK 6
SET HEADING ON
-- SET LINESIZE 180
-- SET PAGESIZE 50000
SET PAGESIZE 50000
SET TERMOUT ON
SET TIMING OFF
SET TRIMOUT ON
+10 -6
View File
@@ -473,12 +473,12 @@ COLUMN service_name HEADING "ServiceName" FOR
select 'Blocked By' Block
, s.blocking_instance
, s.blocking_session
, s.blocking_session_status
, s.final_blocking_instance
, s.final_blocking_session
, s.final_blocking_session_status
, s.blocking_instance
, s.blocking_session
, s.blocking_session_status
, s.final_blocking_instance
, s.final_blocking_session
, s.final_blocking_session_status
FROM gv$session s
where s.sid = :SID
AND s.inst_id = :INST_ID
@@ -651,6 +651,8 @@ WHERE ROWNUM <= 10
ORDER BY sql_exec_end
;
set serveroutput on
PROMPT
PROMPT ######### Kill/Disconnect Command ##################
@@ -673,3 +675,5 @@ BEGIN
END;
/
set serveroutput off
+41 -22
View File
@@ -1,37 +1,54 @@
/*
*
* Author : Vishal Gupta
* Purpose : Display all SQL PLAN Baselines
* Parameters :
* vplesnila 2025-05 - creation
* Based on Vishal Gupta script
* and other documents:
* - https://www.linkedin.com/pulse/efficiently-converting-sql-statements-sqlids-oracle-database-pandey-fwmff
* - https://franckpachot.medium.com/oracle-dba-sql-plan-baseline-sql-id-and-plan-hash-value-8ffa811a7c68
*
*
* Revision History:
* ===================
* Date Author Description
* --------- ------------ -----------------------------------------
* 12-Jun-12 Vishal Gupta First created
*
* Usage: @sql_plan_baselines.sql <where_clause>
* Examples:
* @sql_plan_baselines.sql "1=1"
* @sql_plan_baselines.sql "accepted='YES' and Last_Modified >(sysdate-1)"
* @sql_plan_baselines.sql "plan_hash_value=237994299"
* @sql_plan_baselines.sql "sql_id='g3gwhhx6r00qc'"
*/
COLUMN sql_id HEADING "SQL_ID" FORMAT a14
COLUMN sql_handle HEADING "SQL Handle" FORMAT a20
COLUMN plan_hash_value HEADING 'Plan|Hash Value' FORMAT 9999999999
COLUMN plan_name HEADING "Plan Name" FORMAT a30
COLUMN enabled HEADING "Ena|bled" FORMAT a4
COLUMN accepted HEADING "Accep|ted" FORMAT a5
COLUMN fixed HEADING "Fixed" FORMAT a5
COLUMN reproduced HEADING "Repro|duced" FORMAT a5
COLUMN autopurge HEADING "Auto|Purge" FORMAT a5
COLUMN optimizer_cost HEADING "Optimizer|Cost" FORMAT 99999999
COLUMN creator HEADING "Creator" FORMAT a12
COLUMN created HEADING "Created" FORMAT a15
COLUMN last_modified HEADING "LastModified" FORMAT a15
COLUMN last_executed HEADING "LastExecuted" FORMAT a15
COLUMN last_verified HEADING "LastVerified" FORMAT a15
COLUMN creator HEADING "Creator" FORMAT a13
COLUMN created HEADING "Created" FORMAT a19
COLUMN last_modified HEADING "LastModified" FORMAT a19
COLUMN last_executed HEADING "LastExecuted" FORMAT a19
COLUMN last_verified HEADING "LastVerified" FORMAT a19
COLUMN force_matching HEADING "Force|Match" FORMAT a5
COLUMN signature HEADING "Signature" FORMAT 999999999999999999999
COLUMN description HEADING "Description" FORMAT a50
BREAK ON name ON CATEGORY ON created ON last_modified ON type ON status ON force_matching ON signature ON description
SELECT spb.sql_handle
select * from (
SELECT
dbms_sql_translator.sql_id(sql_text) sql_id
,(select
case
when instr(plan_table_output, ':') > 0 then to_number(substr(plan_table_output, instr(plan_table_output, ':', -1) + 1))
else to_number(plan_table_output)
end as last_value
from
(
select * from table(dbms_xplan.DISPLAY_SQL_PLAN_BASELINE(sql_handle,plan_name)) where plan_table_output like 'Plan hash value: %'
)
) plan_hash_value
, spb.sql_handle
, spb.plan_name
, spb.origin
, spb.enabled
@@ -41,12 +58,14 @@ SELECT spb.sql_handle
, spb.autopurge
, spb.optimizer_cost
, spb.creator
, to_char(spb.created,'DD-MON-YY HH24:MI') created
, to_char(spb.last_modified,'DD-MON-YY HH24:MI') last_modified
, to_char(spb.last_executed,'DD-MON-YY HH24:MI') last_executed
, to_char(spb.last_verified,'DD-MON-YY HH24:MI') last_verified
, to_char(spb.created,'YYYY-MM-DD HH24:MI:SS') created
, to_char(spb.last_modified,'YYYY-MM-DD HH24:MI:SS') last_modified
, to_char(spb.last_executed,'YYYY-MM-DD HH24:MI:SS') last_executed
, to_char(spb.last_verified,'YYYY-MM-DD HH24:MI:SS') last_verified
, spb.description
FROM dba_sql_plan_baselines spb
ORDER BY spb.last_modified DESC
)
WHERE
&1
ORDER BY last_modified DESC
;
+2 -1
View File
@@ -1,7 +1,7 @@
/*
*
* Author : Vishal Gupta
* Purpose : Display all SQL Profiles
* Purpose : Display SQL Profiles detail
* Parameters :
*
*
@@ -53,3 +53,4 @@ ORDER BY sp.last_modified DESC
;
set heading on
+42
View File
@@ -0,0 +1,42 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
prompt Show captured binds from GV$SQL_BIND_CAPTURE...
COL sqlbinds_name HEAD NAME FOR A15
COL value_string FOR A100
COL value_anydata FOR A100
COL sqlbinds_pos HEAD POS FOR 9999
COL sqlbinds_chld HEAD CHLD FOR 9999
COL sqlbinds_datatype HEAD DATATYPE FOR A15
BREAK ON sqlbinds_chld SKIP 1
SELECT
-- ADDRESS parent_cursor
-- SQL_ID
CHILD_NUMBER sqlbinds_chld
, POSITION sqlbinds_pos
, NAME sqlbinds_name
--, DUP_POSITION
--, DATATYPE
, DATATYPE_STRING sqlbinds_datatype
, CHARACTER_SID
, MAX_LENGTH
, PRECISION
, SCALE
, VALUE_STRING
, WAS_CAPTURED
, LAST_CAPTURED
, VALUE_ANYDATA
FROM
gv$sql_bind_capture c
WHERE
sql_id like '&1'
AND child_number like '&2'
AND (c.name like '&3' escape '\' OR REGEXP_LIKE(name, '&3', 'i'))
ORDER BY
address
, sql_id
, child_number
, position
/
+6 -2
View File
@@ -13,22 +13,25 @@ col pios_per_exec FOR 9999999999
prompt Show SQL text, child cursors and execution stats for SQLID &1 child &2
select
inst_id,
hash_value,
plan_hash_value,
child_number sql_child_number,
sql_text sql_sql_text
from
v$sql
gv$sql
where
sql_id = ('&1')
and child_number like '&2'
order by
inst_id,
sql_id,
hash_value,
child_number
/
select
inst_id,
child_number sql_child_number,
plan_hash_value plan_hash,
parse_calls parses,
@@ -64,11 +67,12 @@ select
, address parent_handle
, child_address object_handle
from
v$sql
gv$sql
where
sql_id = ('&1')
and child_number like '&2'
order by
inst_id,
sql_id,
hash_value,
child_number
-1
View File
@@ -4,4 +4,3 @@ select FORCE_MATCHING_SIGNATURE from gv$sql where sql_id='&&1'
union all
select FORCE_MATCHING_SIGNATURE from DBA_HIST_SQLSTAT where sql_id='&&1'
fetch first 1 rows only;
-1
View File
@@ -46,4 +46,3 @@ and s.owner = i.object_owner
and s.partition_name is null
and s.subpartition_name is null
order by i.object_owner, i.object_name;
+37
View File
@@ -0,0 +1,37 @@
SET SERVEROUTPUT ON
DECLARE
PROCEDURE display(p_param IN VARCHAR2) AS
l_result VARCHAR2(50);
BEGIN
l_result := DBMS_STATS.get_prefs (pname=>p_param,ownname=>'&1',tabname=>'&2');
DBMS_OUTPUT.put_line(RPAD(p_param, 30, ' ') || ' : ' || l_result);
END;
BEGIN
display('APPROXIMATE_NDV_ALGORITHM');
display('AUTO_STAT_EXTENSIONS');
display('AUTO_TASK_STATUS');
display('AUTO_TASK_MAX_RUN_TIME');
display('AUTO_TASK_INTERVAL');
display('CASCADE');
display('CONCURRENT');
display('DEGREE');
display('ESTIMATE_PERCENT');
display('GLOBAL_TEMP_TABLE_STATS');
display('GRANULARITY');
display('INCREMENTAL');
display('INCREMENTAL_STALENESS');
display('INCREMENTAL_LEVEL');
display('METHOD_OPT');
display('NO_INVALIDATE');
display('OPTIONS');
display('PREFERENCE_OVERRIDES_PARAMETER');
display('PUBLISH');
display('STALE_PERCENT');
display('STAT_CATEGORY');
display('TABLE_CACHED_BLOCKS');
display('STALE_PERCENT');
display('WAIT_TIME_TO_UPDATE_STATS');
END;
/
+1
View File
@@ -357,3 +357,4 @@ SELECT c.owner
)
;
-50
View File
@@ -1,50 +0,0 @@
col owner for a20 head "Owner"
col table_name for a25 head "Table name"
col PARTITION_NAME for a25 head "Partition name"
col SUBPARTITION_NAME for a25 head "Subpartition name"
col last_DML for a20 head "Last DML"
col last_analyzed for a20 head "Last Analyzed"
col STALE_STATS for a7 head "Stale"
col NUM_ROWS head "#Rows"
col INSERTS head "Table|INS"
col UPDATES head "Table|UPD"
col DELETES head "Table|DEL"
col TRUNCATED head "Table|TRUN"
break on report skip 1
compute sum of INSERTS on report
compute sum of UPDATES on report
compute sum of DELETES on report
select
tabstat.OWNER
,tabstat.TABLE_NAME
,tabstat.PARTITION_NAME
,tabstat.SUBPARTITION_NAME
,tabstat.NUM_ROWS
,tabstat.STALE_STATS
,tabstat.LAST_ANALYZED
,tabmod.INSERTS
,tabmod.UPDATES
,tabmod.DELETES
,tabmod.TRUNCATED
,tabmod.TIMESTAMP last_DML
from
dba_tab_statistics tabstat
,dba_tab_modifications tabmod
WHERE
tabstat.owner = '&&1'
AND tabstat.table_name = '&&2'
AND (tabstat.partition_name like '%&&3%' or tabstat.partition_name is NULL)
AND (tabstat.subpartition_name like '%&&4%' or tabstat.subpartition_name is NULL)
AND tabstat.owner = tabmod.table_owner(+)
AND tabstat.table_name = tabmod.table_name(+)
AND tabstat.partition_name = tabmod.partition_name(+)
AND tabstat.subpartition_name = tabmod.subpartition_name(+)
ORDER BY
tabstat.owner asc,
tabstat.table_name asc,
tabstat.partition_position asc,
tabstat.subpartition_position asc
/
+7 -4
View File
@@ -1,3 +1,7 @@
/*
2024-01-27 vplesnila: script creation
*/
col TABLE_OWNER for a25 heading "Owner"
col TABLE_NAME for a30 heading "Table"
col OWNER for a25 heading "Owner"
@@ -19,7 +23,7 @@ define v_table_name=&&2
select
par.TABLE_OWNER
,par.TABLE_NAME
,par.PARTITION_POSITION
,par.PARTITION_POSITION
,par.PARTITION_NAME
,par.NUM_ROWS
,par.HIGH_VALUE PART_HIGHVAL
@@ -29,14 +33,13 @@ select
,sub.HIGH_VALUE SUBPART_HIGHVAL
,sub.INTERVAL SUBPART_INTERVAL
from
dba_tab_partitions par
dba_tab_partitions par
left outer join dba_tab_subpartitions sub
on (par.TABLE_OWNER=sub.TABLE_OWNER) and (par.TABLE_NAME=sub.TABLE_NAME) and(par.PARTITION_NAME=sub.PARTITION_NAME)
where
par.table_owner='&&v_table_owner'
and par.table_name='&&v_table_name'
and par.table_name='&&v_table_name'
order by
par.PARTITION_POSITION asc
,sub.SUBPARTITION_POSITION asc
;
+2 -2
View File
@@ -26,7 +26,7 @@ compute sum of DELETES on report
select
tabstat.OWNER
,tabstat.TABLE_NAME
,tabstat.PARTITION_POSITION
,tabstat.PARTITION_POSITION
,tabstat.PARTITION_NAME
,tabstat.NUM_ROWS
,tabstat.STALE_STATS
@@ -42,7 +42,7 @@ from
WHERE
tabstat.owner = '&&1'
AND tabstat.table_name = '&&2'
AND (tabstat.partition_name like '%&&3%' or tabstat.partition_name is NULL)
AND (tabstat.partition_name like '%&&3%' or tabstat.partition_name is NULL)
AND tabstat.owner = tabmod.table_owner(+)
AND tabstat.table_name = tabmod.table_name(+)
AND tabstat.partition_name = tabmod.partition_name(+)
+1
View File
@@ -79,6 +79,7 @@ COLUMN locked_mode HEADING "Lock Mode" FORMAT a10
COLUMN object_name HEADING "ObjectName" FORMAT a35
SELECT
-- t.xid xid
--, t.ptx_xid
+5 -5
View File
@@ -5,8 +5,8 @@
vplesnila 2024-01-29: creation
*/
col owner for a20 head "Owner"
col table_name for a25 head "Table name"
col owner for a20 head "Owner"
col table_name for a25 head "Table name"
col PARTITION_POSITION for 999 heading "P#"
col PARTITION_NAME for a25 head "Partition name"
col SUBPARTITION_NAME for a25 head "Subpartition name"
@@ -27,7 +27,7 @@ compute sum of DELETES on report
select
tabstat.OWNER
,tabstat.TABLE_NAME
,tabstat.PARTITION_POSITION
,tabstat.PARTITION_POSITION
,tabstat.PARTITION_NAME
,tabstat.SUBPARTITION_NAME
,tabstat.NUM_ROWS
@@ -44,8 +44,8 @@ from
WHERE
tabstat.owner = '&&1'
AND tabstat.table_name = '&&2'
AND (tabstat.partition_name like '%&&3%' or tabstat.partition_name is NULL)
AND (tabstat.subpartition_name like '%&&4%' or tabstat.subpartition_name is NULL)
AND (tabstat.partition_name like '%&&3%' or tabstat.partition_name is NULL)
AND (tabstat.subpartition_name like '%&&4%' or tabstat.subpartition_name is NULL)
AND tabstat.owner = tabmod.table_owner(+)
AND tabstat.table_name = tabmod.table_name(+)
AND tabstat.partition_name = tabmod.partition_name(+)
+19
View File
@@ -0,0 +1,19 @@
col OWNER for a30
col INDEX_OWNER for a30
col INDEX_NAME for a30
col PARTITION_NAME for a30
col SUBPARTITION_NAME for a30
select OWNER,INDEX_NAME from dba_indexes where STATUS='UNUSABLE';
select INDEX_OWNER,INDEX_NAME,PARTITION_NAME from dba_ind_partitions where STATUS='UNUSABLE';
select INDEX_OWNER,INDEX_NAME,SUBPARTITION_NAME from dba_ind_subpartitions where STATUS='UNUSABLE';
select distinct status from dba_indexes
union
select distinct status from dba_ind_partitions
union
select distinct status from dba_ind_subpartitions
/
+7 -8
View File
@@ -1,5 +1,5 @@
/*
based on Jeffrey M. Hunter jhunter@idevelopment.info script / www.idevelopment.info
based on Jeffrey M. Hunter jhunter@idevelopment.info script / www.idevelopment.info
*/
SET ECHO OFF
@@ -48,14 +48,13 @@ SELECT
, s.module module
, s.action action
FROM
gv$session s
INNER JOIN gv$process p ON (s.paddr = p.addr AND s.inst_id = p.inst_id)
INNER JOIN gv$instance i ON (p.inst_id = i.inst_id)
gv$session s
INNER JOIN gv$process p ON (s.paddr = p.addr AND s.inst_id = p.inst_id)
INNER JOIN gv$instance i ON (p.inst_id = i.inst_id)
WHERE
(&1)
AND s.username IS NOT null
AND s.username not in ('SYS','SYSRAC')
(&1)
AND s.username IS NOT null
AND s.username not in ('SYS','SYSRAC')
ORDER BY
i.instance_name
, s.sid;
+9 -5
View File
@@ -15,6 +15,10 @@
prompt Show Active workarea memory usage for where &1....
COL wrka_operation_type HEAD OPERATION_TYPE FOR A30
col actual_mem_used for 999,999.99
col max_mem_used for 999,999.99
col work_area_size for 999,999.99
col tempseg_size_MB for 999,999.99
SELECT
inst_id
@@ -22,16 +26,16 @@ SELECT
, qcinst_id
, qcsid
, sql_id
-- , sql_exec_start -- 11g+
, sql_exec_start
, operation_type wrka_operation_type
, operation_id plan_line
, policy
, ROUND(active_time/1000000,1) active_sec
, actual_mem_used
, max_mem_used
, work_area_size
, actual_mem_used/1024/1024 actual_mem_used
, max_mem_used/1024/1024 max_mem_used
, work_area_size/1024/1024 work_area_size
, number_passes
, tempseg_size
, tempseg_size/1024/1024 tempseg_size_MB
, tablespace
FROM
gv$sql_workarea_active
+358
View File
@@ -0,0 +1,358 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
--------------------------------------------------------------------------------
--
-- File name: xb (eXplain Better)
--
-- Purpose: Explain a SQL statements execution plan with execution
-- profile directly from library cache - for the last
-- SQL executed in current session (see also xbi.sql)
--
-- Author: Tanel Poder
-- Copyright: (c) https://blog.tanelpoder.com
--
-- Usage: 1) alter session set statistics_level = all;
-- 2) Run the statement you want to explain
-- 3) @xb.sql
--
-- Other: You can add a GATHER_PLAN_STATISTICS hint to the statement instead
-- if you dont want to use "alter session set statistics_level"
-- for some reason (this hint works on Oracle 10.2 and higher)
--
-- TODO: Noteworthy outstanding items are:
-- * formatting, decide what columns to show by default
-- * clone to an @xbx.sql (eXtended version) with wider output and stuff like plan outline hints shown etc
-- currently you can just comment/uncomment sections in this script
-- * clone to @xbad.sql for showing full adaptive plans
-- * add an option to gather/report metrics of all PX slaves
--
--------------------------------------------------------------------------------
prompt -- xb.sql: eXplain Better v1.01 for prev SQL in the current session - by Tanel Poder (https://blog.tanelpoder.com)
set verify off pagesize 5000 tab off lines 999
column xbi_child_number heading "Ch|ld" format 999
column xbi_sql_id heading "SQL_ID" for a13
column xbi_sql_child_number heading "CHLD" for 9999
column xbi_sql_addr heading "ADDRESS"
column xbi_sql_id_text heading ""
column xbi_seconds_ago heading "First Load Time"
column xbi_id heading "Op|ID" for 9999 justify right
column xbi_parent_id heading "Par.|ID" for 9999 justify right
column xbi_id2 heading "Op|ID" for a5 justify right
column xbi_pred heading "Pred|#Col" for a5 justify right
column xbi_pos heading "#Sib|ling" for 9999
column xbi_optimizer heading "Optimizer|Mode" format a10
column xbi_plan_step heading "Operation" for a55
column xbi_plan_line heading "Row Source" for a72
column xbi_qblock_name heading "Query Block|name" for a20 PRINT
column xbi_object_name heading "Object|Name" for a30
column xbi_object_node heading "Object|Node" for a10
column xbi_opt_cost heading "Optimizer|Cost" for 9999999999
column xbi_opt_card heading "Est. rows|per Start" for 999999999999
column xbi_opt_card_times_starts heading "Est. rows|total" for 999999999999
column xbi_opt_card_misestimate heading "Opt. Card.|misestimate" for a15 justify right
column xbi_opt_bytes heading "Estimated|output bytes" for 999999999999
column xbi_predicate_info heading "Predicate Information (identified by operation id):" format a100 word_wrap
column xbi_cpu_cost heading "CPU|Cost" for 9999999
column xbi_io_cost heading "IO|Cost" for 9999999
column xbi_last_output_rows heading "Real #rows|returned" for 9999999999
column xbi_last_starts heading "Rowsource|starts" for 999999999
column xbi_last_rows_start heading "#Rows ret/|per start" for 999999999
column xbi_last_cr_buffer_gets heading "Consistent|gets" for 999999999
column xbi_last_cr_buffer_gets_row heading "Consistent|gets/row" for 999999999
column xbi_last_cu_buffer_gets heading "Current|gets" for 999999999
column xbi_last_cu_buffer_gets_row heading "Current|gets/row" for 999999999
column xbi_last_disk_reads heading "Physical|read blks" for 999999999
column xbi_last_disk_writes heading "Physical|write blks" for 999999999
column xbi_last_elapsed_time_ms heading "cumulative ms|spent in branch" for 9,999,999.99 noprint
column xbi_self_elapsed_time_ms heading "ms spent in|this operation" for 9,999,999.99
column xbi_self_cr_buffer_gets heading "Consistent|gets" for 999999999
column xbi_self_cr_buffer_gets_row heading "Consistent|gets/row" for 999999999
column xbi_self_cu_buffer_gets heading "Current|gets" for 999999999
column xbi_self_cu_buffer_gets_row heading "Current|gets/row" for 999999999
column xbi_self_disk_reads heading "Physical|read blks" for 999999999
column xbi_self_disk_writes heading "Physical|write blks" for 999999999
column xbi_last_memory_used heading "Memory|used (MB)" for 9,999,999.99
column xbi_last_execution heading "Workarea|Passes" for a13
column xbi_sql_plan_hash_value heading "Plan Hash Value" for 9999999999
column xbi_plan_hash_value_text noprint
column xbi_outline_hints heading "Outline Hints" for a120 word_wrap
column xbi_notes heading "Plan|Notes" for a120 word_wrap
column xbi_sql_id heading "SQL_ID" for a13 new_value xbi_sql_id
column xbi_sql_child_number heading "CHLD" for 9999 new_value xbi_sql_child_number
column xbi_sql_addr heading "ADDRESS" new_value xbi_sql_addr
set feedback off
select
'Cursor: ' xbi_sql_id_text,
sql.sql_id xbi_sql_id,
sql.child_number xbi_sql_child_number,
sql.address xbi_sql_addr,
' PLAN_HASH_VALUE: ' xbi_plan_hash_value_text,
sql.plan_hash_value xbi_sql_plan_hash_value,
'Statement first parsed at: '|| sql.first_load_time ||' - '||
round( (sysdate - to_date(sql.first_load_time,'YYYY-MM-DD/HH24:MI:SS'))*86400 ) || ' seconds ago' xbi_seconds_ago
from
v$sql sql,
all_users usr
where
sql.parsing_user_id = usr.user_id
and (sql.sql_id,sql.child_number,sql.address) = (SELECT prev_sql_id,prev_child_number,prev_sql_addr
FROM v$session WHERE sid = USERENV('SID'))
/
WITH sq AS (
SELECT
sp.id, sp.parent_id, sp.operation, sp.options, sp.object_owner, sp.object_name
, ss.last_elapsed_time, ss.last_cr_buffer_gets, ss.last_cu_buffer_gets, ss.last_disk_reads, ss.last_disk_writes
FROM v$sql_plan_statistics_all ss INNER JOIN
v$sql_plan sp
ON (
sp.sql_id=ss.sql_id
AND sp.child_number=ss.child_number
AND sp.address=ss.address
AND sp.id=ss.id
)
AND sp.sql_id='&xbi_sql_id'
AND sp.child_number = TO_NUMBER('&xbi_sql_child_number')
AND sp.address = hextoraw('&xbi_sql_addr')
), deltas AS (
SELECT
par.id
, par.last_elapsed_time - SUM(chi.last_elapsed_time ) self_elapsed_time
, par.last_cr_buffer_gets - SUM(chi.last_cr_buffer_gets) self_cr_buffer_gets
, par.last_cu_buffer_gets - SUM(chi.last_cu_buffer_gets) self_cu_buffer_gets
, par.last_disk_reads - SUM(chi.last_disk_reads ) self_disk_reads
, par.last_disk_writes - SUM(chi.last_disk_writes ) self_disk_writes
FROM sq par LEFT OUTER JOIN
sq chi
ON chi.parent_id = par.id
GROUP BY
par.id
, par.last_elapsed_time, par.last_cr_buffer_gets, par.last_cu_buffer_gets, par.last_disk_reads, par.last_disk_writes
), combined AS (
SELECT sq.id, sq.parent_id, sq.operation, sq.options
, sq.object_owner, sq.object_name
, sq.last_elapsed_time
, sq.last_cr_buffer_gets
, sq.last_cu_buffer_gets
, sq.last_disk_reads
, sq.last_disk_writes
, NVL(deltas.self_elapsed_time , sq.last_elapsed_time) self_elapsed_time
, NVL(deltas.self_cr_buffer_gets , sq.last_cr_buffer_gets) self_cr_buffer_gets
, NVL(deltas.self_cu_buffer_gets , sq.last_cu_buffer_gets) self_cu_buffer_gets
, NVL(deltas.self_disk_reads , sq.last_disk_reads) self_disk_reads
, NVL(deltas.self_disk_writes , sq.last_disk_writes) self_disk_writes
FROM
sq, deltas
WHERE
sq.id = deltas.id
),
adaptive_display_map AS (
SELECT
TO_NUMBER(EXTRACT(column_value, '/row/@op' )) id
, TO_NUMBER(EXTRACT(column_value, '/row/@par')) parent_id
, TO_NUMBER(EXTRACT(column_value, '/row/@dis')) display_id
, TO_NUMBER(EXTRACT(column_value, '/row/@dep')) depth
, TO_NUMBER(EXTRACT(column_value, '/row/@skp')) skip
FROM
v$sql_plan
, TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(other_xml),'/*/display_map/row')))
WHERE
sql_id = '&xbi_sql_id'
AND child_number = TO_NUMBER('&xbi_sql_child_number')
AND address = hextoraw('&xbi_sql_addr')
AND other_xml IS NOT NULL
)
select
LPAD(
CASE WHEN p.filter_predicates IS NOT NULL THEN 'F' ELSE ' ' END ||
CASE WHEN p.access_predicates IS NOT NULL THEN CASE WHEN p.options LIKE 'STORAGE %' THEN 'S' ELSE 'A' END ELSE '' END ||
CASE p.search_columns WHEN 0 THEN NULL ELSE '#'||TO_CHAR(p.search_columns) END
, 5) xbi_pred,
NVL(CASE WHEN adm.skip IS NULL THEN NULL
WHEN adm.skip = 0 THEN adm.display_id
WHEN adm.skip = 1 THEN NULL
END
, p.id) xbi_id,
nvl(adm2.parent_id, p.parent_id) xbi_parent_id,
CASE WHEN p.id != 0 THEN p.position END xbi_pos,
LPAD(' ',NVL(adm.depth,p.depth),' ')|| p.operation || ' ' || p.options ||' '
||nvl2(p.object_name, '['||p.object_name||']', null)
xbi_plan_line,
CASE WHEN p.id = 0 THEN '>>> Plan totals >>>' ELSE p.qblock_name END xbi_qblock_name,
-- p.object_node xbi_object_node,
-- p.distribution xbi_distribution,
-- lpad(decode(p.id,0,'T ','')||trim(to_char(round(decode(p.id,0,c.last_elapsed_time,c.self_elapsed_time) /1000,2),'9,999,999.00')), 14) xbi_self_elapsed_time_ms,
round(decode(p.id,0,c.last_elapsed_time,c.self_elapsed_time) /1000,2) xbi_self_elapsed_time_ms,
decode(p.id,0,c.last_cr_buffer_gets,c.self_cr_buffer_gets) xbi_self_cr_buffer_gets,
ps.last_starts xbi_last_starts,
ps.last_output_rows xbi_last_output_rows,
p.cardinality * ps.last_starts xbi_opt_card_times_starts,
regexp_replace(lpad(to_char(round(
CASE WHEN (DECODE(ps.last_output_rows,0,1,ps.last_output_rows) / DECODE(p.cardinality*ps.last_starts,0,1,p.cardinality*ps.last_starts)) > 1 THEN -(DECODE(ps.last_output_rows,0,1,ps.last_output_rows) / DECODE(p.cardinality*ps.last_starts,0,1,p.cardinality*ps.last_starts))
WHEN (DECODE(ps.last_output_rows,0,1,ps.last_output_rows) / DECODE(p.cardinality*ps.last_starts,0,1,p.cardinality*ps.last_starts)) < 1 THEN 1/(DECODE(ps.last_output_rows,0,1,ps.last_output_rows) / DECODE(p.cardinality*ps.last_starts,0,1,p.cardinality*ps.last_starts))
WHEN (DECODE(ps.last_output_rows,0,1,ps.last_output_rows) / DECODE(p.cardinality*ps.last_starts,0,1,p.cardinality*ps.last_starts)) = 1 THEN 1
ELSE null
END
,0))||'x',15),'^ *x$') xbi_opt_card_misestimate,
-- c.self_cr_buffer_gets xbi_self_cr_buffer_gets,
-- c.self_cr_buffer_gets / DECODE(ps.last_output_rows,0,1,ps.last_output_rows) xbi_self_cr_buffer_gets_row,
decode(p.id,0,c.last_cu_buffer_gets,c.self_cu_buffer_gets) xbi_self_cu_buffer_gets,
-- c.self_cu_buffer_gets / DECODE(ps.last_output_rows,0,1,ps.last_output_rows) xbi_self_cu_buffer_gets_row,
decode(p.id,0,c.last_disk_reads,c.self_disk_reads) xbi_self_disk_reads,
decode(p.id,0,c.last_disk_writes,c.self_disk_writes) xbi_self_disk_writes,
round(ps.last_elapsed_time/1000,2) xbi_last_elapsed_time_ms,
-- ps.last_cr_buffer_gets xbi_last_cr_buffer_gets,
-- ps.last_cr_buffer_gets / DECODE(ps.last_output_rows,0,1,ps.last_output_rows) xbi_last_cr_buffer_gets_row,
-- ps.last_cu_buffer_gets xbi_last_cu_buffer_gets,
-- ps.last_cu_buffer_gets / DECODE(ps.last_output_rows,0,1,ps.last_output_rows) xbi_last_cu_buffer_gets_row,
-- ps.last_disk_reads xbi_last_disk_reads,
-- ps.last_disk_writes xbi_last_disk_writes,
ps.last_memory_used/1048576 xbi_last_memory_used,
ps.last_execution xbi_last_execution,
p.cost xbi_opt_cost
-- p.bytes xbi_opt_bytes,
-- p.cpu_cost xbi_cpu_cost,
-- p.io_cost xbi_io_cost,
-- p.other_tag,
-- p.other,
-- p.access_predicates,
-- p.filter_predicates,
from
v$sql_plan p
, v$sql_plan_statistics_all ps
, combined c
, adaptive_display_map adm
, adaptive_display_map adm2
where
p.address = ps.address (+)
and p.sql_id = ps.sql_id (+)
and p.plan_hash_value = ps.plan_hash_value (+)
and p.child_number = ps.child_number (+)
and p.id = ps.id (+)
and p.id = adm.id (+)
and adm.id = adm2.id (+)
and (adm.id IS NULL or adm.skip = 0)
and p.sql_id = '&xbi_sql_id'
and p.address = hextoraw('&xbi_sql_addr')
and p.child_number = TO_NUMBER(&xbi_sql_child_number)
and ps.id = c.id (+)
order by
p.id asc
/
WITH adaptive_display_map AS (
SELECT
TO_NUMBER(EXTRACT(column_value, '/row/@op' )) id
, TO_NUMBER(EXTRACT(column_value, '/row/@dis')) display_id
, TO_NUMBER(EXTRACT(column_value, '/row/@skp')) skip
FROM
v$sql_plan
, TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(other_xml),'/*/display_map/row')))
WHERE
sql_id = '&xbi_sql_id'
AND child_number = TO_NUMBER('&xbi_sql_child_number')
AND address = hextoraw('&xbi_sql_addr')
AND other_xml IS NOT NULL
AND TO_NUMBER(EXTRACT(column_value, '/row/@skp')) != 1
)
select
xbi_id2,
xbi_qblock_name,
substr(dummy,1,0)||'-' " ", -- there's an ugly reason (bug) for this hack
xbi_predicate_info
from (
select
sp.sql_id xbi_sql_id,
LPAD(NVL(CASE WHEN adm.skip IS NULL THEN NULL
WHEN adm.skip = 0 THEN adm.display_id
WHEN adm.skip = 1 THEN NULL
END
, sp.id), 5, ' ') xbi_id2,
sp.filter_predicates dummy, -- looks like there's a bug in 11.2.0.3 where both pred cols have to be selected
CASE WHEN sp.options LIKE 'STORAGE %' THEN 'storage' ELSE 'access' END||'('|| substr(sp.access_predicates,1,3989) || ')' xbi_predicate_info,
sp.qblock_name xbi_qblock_name
from
v$sql_plan sp
, adaptive_display_map adm
where
sp.sql_id = '&xbi_sql_id'
and sp.child_number = TO_NUMBER(&xbi_sql_child_number)
AND sp.address = HEXTORAW('&xbi_sql_addr')
and sp.access_predicates is not null
and sp.id = adm.id (+)
union all
select
sp.sql_id xbi_sql_id,
--lpad(sp.id, 5, ' ') xbi_id2,
LPAD(NVL(CASE WHEN adm.skip IS NULL THEN NULL
WHEN adm.skip = 0 THEN adm.display_id
WHEN adm.skip = 1 THEN NULL
END
, sp.id), 5, ' ') xbi_id2,
sp.access_predicates dummy,
'filter('|| substr(sp.filter_predicates,1,3989) || ')' xbi_predicate_info,
sp.qblock_name xbi_qblock_name
from
v$sql_plan sp
, adaptive_display_map adm
where
sp.sql_id = '&xbi_sql_id'
and sp.child_number = TO_NUMBER(&xbi_sql_child_number)
and sp.address = HEXTORAW('&xbi_sql_addr')
and sp.filter_predicates is not null
and sp.id = adm.id (+)
)
order by
xbi_id2 asc,
xbi_predicate_info asc
/
-- this query can return ORA-600 in Oracle 10.2 due to Bug 5497611 - OERI[qctVCO:csform] from Xquery using XMLType constructor (Doc ID 5497611.8)
WITH sq AS (
SELECT other_xml
FROM v$sql_plan p
WHERE
p.sql_id = '&xbi_sql_id'
AND p.child_number = &xbi_sql_child_number
AND p.address = hextoraw('&xbi_sql_addr')
AND p.other_xml IS NOT NULL -- (the other_xml is not guaranteed to always be on plan line 1)
)
SELECT ' *' " ", 'Cardinality feedback = yes' xbi_notes FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "cardinality_feedback"]') = 'yes'
UNION ALL SELECT ' *', 'SQL Stored Outline used = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "outline"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "outline"]') IS NOT NULL
UNION ALL SELECT ' *', 'SQL Patch used = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "sql_patch"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "sql_patch"]') IS NOT NULL
UNION ALL SELECT ' *', 'SQL Profile used = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "sql_profile"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "sql_profile"]') IS NOT NULL
UNION ALL SELECT ' *', 'SQL Plan Baseline used = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "baseline"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "baseline"]') IS NOT NULL
UNION ALL SELECT ' *', 'Adaptive Plan = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "adaptive_plan"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "adaptive_plan"]') IS NOT NULL
/
-- === Outline Hints ===
WITH sq AS (
SELECT other_xml
FROM v$sql_plan p
WHERE
p.sql_id = '&xbi_sql_id'
AND p.child_number = &xbi_sql_child_number
AND p.address = hextoraw('&xbi_sql_addr')
AND p.other_xml IS NOT NULL
)
SELECT
SUBSTR(EXTRACTVALUE(VALUE(d), '/hint'),1,4000) xbi_outline_hints
FROM
sq
, TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(sq.other_xml), '/*/outline_data/hint'))) D
/
set feedback on
PROMPT
+365
View File
@@ -0,0 +1,365 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
--------------------------------------------------------------------------------
--
-- File name: xb (eXplain Better)
--
-- Purpose: Explain a SQL statements execution plan with execution
-- profile directly from library cache - for the last
-- SQL executed in current session (see also xbi.sql)
--
-- Author: Tanel Poder
-- Copyright: (c) https://blog.tanelpoder.com
--
-- Usage: 1) alter session set statistics_level = all;
-- 2) Run the statement you want to explain
-- 3) @xb.sql
--
-- Other: You can add a GATHER_PLAN_STATISTICS hint to the statement instead
-- if you dont want to use "alter session set statistics_level"
-- for some reason (this hint works on Oracle 10.2 and higher)
--
-- TODO: Noteworthy outstanding items are:
-- * formatting, decide what columns to show by default
-- * clone to an @xbx.sql (eXtended version) with wider output and stuff like plan outline hints shown etc
-- currently you can just comment/uncomment sections in this script
-- * clone to @xbad.sql for showing full adaptive plans
-- * add an option to gather/report metrics of all PX slaves
--
--------------------------------------------------------------------------------
def xbi_sql_id=&1
def xbi_sql_child_number=&2
def xbi_sql_addr="TODO"
prompt -- xbi.sql: eXplain Better v1.01 for sql_id=&xbi_sql_id child=&xbi_sql_child_number - by Tanel Poder (https://blog.tanelpoder.com)
set verify off pagesize 5000 tab off lines 999
column xbi_child_number heading "Ch|ld" format 999
column xbi_sql_id heading "SQL_ID" for a13
column xbi_sql_child_number heading "CHLD" for 9999
column xbi_sql_addr heading "ADDRESS"
column xbi_sql_id_text heading ""
column xbi_seconds_ago heading "First Load Time"
column xbi_id heading "Op|ID" for 9999 justify right
column xbi_parent_id heading "Par.|ID" for 9999 justify right
column xbi_id2 heading "Op|ID" for a5 justify right
column xbi_pred heading "Pred|#Col" for a5 justify right
column xbi_pos heading "#Sib|ling" for 9999
column xbi_optimizer heading "Optimizer|Mode" format a10
column xbi_plan_step heading "Operation" for a55
column xbi_plan_line heading "Row Source" for a72
column xbi_qblock_name heading "Query Block|name" for a20 PRINT
column xbi_object_name heading "Object|Name" for a30
column xbi_object_node heading "Object|Node" for a10
column xbi_opt_cost heading "Optimizer|Cost" for 9999999999
column xbi_opt_card heading "Est. rows|per Start" for 999999999999
column xbi_opt_card_times_starts heading "Est. rows|total" for 999999999999
column xbi_opt_card_misestimate heading "Opt. Card.|misestimate" for a15 justify right
column xbi_opt_bytes heading "Estimated|output bytes" for 999999999999
column xbi_predicate_info heading "Predicate Information (identified by operation id):" format a100 word_wrap
column xbi_cpu_cost heading "CPU|Cost" for 9999999
column xbi_io_cost heading "IO|Cost" for 9999999
column xbi_last_output_rows heading "Real #rows|returned" for 9999999999
column xbi_last_starts heading "Rowsource|starts" for 999999999
column xbi_last_rows_start heading "#Rows ret/|per start" for 999999999
column xbi_last_cr_buffer_gets heading "Consistent|gets" for 999999999
column xbi_last_cr_buffer_gets_row heading "Consistent|gets/row" for 999999999
column xbi_last_cu_buffer_gets heading "Current|gets" for 999999999
column xbi_last_cu_buffer_gets_row heading "Current|gets/row" for 999999999
column xbi_last_disk_reads heading "Physical|read blks" for 999999999
column xbi_last_disk_writes heading "Physical|write blks" for 999999999
column xbi_last_elapsed_time_ms heading "cumulative ms|spent in branch" for 9,999,999.99 noprint
column xbi_self_elapsed_time_ms heading "ms spent in|this operation" for 9,999,999.99
column xbi_self_cr_buffer_gets heading "Consistent|gets" for 999999999
column xbi_self_cr_buffer_gets_row heading "Consistent|gets/row" for 999999999
column xbi_self_cu_buffer_gets heading "Current|gets" for 999999999
column xbi_self_cu_buffer_gets_row heading "Current|gets/row" for 999999999
column xbi_self_disk_reads heading "Physical|read blks" for 999999999
column xbi_self_disk_writes heading "Physical|write blks" for 999999999
column xbi_last_memory_used heading "Memory|used (MB)" for 9,999,999.99
column xbi_last_execution heading "Workarea|Passes" for a13
column xbi_sql_plan_hash_value heading "Plan Hash Value" for 9999999999
column xbi_plan_hash_value_text noprint
column xbi_outline_hints heading "Outline Hints" for a120 word_wrap
column xbi_notes heading "Plan|Notes" for a120 word_wrap
column xbi_sql_id heading "SQL_ID" for a13 new_value xbi_sql_id
column xbi_sql_child_number heading "CHLD" for 9999 new_value xbi_sql_child_number
column xbi_sql_addr heading "ADDRESS" new_value xbi_sql_addr
set feedback off
select
'Cursor: ' xbi_sql_id_text,
sql.sql_id xbi_sql_id,
sql.child_number xbi_sql_child_number,
sql.address xbi_sql_addr,
' PLAN_HASH_VALUE: ' xbi_plan_hash_value_text,
sql.plan_hash_value xbi_sql_plan_hash_value,
'Statement first parsed at: '|| sql.first_load_time ||' - '||
round( (sysdate - to_date(sql.first_load_time,'YYYY-MM-DD/HH24:MI:SS'))*86400 ) || ' seconds ago' xbi_seconds_ago
from
v$sql sql,
all_users usr
where
sql.parsing_user_id = usr.user_id
and (sql.sql_id,sql.child_number) = (('&xbi_sql_id', TO_NUMBER('&xbi_sql_child_number')))
and is_obsolete = 'N'
/
WITH sq AS (
SELECT
sp.id, sp.parent_id, sp.operation, sp.options, sp.object_owner, sp.object_name
, ss.last_elapsed_time, ss.last_cr_buffer_gets, ss.last_cu_buffer_gets, ss.last_disk_reads, ss.last_disk_writes
FROM v$sql_plan_statistics_all ss INNER JOIN
v$sql_plan sp
ON (
sp.sql_id=ss.sql_id
AND sp.child_number=ss.child_number
AND sp.address=ss.address
AND sp.id=ss.id
)
AND sp.sql_id='&xbi_sql_id'
AND sp.child_number = TO_NUMBER('&xbi_sql_child_number')
AND sp.address = hextoraw('&xbi_sql_addr')
), deltas AS (
SELECT
par.id
, par.last_elapsed_time - SUM(chi.last_elapsed_time ) self_elapsed_time
, par.last_cr_buffer_gets - SUM(chi.last_cr_buffer_gets) self_cr_buffer_gets
, par.last_cu_buffer_gets - SUM(chi.last_cu_buffer_gets) self_cu_buffer_gets
, par.last_disk_reads - SUM(chi.last_disk_reads ) self_disk_reads
, par.last_disk_writes - SUM(chi.last_disk_writes ) self_disk_writes
FROM sq par LEFT OUTER JOIN
sq chi
ON chi.parent_id = par.id
GROUP BY
par.id
, par.last_elapsed_time, par.last_cr_buffer_gets, par.last_cu_buffer_gets, par.last_disk_reads, par.last_disk_writes
), combined AS (
SELECT sq.id, sq.parent_id, sq.operation, sq.options
, sq.object_owner, sq.object_name
, sq.last_elapsed_time
, sq.last_cr_buffer_gets
, sq.last_cu_buffer_gets
, sq.last_disk_reads
, sq.last_disk_writes
, NVL(deltas.self_elapsed_time , sq.last_elapsed_time) self_elapsed_time
, NVL(deltas.self_cr_buffer_gets , sq.last_cr_buffer_gets) self_cr_buffer_gets
, NVL(deltas.self_cu_buffer_gets , sq.last_cu_buffer_gets) self_cu_buffer_gets
, NVL(deltas.self_disk_reads , sq.last_disk_reads) self_disk_reads
, NVL(deltas.self_disk_writes , sq.last_disk_writes) self_disk_writes
FROM
sq, deltas
WHERE
sq.id = deltas.id
),
adaptive_display_map AS (
SELECT
TO_NUMBER(EXTRACT(column_value, '/row/@op' )) id
, TO_NUMBER(EXTRACT(column_value, '/row/@par')) parent_id
, TO_NUMBER(EXTRACT(column_value, '/row/@dis')) display_id
, TO_NUMBER(EXTRACT(column_value, '/row/@dep')) depth
, TO_NUMBER(EXTRACT(column_value, '/row/@skp')) skip
FROM
v$sql_plan
, TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(other_xml),'/*/display_map/row')))
WHERE
sql_id = '&xbi_sql_id'
AND child_number = TO_NUMBER('&xbi_sql_child_number')
AND address = hextoraw('&xbi_sql_addr')
AND other_xml IS NOT NULL
)
select
LPAD(
CASE WHEN p.filter_predicates IS NOT NULL THEN 'F' ELSE ' ' END ||
CASE WHEN p.access_predicates IS NOT NULL THEN CASE WHEN p.options LIKE 'STORAGE %' THEN 'S' ELSE 'A' END ELSE '' END ||
CASE p.search_columns WHEN 0 THEN NULL ELSE '#'||TO_CHAR(p.search_columns) END
, 5) xbi_pred,
NVL(CASE WHEN adm.skip IS NULL THEN NULL
WHEN adm.skip = 0 THEN adm.display_id
WHEN adm.skip = 1 THEN NULL
END
, p.id) xbi_id,
nvl(adm2.parent_id, p.parent_id) xbi_parent_id,
CASE WHEN p.id != 0 THEN p.position END xbi_pos,
LPAD(' ',NVL(adm.depth,p.depth),' ')|| p.operation || ' ' || p.options ||' '
||nvl2(p.object_name, '['||p.object_name||']', null)
xbi_plan_line,
CASE WHEN p.id = 0 THEN '>>> Plan totals >>>' ELSE p.qblock_name END xbi_qblock_name,
-- p.object_node xbi_object_node,
-- p.object_owner,
-- p.object_name,
-- p.object_alias,
-- p.distribution xbi_distribution,
-- lpad(decode(p.id,0,'T ','')||trim(to_char(round(decode(p.id,0,c.last_elapsed_time,c.self_elapsed_time) /1000,2),'9,999,999.00')), 14) xbi_self_elapsed_time_ms,
round(decode(p.id,0,c.last_elapsed_time,c.self_elapsed_time) /1000,2) xbi_self_elapsed_time_ms,
decode(p.id,0,c.last_cr_buffer_gets,c.self_cr_buffer_gets) xbi_self_cr_buffer_gets,
ps.last_starts xbi_last_starts,
ps.last_output_rows xbi_last_output_rows,
p.cardinality * ps.last_starts xbi_opt_card_times_starts,
regexp_replace(lpad(to_char(round(
CASE WHEN (NULLIF(ps.last_output_rows / NULLIF(p.cardinality * ps.last_starts, 0),0)) > 1 THEN -(NULLIF(ps.last_output_rows / NULLIF(p.cardinality * ps.last_starts, 0),0))
WHEN (NULLIF(ps.last_output_rows / NULLIF(p.cardinality * ps.last_starts, 0),0)) < 1 THEN 1/(NULLIF(ps.last_output_rows / NULLIF(p.cardinality * ps.last_starts, 0),0))
WHEN (NULLIF(ps.last_output_rows / NULLIF(p.cardinality * ps.last_starts, 0),0)) = 1 THEN 1
ELSE null
END
,0))||'x',15),'^ *x$') xbi_opt_card_misestimate,
-- c.self_cr_buffer_gets xbi_self_cr_buffer_gets,
-- c.self_cr_buffer_gets / DECODE(ps.last_output_rows,0,1,ps.last_output_rows) xbi_self_cr_buffer_gets_row,
decode(p.id,0,c.last_cu_buffer_gets,c.self_cu_buffer_gets) xbi_self_cu_buffer_gets,
-- c.self_cu_buffer_gets / DECODE(ps.last_output_rows,0,1,ps.last_output_rows) xbi_self_cu_buffer_gets_row,
decode(p.id,0,c.last_disk_reads,c.self_disk_reads) xbi_self_disk_reads,
decode(p.id,0,c.last_disk_writes,c.self_disk_writes) xbi_self_disk_writes,
round(ps.last_elapsed_time/1000,2) xbi_last_elapsed_time_ms,
-- ps.last_cr_buffer_gets xbi_last_cr_buffer_gets,
-- ps.last_cr_buffer_gets / DECODE(ps.last_output_rows,0,1,ps.last_output_rows) xbi_last_cr_buffer_gets_row,
-- ps.last_cu_buffer_gets xbi_last_cu_buffer_gets,
-- ps.last_cu_buffer_gets / DECODE(ps.last_output_rows,0,1,ps.last_output_rows) xbi_last_cu_buffer_gets_row,
-- ps.last_disk_reads xbi_last_disk_reads,
-- ps.last_disk_writes xbi_last_disk_writes,
ps.last_memory_used/1048576 xbi_last_memory_used,
ps.last_execution xbi_last_execution,
p.cost xbi_opt_cost
-- p.bytes xbi_opt_bytes,
-- p.cpu_cost xbi_cpu_cost,
-- p.io_cost xbi_io_cost,
-- p.other_tag,
-- p.other,
-- p.access_predicates,
-- p.filter_predicates,
from
v$sql_plan p
, v$sql_plan_statistics_all ps
, combined c
, adaptive_display_map adm
, adaptive_display_map adm2
where
p.address = ps.address (+)
and p.sql_id = ps.sql_id (+)
and p.plan_hash_value = ps.plan_hash_value (+)
and p.child_number = ps.child_number (+)
and p.id = ps.id (+)
and p.id = adm.id (+)
and adm.id = adm2.id (+)
and (adm.id IS NULL or adm.skip = 0)
and p.sql_id = '&xbi_sql_id'
and p.address = hextoraw('&xbi_sql_addr')
and p.child_number = TO_NUMBER(&xbi_sql_child_number)
and ps.id = c.id (+)
order by
p.id asc
/
WITH adaptive_display_map AS (
SELECT
TO_NUMBER(EXTRACT(column_value, '/row/@op' )) id
, TO_NUMBER(EXTRACT(column_value, '/row/@dis')) display_id
, TO_NUMBER(EXTRACT(column_value, '/row/@skp')) skip
FROM
v$sql_plan
, TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(other_xml),'/*/display_map/row')))
WHERE
sql_id = '&xbi_sql_id'
AND child_number = TO_NUMBER('&xbi_sql_child_number')
AND address = hextoraw('&xbi_sql_addr')
AND other_xml IS NOT NULL
AND TO_NUMBER(EXTRACT(column_value, '/row/@skp')) != 1
)
select
xbi_id2,
xbi_qblock_name,
substr(dummy,1,0)||'-' " ", -- there's an ugly reason (bug) for this hack
xbi_predicate_info
from (
select
sp.sql_id xbi_sql_id,
LPAD(NVL(CASE WHEN adm.skip IS NULL THEN NULL
WHEN adm.skip = 0 THEN adm.display_id
WHEN adm.skip = 1 THEN NULL
END
, sp.id), 5, ' ') xbi_id2,
sp.filter_predicates dummy, -- looks like there's a bug in 11.2.0.3 where both pred cols have to be selected
CASE WHEN sp.options LIKE 'STORAGE %' THEN 'storage' ELSE 'access' END||'('|| substr(sp.access_predicates,1,3989) || ')' xbi_predicate_info,
sp.qblock_name xbi_qblock_name
from
v$sql_plan sp
, adaptive_display_map adm
where
sp.sql_id = '&xbi_sql_id'
and sp.child_number = TO_NUMBER(&xbi_sql_child_number)
AND sp.address = HEXTORAW('&xbi_sql_addr')
and sp.access_predicates is not null
and sp.id = adm.id (+)
union all
select
sp.sql_id xbi_sql_id,
--lpad(sp.id, 5, ' ') xbi_id2,
LPAD(NVL(CASE WHEN adm.skip IS NULL THEN NULL
WHEN adm.skip = 0 THEN adm.display_id
WHEN adm.skip = 1 THEN NULL
END
, sp.id), 5, ' ') xbi_id2,
sp.access_predicates dummy,
'filter('|| substr(sp.filter_predicates,1,3989) || ')' xbi_predicate_info,
sp.qblock_name xbi_qblock_name
from
v$sql_plan sp
, adaptive_display_map adm
where
sp.sql_id = '&xbi_sql_id'
and sp.child_number = TO_NUMBER(&xbi_sql_child_number)
and sp.address = HEXTORAW('&xbi_sql_addr')
and sp.filter_predicates is not null
and sp.id = adm.id (+)
)
order by
xbi_id2 asc,
xbi_predicate_info asc
/
-- this query can return ORA-600 in Oracle 10.2 due to Bug 5497611 - OERI[qctVCO:csform] from Xquery using XMLType constructor (Doc ID 5497611.8)
WITH sq AS (
SELECT other_xml
FROM v$sql_plan p
WHERE
p.sql_id = '&xbi_sql_id'
AND p.child_number = &xbi_sql_child_number
AND p.address = hextoraw('&xbi_sql_addr')
AND p.other_xml IS NOT NULL -- (the other_xml is not guaranteed to always be on plan line 1)
)
SELECT ' *' " ", 'Cardinality feedback = yes' xbi_notes FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "cardinality_feedback"]') = 'yes'
UNION ALL SELECT ' *', 'SQL Stored Outline used = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "outline"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "outline"]') IS NOT NULL
UNION ALL SELECT ' *', 'SQL Patch used = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "sql_patch"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "sql_patch"]') IS NOT NULL
UNION ALL SELECT ' *', 'SQL Profile used = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "sql_profile"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "sql_profile"]') IS NOT NULL
UNION ALL SELECT ' *', 'SQL Plan Baseline used = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "baseline"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "baseline"]') IS NOT NULL
UNION ALL SELECT ' *', 'Adaptive Plan = ' ||extractvalue(xmltype(sq.other_xml), '/*/info[@type = "adaptive_plan"]') FROM sq WHERE extractvalue(xmltype(sq.other_xml), '/*/info[@type = "adaptive_plan"]') IS NOT NULL
/
-- === Outline Hints ===
WITH sq AS (
SELECT other_xml
FROM v$sql_plan p
WHERE
p.sql_id = '&xbi_sql_id'
AND p.child_number = &xbi_sql_child_number
AND p.address = hextoraw('&xbi_sql_addr')
AND p.other_xml IS NOT NULL
)
SELECT
SUBSTR(EXTRACTVALUE(VALUE(d), '/hint'),1,4000) xbi_outline_hints
FROM
sq
, TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(sq.other_xml), '/*/outline_data/hint'))) D
/
set feedback on
PROMPT
-1
View File
@@ -2,4 +2,3 @@ prompt Display execution plan for last statement for this session from library c
select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST +ALIAS +PEEKED_BINDS +PARALLEL +PARTITION +COST +BYTES +HINT_REPORT'));
+4 -4
View File
@@ -1,3 +1,4 @@
/*
*
* Author : Vishal Gupta
@@ -31,9 +32,9 @@ FROM DUAL
SET long 4000
SET longchunksize 4000
SET pagesize 0
-- SET long 4000
-- SET longchunksize 4000
-- SET pagesize 0
SELECT *
FROM table(DBMS_XPLAN.display_cursor( sql_id => '&&sql_id'
@@ -45,4 +46,3 @@ FROM table(DBMS_XPLAN.display_cursor( sql_id => '&&sql_id'
UNDEFINE sql_id
UNDEFINE child_number