Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle monitoring script statement

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

View highly fragmented tables

SELECT segment_name table_name, COUNT (*) extents

FROM dba_segments

WHERE owner NOT IN ('SYS',' SYSTEM')

GROUP BY segment_name

HAVING COUNT (*) = (SELECT MAX (COUNT (*))

FROM dba_segments

GROUP BY segment_name)

Find users who use CPU more than others

Session select a. Sidgery spidgery statuspr substr (a. Programmel 1 pas 40) prog,a.terminal,osuser,value/60/100 value

From v$session a recordsesstat c

Where c.statistic#=12 and c.sid=a.sid and a.paddr=b.addr order by value desc

Contention of rollback segment

Select name, waits, gets, waits/gets "Ratio"

From v$rollstat a, v$rollname b

Where a.usn = b.usn

The hit rate of monitoring SGA shared cache should be less than 1%.

Select sum (pins) "Total Pins"

Sum (reloads) "Total Reloads"

Sum (reloads) / sum (pins) * 100 libcache

Sum (pinhits-reloads) / sum (pins) "hit radio"

Sum (reloads) / sum (pins) "reload percent"

From v$librarycache

The hit rate of the redo log cache in monitoring SGA should be less than 1%.

SELECT name, gets, misses, immediate_gets, immediate_misses

Decode (gets,0,0,misses/gets*100) ratio1

Decode (immediate_gets+immediate_misses,0,0

Immediate_misses/ (immediate_gets+immediate_misses) * 100) ratio2

FROM v$latch WHERE name IN ('redo allocation',' redo copy')

Monitor the use of log_buffer

Select name,value from v$sysstat where name in ('redo entries','redo buffer allocation retries')

Monitor the hit rate of database buffers in SGA

Select a.value + b.value "logical_reads", c.value "phys_reads"

Round ((a.value+b.value)-c.value) / (a.value+b.value)) "BUFFER HIT RATIO"

From v$sysstat a, v$sysstat b, v$sysstat c

Where a.statistic# = 38 and b.statistic# = 39

And c.statistic# = 40

Monitor the IO ratio of tablespaces

Select df.tablespace_name name,df.file_name "ile", f.phyrds pyr

F.phyblkrd pbr,f.phywrts pyw, f.phyblkwrt pbw

From v$filestat f, dba_data_files df

Where f.file# = df.file_id

Order by df.tablespace_name

Monitor tablespace utilization

SELECT UPPER (F.TABLESPACE_NAME) "tablespace name"

D.TOT_GROOTTE_MB Tablespace size (M)

D.TOT_GROOTTE_MB-F.TOTAL_BYTES "Space used (M)"

ROUND ((D.TOT_GROOTTE_MB-F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100J 2) "usage ratio"

F.TOTAL_BYTES "Free Space"

F.MAX_BYTES "maximum Block (M)"

FROM (SELECT TABLESPACE_NAME

ROUND (SUM (BYTES) / (1024 * 1024), 2) TOTAL_BYTES

ROUND (MAX (BYTES) / (1024 * 1024), 2) MAX_BYTES

FROM SYS.DBA_FREE_SPACE

GROUP BY TABLESPACE_NAME) F

(SELECT DD.TABLESPACE_NAME

ROUND (SUM (DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB

FROM SYS.DBA_DATA_FILES DD

GROUP BY DD.TABLESPACE_NAME) D

WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME

ORDER BY 4 DESC

Monitor who is running what SQL statements in the current database

SELECT osuser, username, sql_text

From v$session a, v$sqltext b

Where a.sql_address = b.address

Order by address, piece

Monitor waiting events

Select event,sum (decode (wait_Time,0,0,1)) "rev"

Sum (decode (wait_Time,0,1,0)) "Curr", count (*) "Tot"

From v$session_Wait

Group by event order by 4

Monitor the sorting ratio of memory to hard disk

SELECT name, value

FROM v$sysstat

WHERE name IN ('sorts (memory)', 'sorts (disk)')

Monitor the IO ratio of the file system

"#" select substr (a.filemagic pr 1pr 2), substr (a.namemere 1pr 30) "Name"

A.status, a.bytes, b.phyrds, b.phywrts

From v$datafile a, v$filestat b

Where a.file# = b.file#

Find all the indexes under a user

Select user_indexes.table_name

User_indexes.index_name

Uniqueness

Column_name

From user_ind_columns, user_indexes

Where user_ind_columns.index_name = user_indexes.index_name

And user_ind_columns.table_name = user_indexes.table_name

Order by user_indexes.table_type

User_indexes.table_name

User_indexes.index_name

Column_position

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 261

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report