0% found this document useful (0 votes)
66 views

Health Check SQL

This document provides instructions for checking the status of various database objects and configurations to help troubleshoot performance issues. It includes steps to check the Automatic Workload Repository reports, ADDM reports, segment advisor, alert log, ASH report, performance hub report, invalid objects, tablespace sizes, blocking sessions, session I/O, library cache locks, long running SQL, failed jobs, initialization parameters, RMAN backup status, database size, autotask client status and jobs. It also provides commands to check the operating system memory, CPU, disk usage and version.

Uploaded by

mahmoud010
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Health Check SQL

This document provides instructions for checking the status of various database objects and configurations to help troubleshoot performance issues. It includes steps to check the Automatic Workload Repository reports, ADDM reports, segment advisor, alert log, ASH report, performance hub report, invalid objects, tablespace sizes, blocking sessions, session I/O, library cache locks, long running SQL, failed jobs, initialization parameters, RMAN backup status, database size, autotask client status and jobs. It also provides commands to check the operating system memory, CPU, disk usage and version.

Uploaded by

mahmoud010
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

select p.profile_option_name SHORT_NAME, n.

user_profile_option_name "PROFILE NAME",


decode(v.level_id, 10001, 'Site', 10002, 'Application',
10003, 'Responsibility', 10004, 'User', 10005, 'Server',
10007, 'SERVRESP', 'UnDef') LEVEL_SET,
decode(to_char(v.level_id), '10001', '',
'10002', app.application_short_name, '10003', rsp.responsibility_key,
'10005', svr.node_name, '10006', org.name, '10004', usr.user_name,
'10007', 'Serv/resp', 'UnDef') "CONTEXT", v.profile_option_value VALUE,
v.LAST_UPDATE_DATE
from fnd_profile_options p,
fnd_profile_option_values v,
fnd_profile_options_tl n,
fnd_user usr,
fnd_application app,
fnd_responsibility rsp,
fnd_nodes svr,
hr_operating_units org
where p.profile_option_id = v.profile_option_id (+)
and p.profile_option_name = n.profile_option_name
--and upper(n.user_profile_option_name) like upper('BNE%')
and trunc(v.LAST_UPDATE_DATE) > trunc(sysdate-1000)
and usr.user_id (+) = v.level_value
and rsp.application_id (+) = v.level_value_application_id
and rsp.responsibility_id (+) = v.level_value
and app.application_id (+) = v.level_value
and svr.node_id (+) = v.level_value
and org.organization_id (+) = v.level_value
and v.LAST_UPDATE_DATE is not null
order by last_update_date desc, short_name, level_set;

show parameter _sqlexec_progression_cost;

#========================================
# How to Determine the Latest APS/VCP Patch Applied to the System (Doc ID 252108.1)

#========================================
# Database Check
1- Automatic Workload Repository (AWR) report for a 60 minutes interval of a
problematic period.
@?/rdbms/admin/awrrpt.sql

2- AWR report for another period (Mandatory) with similar load where problems are
not seem.
@?/rdbms/admin/awrrpt.sql

3- AWR Compare Periods report comparing the 'good' and 'bad' periods
@?/rdbms/admin/awrddrpt.sql

3- ADDM
@?/rdbms/admin/addmrpt.sql

4- Segment Advisor.
5- Check alter log for ORA- and warn messages.
select value from v$diag_info where name ='Diag Trace';

6- ASH
@?/rdbms/admin/ashrpt.sql

7- Performance Hub
@?/rdbms/admin/perfhubrpt.sql

8- RDA - Health Check / Validation Engine Guide (Doc ID 250262.1)

9- Check Invalid Object


select owner||' '||object_name||' '||created||' '||status from dba_objects
where status='INVALID';

10- Check tablespace Size

SELECT df.tablespace_name TABLESPACE,


df.total_space TOTAL_SPACE,
fs.free_space FREE_SPACE,
df.total_space_mb TOTAL_SPACE_MB,
(df.total_space_mb - fs.free_space_mb) USED_SPACE_MB,
fs.free_space_mb FREE_SPACE_MB,
ROUND (100 * (fs.free_space / df.total_space), 2) PCT_FREE,
100- ROUND (100 * (fs.free_space / df.total_space), 2) PCT_USED
FROM ( SELECT tablespace_name,
SUM (bytes) TOTAL_SPACE,
ROUND (SUM (bytes) / 1048576) TOTAL_SPACE_MB
FROM dba_data_files
GROUP BY tablespace_name) df,
( SELECT tablespace_name,
SUM (bytes) FREE_SPACE,
ROUND (SUM (bytes) / 1048576) FREE_SPACE_MB
FROM dba_free_space
GROUP BY tablespace_name) fs
WHERE df.tablespace_name = fs.tablespace_name(+)
ORDER BY PCT_USED desc;

11- # Checking Size and usage in GB of Flash Recovery Area

archive log list;

