您好,登錄后才能下訂單哦!
查詢數(shù)據(jù)庫中的等待事件:
SET lines 100
SET pages 10000
COLUMN wait_class format a12
COLUMN event format a30
COLUMN total_waits format 999999
COLUMN total_us format 999999999
COLUMN pct_time format 99.99
COLUMN avg_us format 999999.99
SET echo on
SELECT wait_class, event, total_waits AS waits,
ROUND (time_waited_micro / 1000) AS total_ms,
ROUND (time_waited_micro * 100 / SUM (time_waited_micro) OVER (),
2
) AS pct_time,
ROUND ((time_waited_micro / total_waits) / 1000, 2) AS avg_ms
FROM v$system_event
WHERE wait_class <> 'Idle'
ORDER BY time_waited_micro DESC;
2.整合時間模型和等待接口:
SELECT event,
total_waits,
round(time_waited_micro / 1000000) AS time_waited_secs,
round(time_waited_micro * 100 / SUM(time_waited_micro) over(), 2) AS pct_time
FROM (SELECT event, total_waits, time_waited_micro
FROM v$system_event
WHERE wait_class <> 'Idle'
UNION
SELECT stat_name, NULL, VALUE
FROM v$sys_time_model
WHERE stat_name IN ('DB CPU', 'backup cpu time'))
ORDER BY 3 DESC
SELECT sample_seconds,
stat_name,
waits_per_second waits_per_sec,
microseconds_per_second ms_per_sec,
pct_of_time pct
FROM opsg_delta_report
WHERE microseconds_per_second > 0;
監(jiān)控索引的使用情況:
WITH in_plan_objects AS
(SELECT DISTINCT object_name FROM v$sql_plan WHERE object_owner = 'SCOTT')
SELECT table_name,
index_name,
CASE
WHEN object_name IS NULL THEN
'NO'
ELSE
'YES'
END AS in_cached_plan
FROM user_indexes
LEFT OUTER JOIN in_plan_objects
ON (index_name = object_name);
4.識別從綁定變量中獲益的sql語句:
WITH force_matches AS
(SELECT force_matching_signature,
COUNT( * ) matches,
MAX(sql_id || child_number) max_sql_child,
DENSE_RANK() OVER (ORDER BY COUNT( * ) DESC)
ranking
FROM v$sql
WHERE force_matching_signature <> 0
AND parsing_schema_name <> 'SYS'
GROUP BY force_matching_signature
HAVING COUNT( * ) > 5)
SELECT sql_id, matches, parsing_schema_name schema, sql_text
FROM v$sql JOIN force_matches
ON (sql_id || child_number = max_sql_child)
WHERE ranking <= 10
ORDER BY matches DESC;
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。