Skip to content

Commit 99d2427

Browse files
author
rednetx
committed
sync
1 parent 12de0b1 commit 99d2427

12 files changed

Lines changed: 169 additions & 20 deletions

ash/top_sqls_by_count.sql

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
select *
1+
col stext for a100 trunc;
2+
select
3+
ash.*
4+
,substr(s.sql_text,1,200) stext
5+
,s.elapsed_time/nullif(executions,0)/1e6 as elaexe
6+
,s.executions
7+
,to_char(s.elapsed_time,'tm9') elapsed_time
28
from (
39
select
4-
h.sql_id
10+
row_number()over(order by count(*) desc) rn
11+
,h.sql_id
512
,count(distinct sql_plan_hash_value) plans_cnt
613
,min(sql_plan_hash_value) phv_min
714
,max(sql_plan_hash_value) phv_max
8-
,count(distinct sql_exec_id) execs
9-
,count(*) cnt
15+
,count(distinct sql_exec_id) ash_execs
16+
,count(*) ash_cnt
1017
from v$active_session_history h
1118
where sql_id is not null
1219
group by sql_id
13-
order by cnt desc
14-
)
15-
where rownum<=20
20+
) ash
21+
left join v$sqlarea s
22+
on s.sql_id = ash.sql_id
23+
where rn<=20
24+
1625
/