SELECT
ROUND((A.SPACE_LIMIT / 1024 / 1024 / 1024), 2) AS FLASH_IN_GB,
ROUND((A.SPACE_USED / 1024 / 1024 / 1024), 2) AS FLASH_USED_IN_GB,
ROUND((A.SPACE_RECLAIMABLE / 1024 / 1024 / 1024), 2) AS FLASH_RECLAIMABLE_GB,
SUM(B.PERCENT_SPACE_USED) AS PERCENT_OF_SPACE_USED
FROM
V$RECOVERY_FILE_DEST A,
V$FLASH_RECOVERY_AREA_USAGE B
GROUP BY
SPACE_LIMIT,
SPACE_USED ,
SPACE_RECLAIMABLE ;

set lines 200 pages 200


col owner format a30
col SEGMENT_NAME format A50
SELECT * FROM (
SELECT
OWNER, SEGMENT_NAME,SEGMENT_TYPE, BYTES/1024/1024 SIZE_MB
FROM
DBA_SEGMENTS
ORDER BY
BYTES/1024/1024 DESC ) WHERE ROWNUM <= 20;

13 - # Check blocking sessions

select
(select username || ' - ' || osuser from v$session where sid=a.sid) blocker,
a.sid || ',' ||
(select serial# from v$session where sid=a.sid) sid_serial,
' is blocking ',
(select username || ' - ' || osuser from v$session where sid=b.sid) blockee,
b.sid || ',' ||
(select serial# from v$session where sid=b.sid) sid_serial
from v$lock a, v$lock b
where a.block = 1
and b.request > 0
and a.id1 = b.id1
and a.id2 = b.id2;

14- # Session I/O

SELECT NVL (s.username, '(oracle)') AS username,


s.osuser,
s.sid,
S.STATUS,
s.serial#,
si.block_gets,
si.consistent_gets "Logical read", --
Logical read
si.physical_reads "Physical read", --
Physical read
si.block_changes,
si.consistent_changes,
s.MACHINE,
s.TERMINAL,
s.PROGRAM,
s.MODULE,
s.ACTION,
s.CLIENT_INFO,
s.CLIENT_IDENTIFIER,
S.SQL_ID
FROM v$session s, v$sess_io si
WHERE s.sid = si.sid
ORDER BY si.physical_reads DESC;

15- # Detect sessions waiting for a Library Cache Locks

select sid Waiter, p1raw,


substr(rawtohex(p1),1,30) Handle,
substr(rawtohex(p2),1,30) Pin_addr
from v$session_wait where wait_time=0 and event like '%library cache%';
16- # How to find the long running sqls

select sid,
opname,
target,
sofar,
totalwork,
units,
(totalwork-sofar)/time_remaining bps,
time_remaining,
sofar/totalwork*100 fertig
from v$session_longops
where time_remaining > 0

17- # Checking for last 50 Failed jobs

select OWNER,job_name,status,ACTUAL_START_DATE,RUN_DURATION,additional_info
from DBA_SCHEDULER_JOB_RUN_DETAILS
where status<>'SUCCEEDED' and rownum <=50 order by ACTUAL_START_DATE desc;

SELECT COUNT(*)
FROM dba_jobs
WHERE NVL(failures, 0) < > 0;

18- Check Main


show parameter memory;
show parameter sga;
show parameter pga;
show parameter db_writer_processes;
show parameter session;
show parameter process;

19- #Check RMAN backup completion status

select (select NAME from v$database) Instance,


object_type,operation,status,session_stamp,
round((end_time - start_time) * 24 * 60, 2) Elapsed_Time,
decode(to_char(start_time, 'd'), 1, 'Sunday', 2, 'Monday',
3, 'Tuesday', 4, 'Wednesday',
5, 'Thursday', 6, 'Friday',
7, 'Saturday') dow,
to_char(start_time, 'mm/dd/yyyy hh:mi:ss') start_time,
to_char(end_time, 'mm/dd/yyyy hh:mi:ss') end_time,
round((input_bytes/(1024*1024*1024)),2) input_gb,
round((output_bytes/(1024*1024*1024)),2) output_gb
from v$rman_status
where start_time > trunc(sysdate-10) and operation = 'BACKUP' order by start_time
desc;

20- #Check Database size

Select DF.TOTAL/1073741824 "DataFile Size GB", LOG.TOTAL/1073741824 "Redo Log Size


GB",(DF.TOTAL + LOG.TOTAL )/ 1073741824 "Total Size GB"
from dual, (select sum(a.bytes) TOTAL from dba_data_files a) DF, (select
sum(b.bytes) TOTAL from v$log b) LOG;
21-
select client_name, status
from dba_autotask_client;

select distinct client_name, window_name, job_status, job_info


from dba_autotask_job_history
where job_status <> 'SUCCEEDED'
order by 1,2;

#========================================
# OS
#========================================
1- OSWatcher (Includes: [Video]) (Doc ID 301137.1).

2- Check memory size.


free -m # Linux
svmon -G, lsconf | grep Memory , lparstat -i | grep Memory # AIX

3- Check CPU
lscpu | grep -E '^Thread|^Core|^Socket|^CPU\(' # Linux
lparstat -i | grep Entitled # AIX

4- Check harddisk size.


df -h # Linux
df -g # AIX

5- OS version.
uname -a

You might also like