select語句寫redolog的條件

來源:互聯網
上載者:User

通過測試,我們發現select 語句在執行for update的時候會寫REDOLOG,以下是測試結果:

SQL> desc test
 Name                                                              Null?    Type
 ----------------------------------------------------------------- -------- --------------------------------------------
 NAME                                                                       VARCHAR2(20)
 CHENFENG                                                                   DATE

SQL> select name,count(*) from test group by name;

NAME                   COUNT(*)
-------------------- ----------
msptest                       1
tsptest                    1034

SQL> select * from test where name='msptest';

NAME                 CHENFENG
-------------------- -------------------
msptest              2004-05-10:04:00:43

SQL> select name,value from v$mystat, v$statname where v$mystat.statistic# = v$statname.statistic# and v$statname.name like '%redo%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
redo synch writes                                                         1
redo synch time                                                           1
redo entries                                                              3
redo size                                                               532
redo buffer allocation retries                                            0
redo wastage                                                              0
redo writer latching time                                                 0
redo writes                                                               0
redo blocks written                                                       0
redo write time                                                           0
redo log space requests                                                   0
redo log space wait time                                                  0
redo log switch interrupts                                                0
redo ordering marks                                                       0

14 rows selected.

不加for update的時候,得到當前select語句的redo產生量為532.

執行select ... for update後,看看redo的產生量:

SQL> select * from test where name='msptest' for update;

NAME                 CHENFENG
-------------------- -------------------
msptest              2004-05-10:04:00:43

SQL> select name,value from v$mystat, v$statname where v$mystat.statistic# = v$statname.statistic# and v$statname.name like '%redo%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
redo synch writes                                                         1
redo synch time                                                           1
redo entries                                                              4
redo size                                                               836
redo buffer allocation retries                                            0
redo wastage                                                              0
redo writer latching time                                                 0
redo writes                                                               0
redo blocks written                                                       0
redo write time                                                           0
redo log space requests                                                   0
redo log space wait time                                                  0
redo log switch interrupts                                                0
redo ordering marks                                                       0

14 rows selected.

產生量增加到了836,這說明select ... for update操作會寫一定量的redo.

我們執行rollback後,看一下redo的產生量:

SQL> rollback;

Rollback complete.

SQL> select name,value from v$mystat, v$statname where v$mystat.statistic# = v$statname.statistic# and v$statname.name like '%redo%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
redo synch writes                                                         2
redo synch time                                                           2
redo entries                                                              6
redo size                                                              1088
redo buffer allocation retries                                            0
redo wastage                                                              0
redo writer latching time                                                 0
redo writes                                                               0
redo blocks written                                                       0
redo write time                                                           0
redo log space requests                                                   0
redo log space wait time                                                  0
redo log switch interrupts                                                0
redo ordering marks                                                       0

14 rows selected.

SQL>  select name,value from v$mystat, v$statname where v$mystat.statistic# = v$statname.statistic# and v$statname.name like '%redo%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
redo synch writes                                                         2
redo synch time                                                           2
redo entries                                                              6
redo size                                                              1088
redo buffer allocation retries                                            0
redo wastage                                                              0
redo writer latching time                                                 0
redo writes                                                               0
redo blocks written                                                       0
redo write time                                                           0
redo log space requests                                                   0
redo log space wait time                                                  0
redo log switch interrupts                                                0
redo ordering marks                                                       0

14 rows selected. 

結果表明rollback或commit操作也會寫一定量的redo.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.