awr/top_sql.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ snaps as (
1313
,begin_interval_time as beg_time
1414
,end_interval_time as end_time
1515
from dba_hist_snapshot sn
16-
where dbid=(select distinct dbid from dba_hist_database_instance i where i.db_name='&_awr_db_name')
16+
where dbid in (select distinct dbid from dba_hist_database_instance i where i.db_name='&_awr_db_name')
1717
--and snap_id between 63481 and 63504
1818
--63490 and 63494
1919
and end_interval_time between timestamp'&_awr_beg_time' and timestamp'&_awr_end_time'

cdb/chck_patches_18c.sql

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-- -----------------------------------------------------------------------------------
2+
-- File Name : https://MikeDietrichDE.com/wp-content/scripts/18c/check_patchesi_18.sql
3+
-- Author : Mike Dietrich
4+
-- Description : Displays contents of the patches (BP/PSU) registry and history
5+
-- Requirements : Access to the DBA role.
6+
-- Call Syntax : @check_patches_18.sql
7+
-- Last Modified: 24/07/2018
8+
-- Database Rel.: Oracle 12.2.0.1, Oracle 18c, Oracle 19c
9+
-- -----------------------------------------------------------------------------------
10+
11+
SET LINESIZE 500
12+
SET PAGESIZE 1000
13+
SET SERVEROUT ON
14+
SET LONG 2000000
15+
16+
COLUMN action_time FORMAT A12
17+
COLUMN action FORMAT A10
18+
COLUMN patch_type FORMAT A10
19+
COLUMN description FORMAT A32
20+
COLUMN status FORMAT A10
21+
COLUMN version FORMAT A10
22+
23+
alter session set "_exclude_seed_cdb_view"=FALSE;
24+
25+
spool check_patches_18.txt
26+
27+
select CON_ID,
28+
TO_CHAR(action_time, 'YYYY-MM-DD') AS action_time,
29+
PATCH_ID,
30+
PATCH_TYPE,
31+
ACTION,
32+
DESCRIPTION,
33+
SOURCE_VERSION,
34+
TARGET_VERSION
35+
from CDB_REGISTRY_SQLPATCH
36+
order by CON_ID, action_time, patch_id;
37+
38+

ctx/indexes.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ from ctxsys.ctx_indexes
1616
where idx_owner like '&_owner_mask'
1717
and idx_name like '&_index_mask'
1818
and idx_table like '&_table_mask'
19+
and IDX_TABLE !='DR$POLICY_TAB'
20+
and IDX_TABLE_OWNER!='CTXSYS'
1921
;
2022
col status for a10;
2123
col DOMIDX_STATUS for a15;
@@ -36,6 +38,7 @@ from dba_indexes idx
3638
where idx.owner like '&_owner_mask'
3739
and idx.index_name like '&_index_mask'
3840
and idx.table_name like '&_table_mask'
41+
and idx.DOMIDX_STATUS is not null
3942
;
4043

4144
col idx_owner clear;

ctx/indexes_invalid.sql

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
accept _owner_mask prompt "Owner mask[%]: " default '%';
2+
accept _index_mask prompt "Index mask[%]: " default '%';
3+
accept _table_mask prompt "Table mask[%]: " default '%';
4+
5+
col owner for a30;
6+
col idx_name for a30;
7+
col idx_table for a30;
8+
col idx_status for a20;
9+
10+
select
11+
idx_owner as owner
12+
,idx_name
13+
,idx_table
14+
,idx_status
15+
from ctxsys.ctx_indexes
16+
where idx_owner like '&_owner_mask'
17+
and idx_name like '&_index_mask'
18+
and idx_table like '&_table_mask'
19+
and (idx_status!='INDEXED')
20+
and IDX_TABLE !='DR$POLICY_TAB'
21+
and IDX_TABLE_OWNER!='CTXSYS'
22+
;
23+
col status for a10;
24+
col DOMIDX_STATUS for a15;
25+
col DOMIDX_OPSTATUS for a15;
26+
col FUNCIDX_STATUS for a15;
27+
col DROPPED for a7;
28+
29+
30+
select
31+
owner,
32+
index_name as idx_name,
33+
status,
34+
DOMIDX_STATUS,
35+
DOMIDX_OPSTATUS,
36+
FUNCIDX_STATUS,
37+
DROPPED
38+
from dba_indexes idx
39+
where idx.owner like '&_owner_mask'
40+
and idx.index_name like '&_index_mask'
41+
and idx.table_name like '&_table_mask'
42+
and (idx.DOMIDX_STATUS != 'VALID' or DOMIDX_OPSTATUS!='VALID')
43+
;
44+
45+
col owner clear;
46+
col idx_name clear;
47+
col idx_table clear;
48+
col idx_status clear;
49+

externals/my/XT_REGEXP

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 2dc145df269e92cc2b1695d2ac7a69d769ab0605

longops.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ select
3030
&_IF_ORA11_OR_HIGHER ,l.sql_plan_operation
3131
&_IF_ORA11_OR_HIGHER ,l.sql_plan_options
3232
from v$session_longops l
33-
where last_update_time>sysdate - 0&_minutes/24/60;
33+
where last_update_time>sysdate - 0&_minutes/24/60
34+
order by 1,2,5 desc,6 desc;
3435

3536
undef _minutes;
3637
col username clear;

my_pid.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
select
2+
s.sid
3+
,s.serial#
4+
,p.spid as os_pid
5+
,p.pid as ora_pid
6+
from v$session s
7+
,v$process p
8+
where s.PADDR=p.addr
9+
and s.sid = userenv('SID')
10+
/

profiles/patch_create.old.sql

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
prompt ***;
2+
prompt Using SQL Patch to add hints;
3+
prompt ***;
4+
5+
set feed on serverout on;
6+
7+
accept p_sqlid prompt "SQL_ID: ";
8+
accept p_hints prompt "Hints: ";
9+
accept p_name prompt "Patch name: ";
10+
accept p_descr prompt "Description: ";
11+
12+
declare
13+
-- params:
14+
p_sql_id varchar2(13) :=q'[&p_sqlid]';
15+
p_hints varchar2(4000):=q'[&p_hints]';
16+
p_name varchar2(30) :=q'[&p_name]';
17+
p_description varchar2(120) :=q'[&p_descr]';
18+
cl_sql_text clob;
19+
begin
20+
21+
select
22+
coalesce(
23+
(select s1.sql_fulltext from v$sqlarea s1 where p_sql_id = s1.sql_id)
24+
,(select s2.sql_text from dba_hist_sqltext s2 where p_sql_id = s2.sql_id and s2.dbid = (select db.dbid from v$database db))
25+
) stext
26+
into cl_sql_text
27+
from dual;
28+
29+
sys.dbms_sqldiag_internal.i_create_patch(
30+
sql_text => cl_sql_text,
31+
hint_text => p_hints,
32+
name => p_name,
33+
description => p_description
34+
);
35+
36+
dbms_output.put_line('SQL Profile '||p_name||' created on instance #'||sys_context('userenv','instance'));
37+
end;
38+
/
39+
undef p_sqlid p_hints p_name p_descr

profiles/patch_create.sql

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,24 @@ accept p_descr prompt "Description: ";
1212
declare
1313
-- params:
1414
p_sql_id varchar2(13) :=q'[&p_sqlid]';
15-
p_hints varchar2(4000):=q'[&p_hints]';
15+
p_hints clob :=q'[&p_hints]';
1616
p_name varchar2(30) :=q'[&p_name]';
1717
p_description varchar2(120) :=q'[&p_descr]';
1818
cl_sql_text clob;
19+
res varchar2(4000);
1920
begin
20-
21-
select
22-
coalesce(
23-
(select s1.sql_fulltext from v$sqlarea s1 where p_sql_id = s1.sql_id)
24-
,(select s2.sql_text from dba_hist_sqltext s2 where p_sql_id = s2.sql_id and s2.dbid = (select db.dbid from v$database db))
25-
) stext
26-
into cl_sql_text
27-
from dual;
2821

29-
sys.dbms_sqldiag_internal.i_create_patch(
30-
sql_text => cl_sql_text,
22+
res:=sys.dbms_sqldiag_internal.i_create_patch(
23+
sql_id => p_sql_id,
3124
hint_text => p_hints,
25+
creator => user,
3226
name => p_name,
3327
description => p_description
3428
);
3529

3630
dbms_output.put_line('SQL Profile '||p_name||' created on instance #'||sys_context('userenv','instance'));
31+
dbms_output.put_line('Results:');
32+
dbms_output.put_line(res);
3733
end;
3834
/
3935
undef p_sqlid p_hints p_name p_descr

0 commit comments

Comments
 (0)