如何追蹤產生大量REDO的來源
SQL: How to Find Sessions Generating Lots of Redo or Archive logs (文件 ID 167492.1)
***Checked for relevance on 13-Oct-2015***
goal: How to find sessions generating lots of redo
fact: Oracle Server - Enterprise Edition 8
fact: Oracle Server - Enterprise Edition 9
fact: Oracle Server - Enterprise Edition 10
fix:
To find sessions generating lots of redo, you can use either of the following
methods. Both methods examine the amount of undo generated. When a transaction
generates undo, it will automatically generate redo as well.
The methods are:
1) Query V$SESS_IO. This view contains the column BLOCK_CHANGES which indicates
how much blocks have been changed by the session. High values indicate a
session generating lots of redo.
The query you can use is:
SQL> SELECT s.sid, s.serial#, s.username, s.program,
2 i.block_changes
3 FROM v$session s, v$sess_io i
4 WHERE s.sid = i.sid
5 ORDER BY 5 desc, 1, 2, 3, 4;
Run the query multiple times and examine the delta between each occurrence
of BLOCK_CHANGES. Large deltas indicate high redo generation by the session.
2) Query V$TRANSACTION. This view contains information about the amount of
undo blocks and undo records accessed by the transaction (as found in the
USED_UBLK and USED_UREC columns).
The query you can use is:
SQL> SELECT s.sid, s.serial#, s.username, s.program,
2 t.used_ublk, t.used_urec
3 FROM v$session s, v$transaction t
4 WHERE s.taddr = t.addr
5 ORDER BY 5 desc, 6 desc, 1, 2, 3, 4;
Run the query multiple times and examine the delta between each occurrence
of USED_UBLK and USED_UREC. Large deltas indicate high redo generation by
the session.
You use the first query when you need to check for programs generating lots of
redo when these programs activate more than one transaction. The latter query
can be used to find out which particular transactions are generating redo.
How To Determine The Cause Of Lots Of Redo Generation Using LogMiner (文件 ID 300395.1)
APPLIES TO:
Oracle Database - Enterprise Edition - Version 8.1.7.4 to 10.2.0.5 [Release 8.1.7 to 10.2]
Oracle Database - Enterprise Edition - Version 11.2.0.1 and later
Information in this document applies to any platform.
GOAL
This article provides guidelines DBAs can use to determine which OPERATION codes are generating lots of redo information.
This article is intended for DBAs. The article assumes the reader is familiar with LogMiner and has basic skills in mining redo logs.
SOLUTION
--- How to determine the cause of lots of redo generation using LogMiner ---
Using OPERATION Codes to Understand Redo Information
There are multiple operation codes which can generate the redo information, using following guide lines you can identify the operation codes which are causing the high redo generation and you need to take an appropriate action on it to reduce the high redo generation.
NOTE:
Redo records are not all equally sized. So remember that just because certain statements show up a lot in the LogMiner output, this does not guarantee that you have found the area of functionality generating the excessive redo.
What are these OPERATION codes ?
INSERT / UPDATE / DELETE -- Operations are performed on SYS objects are also considered as an Internal Operations.
COMMIT -- This is also "Internal" operation, you will get line "commit;" in the column sql_redo.
START -- This is also "Internal" operation, you will get line "set transaction read write;" in sql_redo INTERNAL -- Dictionary updates
SELECT_FOR_UPDATE - This is also an Internal operation and oracle generates the redo information for "select" statements which has "for update" clause.
In general INTERNAL operations are not relevant, so to query the relevant data, use "seg_owner=' in the "where" clause.
Examples :
How to extract relevant information from the view v$logmnr_contents?
1. This SQL lists operations performed by user SCOTT
SQL> select distinct operation,username,seg_owner from v$logmnr_contents where seg_owner='SCOTT';
OPERATION USERNAME SEG_OWNER
-------------------------- ------------------------- ---------------------
DDL SCOTT SCOTT
DELETE SCOTT SCOTT
INSERT SCOTT SCOTT
UPDATE SCOTT SCOTT
2. This SQL lists the undo and redo associated with operations that user SCOTT performed
SQL> select seg_owner,operation,sql_redo,sql_undo from v$logmnr_contents where SEG_owner='SCOTT';
SCOTT DDL
create table LM1 (c1 number, c2 varchar2(10));
SCOTT INSERT
insert into "SCOTT"."LM1"("C1","C2") values ('101','AAAA');
delete from "SCOTT"."LM1" where "C1" = '101' and "C2" = 'AAAA'
and ROWID = 'AAAHfBAABAAAMUqAAA';
SCOTT UPDATE update "SCOTT"."LM1" set "C2" = 'YYY'
where "C2" = 'EEE' and ROWID = 'AAAHfBAABAAAMUqAAE';
update "SCOTT"."LM1" set "C2" = 'EEE' where "C2" = 'YYY'
and ROWID = 'AAAHfBAABAAAMUqAAE';
INSERT / UPDATE / DELETE -- Operations are performed on SYS objects are also considered as an Internal Operations.
3. This SQL lists undo and redo genereated for UPDATE statements issues by user SCOTT
SQL> select username, seg_owner,operation,sql_redo,sql_undo from v$logmnr_contents where operation ='UPDATE' and USERNAME='SCOTT';
UNAME SEG_OW OPERATION SQL_REDO SQL_UNDO
---------- ---------- ------------ -----------------------------------
SCOTT SYS UPDATE update "SYS"."OBJ$" set "OBJ#" = '1'..... update ....
SCOTT SYS UPDATE update "SYS"."TSQ$" set "GRANTO..... update .......
SCOTT SYS UPDATE update "SYS"."SEG$" set "TYPE#" = '5'.. update......
As per above result user SCOTT has updated SYS objects so, if you query on USERNAME, you may get incorrect result. So, better to query v$logmnr_contents on SEG_OWNER.
4. Identifying Operation Counts
Run the following query to see the OPERATION code row count from v$logmnr_contents, to understand which OPERATION code has generated lots of redo information.
SQL> select operation,count(*) from v$logmnr_contents group by operation;
OPERATION COUNT(*)
-------------------- ----------
COMMIT 22236
DDL 2
DELETE 1
INSERT 11
INTERNAL 11
SELECT_FOR_UPDATE 32487
START 22236
UPDATE 480
8 rows selected
5. Identifying User Counts
Run the following query to check user activity and operation counts:
SQL> select seg_owner,operation,count(*) from v$logmnr_contents group by seg_owner,operation;
SEG_OWNER OPERATION COUNT(*)
-------------------- ---------------- ---------
SCOTT COMMIT 22236
SCOTT DDL 2
SCOTT DELETE 1
...
BILLY COMMIT 12899
BILLY DDL 5
BILLY DELETE 2
...
NOTE:
Be aware of next known issue:
If you are not using "select for update" statements often in your application and yet find a high operation count for operation code "SELECT_FOR_UPDATE" then you might be hitting a known issue.
To confirm this check whether SQL_REDO shows select,update statements on AQ$_QUEUE_TABLE_AFFINITIES and AQ$_QUEUE_TABLES.
If you see these selects and updates, then check the value of the Init.ora parameter AQ_TM_PROCESSES. The default value is AQ_TM_PROCESSES = 0 meaning that the queue monitor is not created.
If you are not using Advanced Queuing, then set AQ_TM_PROCESSES back to zero to avoid lots of redo generation on objects AQ$_QUEUE_TABLE_AFFINITIES and AQ$_QUEUE_TABLES.
***Checked for relevance on 13-Oct-2015***
goal: How to find sessions generating lots of redo
fact: Oracle Server - Enterprise Edition 8
fact: Oracle Server - Enterprise Edition 9
fact: Oracle Server - Enterprise Edition 10
fix:
To find sessions generating lots of redo, you can use either of the following
methods. Both methods examine the amount of undo generated. When a transaction
generates undo, it will automatically generate redo as well.
The methods are:
1) Query V$SESS_IO. This view contains the column BLOCK_CHANGES which indicates
how much blocks have been changed by the session. High values indicate a
session generating lots of redo.
The query you can use is:
SQL> SELECT s.sid, s.serial#, s.username, s.program,
2 i.block_changes
3 FROM v$session s, v$sess_io i
4 WHERE s.sid = i.sid
5 ORDER BY 5 desc, 1, 2, 3, 4;
Run the query multiple times and examine the delta between each occurrence
of BLOCK_CHANGES. Large deltas indicate high redo generation by the session.
2) Query V$TRANSACTION. This view contains information about the amount of
undo blocks and undo records accessed by the transaction (as found in the
USED_UBLK and USED_UREC columns).
The query you can use is:
SQL> SELECT s.sid, s.serial#, s.username, s.program,
2 t.used_ublk, t.used_urec
3 FROM v$session s, v$transaction t
4 WHERE s.taddr = t.addr
5 ORDER BY 5 desc, 6 desc, 1, 2, 3, 4;
Run the query multiple times and examine the delta between each occurrence
of USED_UBLK and USED_UREC. Large deltas indicate high redo generation by
the session.
You use the first query when you need to check for programs generating lots of
redo when these programs activate more than one transaction. The latter query
can be used to find out which particular transactions are generating redo.
How To Determine The Cause Of Lots Of Redo Generation Using LogMiner (文件 ID 300395.1)
APPLIES TO:
Oracle Database - Enterprise Edition - Version 8.1.7.4 to 10.2.0.5 [Release 8.1.7 to 10.2]
Oracle Database - Enterprise Edition - Version 11.2.0.1 and later
Information in this document applies to any platform.
GOAL
This article provides guidelines DBAs can use to determine which OPERATION codes are generating lots of redo information.
This article is intended for DBAs. The article assumes the reader is familiar with LogMiner and has basic skills in mining redo logs.
SOLUTION
--- How to determine the cause of lots of redo generation using LogMiner ---
Using OPERATION Codes to Understand Redo Information
There are multiple operation codes which can generate the redo information, using following guide lines you can identify the operation codes which are causing the high redo generation and you need to take an appropriate action on it to reduce the high redo generation.
NOTE:
Redo records are not all equally sized. So remember that just because certain statements show up a lot in the LogMiner output, this does not guarantee that you have found the area of functionality generating the excessive redo.
What are these OPERATION codes ?
INSERT / UPDATE / DELETE -- Operations are performed on SYS objects are also considered as an Internal Operations.
COMMIT -- This is also "Internal" operation, you will get line "commit;" in the column sql_redo.
START -- This is also "Internal" operation, you will get line "set transaction read write;" in sql_redo INTERNAL -- Dictionary updates
SELECT_FOR_UPDATE - This is also an Internal operation and oracle generates the redo information for "select" statements which has "for update" clause.
In general INTERNAL operations are not relevant, so to query the relevant data, use "seg_owner=' in the "where" clause.
Examples :
How to extract relevant information from the view v$logmnr_contents?
1. This SQL lists operations performed by user SCOTT
SQL> select distinct operation,username,seg_owner from v$logmnr_contents where seg_owner='SCOTT';
OPERATION USERNAME SEG_OWNER
-------------------------- ------------------------- ---------------------
DDL SCOTT SCOTT
DELETE SCOTT SCOTT
INSERT SCOTT SCOTT
UPDATE SCOTT SCOTT
2. This SQL lists the undo and redo associated with operations that user SCOTT performed
SQL> select seg_owner,operation,sql_redo,sql_undo from v$logmnr_contents where SEG_owner='SCOTT';
SCOTT DDL
create table LM1 (c1 number, c2 varchar2(10));
SCOTT INSERT
insert into "SCOTT"."LM1"("C1","C2") values ('101','AAAA');
delete from "SCOTT"."LM1" where "C1" = '101' and "C2" = 'AAAA'
and ROWID = 'AAAHfBAABAAAMUqAAA';
SCOTT UPDATE update "SCOTT"."LM1" set "C2" = 'YYY'
where "C2" = 'EEE' and ROWID = 'AAAHfBAABAAAMUqAAE';
update "SCOTT"."LM1" set "C2" = 'EEE' where "C2" = 'YYY'
and ROWID = 'AAAHfBAABAAAMUqAAE';
INSERT / UPDATE / DELETE -- Operations are performed on SYS objects are also considered as an Internal Operations.
3. This SQL lists undo and redo genereated for UPDATE statements issues by user SCOTT
SQL> select username, seg_owner,operation,sql_redo,sql_undo from v$logmnr_contents where operation ='UPDATE' and USERNAME='SCOTT';
UNAME SEG_OW OPERATION SQL_REDO SQL_UNDO
---------- ---------- ------------ -----------------------------------
SCOTT SYS UPDATE update "SYS"."OBJ$" set "OBJ#" = '1'..... update ....
SCOTT SYS UPDATE update "SYS"."TSQ$" set "GRANTO..... update .......
SCOTT SYS UPDATE update "SYS"."SEG$" set "TYPE#" = '5'.. update......
As per above result user SCOTT has updated SYS objects so, if you query on USERNAME, you may get incorrect result. So, better to query v$logmnr_contents on SEG_OWNER.
4. Identifying Operation Counts
Run the following query to see the OPERATION code row count from v$logmnr_contents, to understand which OPERATION code has generated lots of redo information.
SQL> select operation,count(*) from v$logmnr_contents group by operation;
OPERATION COUNT(*)
-------------------- ----------
COMMIT 22236
DDL 2
DELETE 1
INSERT 11
INTERNAL 11
SELECT_FOR_UPDATE 32487
START 22236
UPDATE 480
8 rows selected
5. Identifying User Counts
Run the following query to check user activity and operation counts:
SQL> select seg_owner,operation,count(*) from v$logmnr_contents group by seg_owner,operation;
SEG_OWNER OPERATION COUNT(*)
-------------------- ---------------- ---------
SCOTT COMMIT 22236
SCOTT DDL 2
SCOTT DELETE 1
...
BILLY COMMIT 12899
BILLY DDL 5
BILLY DELETE 2
...
NOTE:
Be aware of next known issue:
If you are not using "select for update" statements often in your application and yet find a high operation count for operation code "SELECT_FOR_UPDATE" then you might be hitting a known issue.
To confirm this check whether SQL_REDO shows select,update statements on AQ$_QUEUE_TABLE_AFFINITIES and AQ$_QUEUE_TABLES.
If you see these selects and updates, then check the value of the Init.ora parameter AQ_TM_PROCESSES. The default value is AQ_TM_PROCESSES = 0 meaning that the queue monitor is not created.
If you are not using Advanced Queuing, then set AQ_TM_PROCESSES back to zero to avoid lots of redo generation on objects AQ$_QUEUE_TABLE_AFFINITIES and AQ$_QUEUE_TABLES.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2155688/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 倉儲物流中心在途物流如何快速大量追蹤?
- 搭建 sentry 追蹤 Laravel 生產環境 bugLaravel
- 如何追蹤Java動態Java
- 如何追蹤Python動態Python
- 如何追蹤vue動態Vue
- 如何追蹤Go動態Go
- 如何追蹤laravel動態Laravel
- 怎麼一次性大量追蹤京東在途物流?
- 如何追蹤laravel動態<二>Laravel
- 追蹤掠食者:地下灰產如何擼死創業公司?創業
- 如何做路由追蹤?【免工具】路由
- BOS分散式鏈路追蹤產品揭秘分散式
- iOS逆向:在任意app上開啟malloc stack追蹤記憶體來源iOSAPP記憶體
- 如何用實時資料追蹤來解決專案瓶頸?
- go的鏈路追蹤Go
- DHorse的鏈路追蹤
- 程式碼追蹤
- 日誌追蹤
- 鏈路追蹤
- Map、Debug追蹤
- Debug追蹤eclipseEclipse
- 微服務追蹤SQL(支援Isto管控下的gorm查詢追蹤)微服務SQLGoORM
- IBM和珠寶行業領導者利用區塊鏈追蹤鑽石來源IBM行業區塊鏈
- 如何在 HDRP 中實現光線追蹤?
- 教你如何用Python追蹤快遞資訊!Python
- 延遲塊清理介紹(select也會產生redo的原因)
- MySQL:產生大量小relay log的故障一例MySql
- OpenTelemetry分散式追蹤分散式
- skywalking鏈路追蹤
- Halo 正式開源: 使用可穿戴裝置進行開源健康追蹤
- oracle 9i臨時表產生過多redoOracle
- go-zero 是如何追蹤你的請求鏈路?Go
- 網路廣告商的畫素追蹤是如何工作的?
- go-zero 是如何追蹤你的請求鏈路的Go
- 追蹤原始碼的方式歸納原始碼
- 如何用網頁尾本追蹤使用者網頁
- 33、buffer_cache_3(redo的產生、LRBA、buffer cache裡的等待事件)事件
- Spring Cloud 鏈路追蹤SpringCloud