減少oracle日誌的產生
大家一定遇到過不想讓oracle產生日誌的情況。那麼什麼時候oracle能夠不產生日誌呢?
有嗎?這裡我總結一下oracle產生少量日誌的情況。
有嗎?這裡我總結一下oracle產生少量日誌的情況。
在scott下,構造了一個9萬多的表
create table t1 as select * from emp;
create table t1 as select * from emp;
SQL> insert into t1 select * from t1;
14 rows created.
SQL> /
28 rows created.
SQL> /
56 rows created.
重複的不斷插入,直到
917504 rows created.
SQL> commit;
-----------------------------------------------------------------------
下面開始我們的實驗
下面開始我們的實驗
SQL> conn /as sysdba
Connected.
SQL> desc v$sysstat
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
STATISTIC# NUMBER
NAME VARCHAR2(64)
CLASS NUMBER
VALUE NUMBER
STAT_ID NUMBER
Connected.
SQL> desc v$sysstat
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
STATISTIC# NUMBER
NAME VARCHAR2(64)
CLASS NUMBER
VALUE NUMBER
STAT_ID NUMBER
SQL> select * from v$sysstat where class=2;
STATISTIC# NAME CLASS VALUE STAT_ID
---------- -------------------------------------------------- ---------- ---------- ----------
132 redo blocks read for recovery 2 0 2679943069
133 redo entries 2 104183 3488821837
134 redo size 2 107480316 1236385760
135 redo buffer allocation retries 2 4 1446958922
136 redo wastage 2 556420 3462806146
137 redo writer latching time 2 2 2166056472
138 redo writes 2 2149 1948353376
139 redo blocks written 2 217925 2391431605
140 redo write time 2 1307 3094453259
141 redo log space requests 2 5 1985754937
142 redo log space wait time 2 27 252430928
143 redo log switch interrupts 2 0 674283274
144 redo ordering marks 2 2294 2104561012
145 redo subscn max counts 2 0 449106517
168 flashback log writes 2 0 3123176560
---------- -------------------------------------------------- ---------- ---------- ----------
132 redo blocks read for recovery 2 0 2679943069
133 redo entries 2 104183 3488821837
134 redo size 2 107480316 1236385760
135 redo buffer allocation retries 2 4 1446958922
136 redo wastage 2 556420 3462806146
137 redo writer latching time 2 2 2166056472
138 redo writes 2 2149 1948353376
139 redo blocks written 2 217925 2391431605
140 redo write time 2 1307 3094453259
141 redo log space requests 2 5 1985754937
142 redo log space wait time 2 27 252430928
143 redo log switch interrupts 2 0 674283274
144 redo ordering marks 2 2294 2104561012
145 redo subscn max counts 2 0 449106517
168 flashback log writes 2 0 3123176560
15 rows selected.
檢視當前的redo size
SQL> select * from v$sysstat where STATISTIC#=134;
STATISTIC# NAME CLASS VALUE STAT_ID
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 107576456 1236385760
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 107576456 1236385760
SQL> show user
USER is "SYS"
SQL> conn scott/tigger
Connected.
SQL> create table test as select * from t1;
USER is "SYS"
SQL> conn scott/tigger
Connected.
SQL> create table test as select * from t1;
Table created.
SQL> conn /as sysdba
Connected.
SQL> select * from v$sysstat where STATISTIC#=134;
Connected.
SQL> select * from v$sysstat where STATISTIC#=134;
STATISTIC# NAME CLASS VALUE STAT_ID
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 108493988 1236385760
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 108493988 1236385760
SQL> select ( 108493988-107576456)/1024/1024 from dual;
(108493988-107576456)/1024/1024
-------------------------------
.875026703
我們日常中的備份表產生了.875026703M大小的日誌
-------------------------------
.875026703
我們日常中的備份表產生了.875026703M大小的日誌
SQL> conn scott/tigger
Connected.
SQL> drop table test purge;
Connected.
SQL> drop table test purge;
Table dropped.
SQL> create table test as select * from t1 nologging;
Table created.
SQL> conn /as sysdba
Connected.
SQL> select * from v$sysstat where STATISTIC#=134;
Connected.
SQL> select * from v$sysstat where STATISTIC#=134;
STATISTIC# NAME CLASS VALUE STAT_ID
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 108905676 1236385760
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 108905676 1236385760
SQL> select (108905676- 108493988)/1024/1024 from dual;
(108905676-108493988)/1024/1024
-------------------------------
.392616272
-------------------------------
.392616272
加上nologging後,產生的日誌比原來的1/2還要小。
---------------------------------------------------------------------------------------
二、接下來,我們來看一下insert
SQL> conn scott/tigger
Connected.
SQL> select count(*) from test;
Connected.
SQL> select count(*) from test;
COUNT(*)
----------
0
----------
0
SQL> insert into test select * from t1;
1835008 rows created.
SQL> commit;
Commit complete.
SQL> conn /as sysdba
Connected.
SQL> select * from v$sysstat where STATISTIC#=134;
Connected.
SQL> select * from v$sysstat where STATISTIC#=134;
STATISTIC# NAME CLASS VALUE STAT_ID
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 202231620 1236385760
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 202231620 1236385760
SQL> select (202231620- 109424508)/1024/1024 from dual;
(202231620-109424508)/1024/1024
-------------------------------
88.5077591
-------------------------------
88.5077591
產生88.5077591M的日誌
SQL> truncate table test;
Table truncated.
SQL> insert /*+append*/ into test select * from t1 nologging;
1835008 rows created.
SQL> commit;
Commit complete.
SQL> select * from v$sysstat where STATISTIC#=134;
STATISTIC# NAME CLASS VALUE STAT_ID
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 489164360 1236385760
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 489164360 1236385760
SQL> select * from v$sysstat where STATISTIC#=134;
STATISTIC# NAME CLASS VALUE STAT_ID
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 489208144 1236385760
---------- -------------------------------------------------- ---------- ---------- ----------
134 redo size 2 489208144 1236385760
SQL> select (489208144-488407836)/1024/1024 from dual;
(489208144-488407836)/1024/1024
-------------------------------
.763233185
產生日誌大小為.763233185M
----------------------------------------------------------------------------
三、建立索引
為9十多萬資料的test建立索引
SQL> create index idx_1 on test(sal);
-------------------------------
.763233185
產生日誌大小為.763233185M
----------------------------------------------------------------------------
三、建立索引
為9十多萬資料的test建立索引
SQL> create index idx_1 on test(sal);
SQL> select (520157608-489472044)/1024/1024 from dual;
(520157608-489472044)/1024/1024
-------------------------------
29.2640343
產生日誌29.2640343M
-------------------------------
29.2640343
產生日誌29.2640343M
SQL> drop index idx_1;
Index dropped.
SQL> create index idx_1 on test(sal) nologging;
Index created.
SQL> select (520661968-520507264)/1024/1024 from dual;
(520661968-520507264)/1024/1024
-------------------------------
.147537231
產生日誌.147537231M
-------------------------------
.147537231
產生日誌.147537231M
到此我們使用了三種方法,來降低日誌的產生
1、create table test as ......... nologging;
2、並行載入資料配合nologging
3、建立索引的時候,加nologging
2、並行載入資料配合nologging
3、建立索引的時候,加nologging
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13726712/viewspace-694578/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 減少日誌產生量小結
- Oracle資料庫減少redo日誌產生方式Oracle資料庫
- oracle 日誌產生大小的計算Oracle
- 減少SQL日誌的三種方法(轉)SQL
- 【oracle】關於日誌產生量的計算Oracle
- Oracle產生redo日誌量大小統計Oracle
- [20180829]減少日誌生成量.txt
- oracle redo日誌產生量測試及比較1Oracle Redo
- 11G Oracle 關閉監聽XML日誌產生的方法OracleXML
- 每天產生REDO歸檔日誌量
- oracle檢視昨天產生歸檔日誌檔案總量Oracle
- 【LISTENER】禁止產生監聽器日誌的方法
- 測試DML 時產生歸檔日誌和閃回日誌的比
- 啟用生產工單標準日誌
- 解決生產日誌重複列印的問題
- oracle redo日誌產生量測試及比較2_insertOracle Redo
- 減少ORACLE中的磁碟I/O(轉)Oracle
- Oracle的0000/0/0日期產生Oracle
- update操作會產生幾條mlog$日誌?
- 記:”$ORACLE_HOME/.../sysman/recv/errors“目錄下產生大量日誌檔案OracleError
- 減小SQL SERVER的日誌檔案SQLServer
- 聊一聊如何截獲 C# 程式產生的日誌C#
- oracle歸檔模式下imp匯入資料,產生的歸檔日誌大小記錄Oracle模式
- 物化檢視comlete重新整理會產生大量的日誌
- MySQL案例之——生產slave庫無法應用日誌MySql應用日誌
- Oracle的重做日誌Oracle
- ORACLE的日誌管理Oracle
- Oracle日誌Oracle
- 歸檔日誌大小 與使用rman 備份後的歸檔日誌產生的備份集大小的關係
- 【Oracle日誌】- 日誌檔案重建Oracle
- Filebeat 收集K8S 日誌,生產環境實踐K8S
- oracle10g_10.2.0.5_構建生產某表為分割槽及分割槽索引的日誌Oracle索引
- 產品經理如何幫助減少技術債務 ?
- trace_enabled 是否產生trace日誌--按情況來關閉
- 11G flashback data archive 導致產生大量歸檔日誌Hive
- 使用 Easysearch,日誌儲存少一半
- 使用MVVM減少控制器程式碼實戰(減少56%)MVVM
- 減少對錶的查詢