Oracle instance ultra-high CPU occupancy investigation

CPU main functions: process instruction, an operation, an operation is required, the control time, process the data.

Combined with high CPU utilization database instance, it may be because the database to perform a large number of operations (full table queries, a lot of sorting).

As the company no DBA, a database problem encountered only their own investigation.

First, if there is a deadlock

And unlock the deadlock query statement references below:
  • Viewing deadlocks ID
SELECT s.username,l.OBJECT_ID,l.SESSION_ID,s.SERIAL#,
l.Oracle_USERNAME,l.OS_USER_NAME,l.PROCESS FROM V$LOCKED_OBJECT
l,V$SESSION S WHERE l.SESSION_ID=S.SID;
  • View the table name
select b.owner,b.object_name,a.session_id,a.locked_mode  from v$locked_object a,dba_objects b  where b.object_id = a.object_id; 
  • Hand closed deadlock
alter system kill session ‘sid,serial#’; (其中sid=l.session_id) 
By inquiry also found some deadlock deadlock, the CPU does not come down after the kill, only to re-investigation.

Second, the aid PLSQL queries regular job and session

Queried by PL / SQL, there is no regular JOB execution.
By Tools-Sessions, we found that there are more database connections and access, but more difficult to target specific problems that sql or table.
So, Kill all the Session, CPU eased, but the root cause is not found, repeated every few minutes and the.

Third, wait for the event database query

SELECT P.PID,
S.SID,
S.SERIAL#,
S.USERNAME,
Q.SQL_ID,
Q.SQL_TEXT,
Q.SQL_FULLTEXT,
W.EVENT,
W.WAIT_TIME,
W.STATE,
CASE
WHEN W.STATE = 'WAITING' THEN
W.SECONDS_IN_WAIT
WHEN W.STATE = 'WAITING KNOWN TIME' THEN
W.WAIT_TIME
END AS SEC_IN_WAIT
FROM V$SESSION S, V$SESSION_WAIT W, V$SQLAREA Q, V$PROCESS P
WHERE S.SID = W.SID
AND S.SQL_ID = Q.SQL_ID
AND P.ADDR = S.PADDR
AND W.EVENT NOT LIKE 'SQL*Net%'
AND S.USERNAME IS NOT NULL
AND W.WAIT_TIME >= 0
ORDER BY W.WAIT_TIME DESC;

Found waiting for the event, SQL analysis to be performed discover the full amount there are multiple tables (millions data) associated with the query.

So the data was appropriate and SQL optimization, CPU usage higher problem to be solved.

Fourth, the process summary

There are many reasons for the surge CPU, there are many ideas, follow-up if they can refer to the above ideas, to issue precise positioning and optimized.

Guess you like

Origin www.cnblogs.com/panda-sweets/p/12121622.html