ORACLE DBA Activity Checklist
ORACLE DBA Activity Checklist
ORACLE DBA Activity Checklist
Purpose:
This document gives details for performance/maintenance task daily, weekly, and monthly for checking the status of one or more Oracle databases.
These proactive activities will give the complete health check report of databases.
Daily Activity
Weekly Activity
Monthly Activity
1. Check the database size & compare it previous size to find the exact growth of the database
2. Find Tablespace Status, segment management, initial & Max Extents and Extent Management
3. Check location of data file also check auto extendable or not
4. Check default tablespace & temporary tablespace of each user
5. Check the Indexes which is not used yet
6. Check the Extents of each object and compare if any object extent are overridden which is define at tablespace level
7. Tablespace need coalescing
8. Check the overall database statistics
9. Trend Analysis of objects with tablespace, last analyzed, no. of Rows, Growth in days & growth in KB
Nightly Activity
Daily Activity
LSNRCTL STATUS
5. Check is there any dbms jobs run & check the status of the same
Verify all the dbms job runn successfully using script check_dbms_jobs.sql if any of the job fail the follow dbms_job_troubleshooting document.
select
sid,
username,
round(100 * total_user_io/total_io,2) tot_io_pct
from
(select
b.sid sid,
nvl(b.username,p.name) username,
sum(value) total_user_io
from
sys.v_$statname c,
sys.v_$sesstat a,
sys.v_$session b,
sys.v_$bgprocess p
where
a.statistic#=c.statistic# and
p.paddr (+) = b.paddr and
b.sid=a.sid and
c.name in ('physical reads',
'physical writes',
'physical writes direct',
'physical reads direct',
'physical writes direct (lob)',
'physical reads direct (lob)')
group by
b.sid, nvl(b.username,p.name)),
(select
sum(value) total_io
from
sys.v_$statname c,
sys.v_$sesstat a
where
a.statistic#=c.statistic# and
c.name in ('physical reads',
'physical writes',
'physical writes direct',
'physical reads direct',
'physical writes direct (lob)',
'physical reads direct (lob)'))
order by
3 desc;
SELECT Start_Date,
Start_Time,
Num_Logs,
Round(Num_Logs * (Vl.Bytes / (1024 * 1024)),
2) AS Mbytes,
Vdb.NAME AS Dbname
FROM (SELECT To_Char(Vlh.First_Time,
'YYYY-MM-DD') AS Start_Date,
To_Char(Vlh.First_Time,
'HH24') || ':00' AS Start_Time,
COUNT(Vlh.Thread#) Num_Logs
FROM V$log_History Vlh
GROUP BY To_Char(Vlh.First_Time,
'YYYY-MM-DD'),
To_Char(Vlh.First_Time,
'HH24') || ':00') Log_Hist,
V$log Vl,
V$database Vdb
WHERE Vl.Group# = 1
ORDER BY Log_Hist.Start_Date,
Log_Hist.Start_Time;
select o.object_name,l.oracle_username,l.os_user_name,l.session_id
,decode(l.locked_mode,2,'Row-S',3,'Row-X',4,'Share',5,'S/Row-X',6 ,'Exclusive','NULL')
from user_objects o , v$locked_object l
where o.object_id = l.object_id;
Weekly Activity
SELECT chain_cnt,
round(chain_cnt/num_rows*100,2) pct_chained,
avg_row_len, pct_free , pct_used
FROM user_tables
WHERE table_name = 'ROW_MIG_CHAIN_DEMO';
3. Check the size of tables & check weather it need to partition or not
Run the script table_size.sql to check the size of the table & follow the Partitioning in Oracle document to identify the table which are the
candidate of partition.
SELECT distinct 'Data Block# '|| block# || ' of Data File '
|| name || ' is corrupted.'
FROM v$backup_corruption a, v$datafile b
WHERE a.file# = b.file#;
SELECT distinct 'Data Block# '|| block# || ' of Data File '
|| name || ' is corrupted.'
FROM v$copy_corruption a, v$datafile b
WHERE a.file# = b.file#;
select sysdate,OWNER,TABLE_NAME
from dba_tables dt
where not exists (
select 'TRUE'
from dba_constraints dc
where dc.TABLE_NAME = dt.TABLE_NAME
and dc.CONSTRAINT_TYPE='P')
and OWNER not in ('SYS','SYSTEM')
order by OWNER, TABLE_NAME
select OWNER,
TABLE_NAME
from dba_tables
minus
select TABLE_OWNER,
TABLE_NAME
from dba_indexes
)
orasnap_noindex
where OWNER not in ('SYS','SYSTEM')
order by OWNER,TABLE_NAME
select sysdate,OWNER,
TABLE_NAME,
COUNT(*) index_count
from dba_indexes
where OWNER not in ('SYS','SYSTEM')
group by OWNER, TABLE_NAME
having COUNT(*) > 5
order by COUNT(*) desc, OWNER, TABLE_NAME
select sysdate,acc.OWNER,
acc.CONSTRAINT_NAME,
acc.COLUMN_NAME,
acc.POSITION,
'No Index' Problem
from dba_cons_columns acc,
dba_constraints ac
where ac.CONSTRAINT_NAME = acc.CONSTRAINT_NAME
and ac.CONSTRAINT_TYPE = 'R'
and acc.OWNER not in ('SYS','SYSTEM')
and not exists (
select 'TRUE'
from dba_ind_columns b
where b.TABLE_OWNER = acc.OWNER
and b.TABLE_NAME = acc.TABLE_NAME
and b.COLUMN_NAME = acc.COLUMN_NAME
and b.COLUMN_POSITION = acc.POSITION)
order by acc.OWNER, acc.CONSTRAINT_NAME, acc.COLUMN_NAME, acc.POSITION
10. Check the frequently load objects & place them in separate tablespace & in cache
Run the script frequent_load_object.sql to find the object which need to pin most the time. So we can place this object in separate tablespace as
well as in keep cache. Follow the document how_move_objects_tablespace and how_to_put_object_cache.
select OWNER,
NAME||' - '||TYPE object,
LOADS
from v$db_object_cache
where LOADS > 3
and type in ('PACKAGE','PACKAGE BODY','FUNCTION','PROCEDURE')
order by LOADS desc
13. Check the used & free Block (High Water Mark)at object level.
SELECT BLOCKS
FROM DBA_SEGMENTS
WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);
SELECT EMPTY_BLOCKS
FROM DBA_TABLES
WHERE OWNER=UPPER(owner) AND TABLE_NAME = UPPER(table);
Thus, the tables' HWM = (query result 1) - (query result 2) - 1
Run the script dbfile_load.sql to check the load on each datafile. Follow the document to balance the load on each datafile.
select v$datafile.name "File_Name", v$filestat.phyrds "Reads", v$filestat.phywrts "Writes" from v$filestat,v$datafile where v$filestat.file# =
v$datafile.file#
Monthly Activity
2. Check the database size & compare it previous size to find the exact growth of the database
Run db_size.sql to find the size of the database
select sum(b.a) "DB SIZE IN GB" from (select sum(bytes)/1024/1024/1024 a from dba_data_files
union
select sum(bytes)/1024/1024/1024 from dba_temp_files) b
3. Find Tablespace Status, segment management, initial & Max Extents and Extent Management
Run the script tablespace_extens.sql to check the storage clause of tablespace
4. Check location of datafile & Used & free space of each datafile
Run the script db_file.sql to check the location of data file & used & free of each datafile.
SELECT sysdate, SUBSTR (df.NAME, 1, 40) file_name, df.bytes / 1024 / 1024 allocated_mb,
((df.bytes / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024, 0))
used_mb,
NVL (SUM (dfs.bytes) / 1024 / 1024, 0) free_space_mb
FROM v$datafile df, dba_free_space dfs
WHERE df.file# = dfs.file_id(+)
GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
ORDER BY file_name;
@run_monitor
select
index_name
mon,
used
from
v$object_usage;
7. Check the Extents of each object and compare if any object extent are overridden which is define at tablespace level.
Run the script extent_compare_object_tablespace.sql to verify that is there any object whose extents are different from tablespace. If so then
move these objects on separate tablespace having same extent as on object level to avoid the fragmentation.
Nightly Activity
5. Check the No. of Date of Last Analysis & No. of Record in the Table
Note :- Compare the Number of rows, with no of insert, delete & update records, if this is more than 10% of number of rows then this table having
the statle stats & need to analysis again
SELECT * FROM
(SELECT
SUBSTR(TABLE_NAME, 1, 21) TABLE_NAME,
NUM_ROWS,
AVG_ROW_LEN ROWLEN,
BLOCKS,
ROUND((AVG_ROW_LEN + 1) * NUM_ROWS / 1000000, 0) NET_MB,
ROUND(BLOCKS * (8000 - 23 * INI_TRANS) *
(1 - PCT_FREE / 100) / 1000000, 0) GROSS_MB,
ROUND((BLOCKS * (8000 - 23 * INI_TRANS) * (1 - PCT_FREE / 100) -
(AVG_ROW_LEN + 1) * NUM_ROWS) / 1000000) "WASTED_MB"
FROM DBA_TABLES
WHERE
NUM_ROWS IS NOT NULL AND
OWNER LIKE 'SAP%' AND
PARTITIONED = 'NO' AND
(IOT_TYPE != 'IOT' OR IOT_TYPE IS NULL)
ORDER BY 7 DESC)
WHERE ROWNUM <=20;
select
p.object_name c1,
p.operation c2,
p.options c3,
count(1) c4
from
dba_hist_sql_plan p,
dba_hist_sqlstat s
where
p.object_owner <> 'SYS'
and
p.operation like %INDEX%
and
p.sql_id = s.sql_id
group by
p.object_name,
p.operation,
p.options
order by
1,2,3
SELECT shared_pool_size_for_estimate,
shared_pool_size_factor,
estd_lc_time_saved
FROM v$shared_pool_advice
select
size_for_estimate c1,
buffers_for_estimate c2,
estd_physical_read_factor c3,
estd_physical_reads c4
from
v$db_cache_advice
where
name = 'DEFAULT'
and
block_size = (SELECT value FROM V$PARAMETER
WHERE name = 'db_block_size')
and
advice_status = 'ON';
Undo Tablespace shrink by SMON after every 12 hrs. if more space is required.
SQL> SELECT SUBSTR (df.NAME, 1, 40) file_name, df.bytes / 1024 / 1024 allocated_mb,
2 ((df.bytes / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024, 0))
3 used_mb,
4 NVL (SUM (dfs.bytes) / 1024 / 1024, 0) free_space_mb
5 FROM v$datafile df, dba_free_space dfs
6 WHERE df.file# = dfs.file_id(+)
7 GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
8 ORDER BY file_name;
Check the tablespace usages considering the auto extend parameter on always