減少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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 減少日誌產生量小結
- [20180829]減少日誌生成量.txt
- 解決生產日誌重複列印的問題
- update操作會產生幾條mlog$日誌?
- oracle alert日誌Oracle
- oracle刪除日誌Oracle
- oracle歸檔日誌Oracle
- 聊一聊如何截獲 C# 程式產生的日誌C#
- 歸檔oracle alert日誌Oracle
- Oracle歸檔日誌清理Oracle
- spring-boot-route(十六)使用logback生產日誌檔案Springboot
- Zabbix如何監控Oracle的告警日誌Oracle
- 【REDO】Oracle 日誌挖掘,分析歸檔日誌線上日誌主要步驟Oracle
- 使用 Easysearch,日誌儲存少一半
- Oracle告警日誌ora-04030Oracle
- Oracle listener log 日誌分析方法Oracle
- Filebeat 收集K8S 日誌,生產環境實踐K8S
- 利用oracle的日誌挖掘實現回滾Oracle
- 使用zabbix監控oracle的後臺日誌Oracle
- ORACLE CRS日誌中的ClssnmPollingThread Missed Checkins MessagesOraclethread
- oracle 刪除過期的歸檔日誌Oracle
- 【Oracle】歸檔日誌管理-設定歸檔日誌路徑以及歸檔日誌冗餘Oracle
- oracle rman備份歸檔日誌需要先切換日誌嗎Oracle
- oracle DG 日誌傳輸小結Oracle
- Oracle redo日誌內容探索(一)Oracle Redo
- oracle資料庫mmnl日誌很大Oracle資料庫
- Oracle實驗6--掌握Oracle資料庫的日誌操作Oracle資料庫
- 減少Android APK的大小99.99%AndroidAPK
- 檢視Oracle的redo日誌切換頻率Oracle
- oracle10g DataGuard的日誌傳輸方式Oracle
- oracle丟失的是所有的redo日誌組Oracle
- 海豚排程清理:使用 API 輕鬆清理工作流歷史版本記錄,一鍵減少關係日誌和任務定義日誌表的資料量API
- 【Oracle】死鎖的產生與處理Oracle
- Oracle12C新特性_DDL日誌Oracle
- Oracle redo日誌內容探索之二Oracle Redo
- oracle11G歸檔日誌管理Oracle
- 產品經理如何幫助減少技術債務 ?
- 產量減少全球葡萄酒價格或上漲
- Oracle歸檔日誌所在目錄時間不對&&Oracle叢集日誌時間顯示錯誤Oracle