What happened when Oracle commit

Source: Internet
Author: User

1. Understand When logws write redo logs into the redo log file in the redo log buffer to understand commit;

  • Write when redo log buffer 1/3 is full
  • Write at commit
  • When a log switch occurs, write
  • Write when the generated redo is 1 MB
  • When DBWN is to be written, write redo first.
  • Write every 3 seconds

That is to say, redo writes log files in a relatively continuous manner. Therefore, no matter how many redo records a transaction generates, the work done in commit is similar, because the redo logs of large departments have been written into log files.

2. What happened during commit?

  • Write the SCN number to the log file
  • LGWN writes the remaining redo to the log file
  • All locks are released
  • To clear blocks. Block Clearing refers to clearing the transaction information stored in this block.

Therefore, in fact, there is very little work done each time a commit is made. The biggest task is to write the redo into the log file, but the redo has been written to the log file by many departments. But this does not mean that, each time you modify a block, you must go to commit to increase competition for log files (log files are a shared structure ), it also adds competition for latches (protecting access to the shared structure ). Therefore, we should decide when to commit based on the size of the logical transaction.

3. In the following example, a redo of different sizes is generated to indicate that during the submission, the work time is almost the same.

S1: create a large table

  1. Scott @ WISON>Create TableTAs Select*FromAll_objects;
  2. TableCreated.
  3. Scott @ WISON>
S2: Create a table t_10 that needs to insert 10 rows of data and set automatic tracing.
  1. Scott @ WISON>Create TableT_10As Select*FromTWhere1 = 0;
  2. TableCreated.
  3. Scott @ WISON>SetAutotraceOn Statistics;
  4. Scott @ WISON>SetTimingOn
  5. Scott @ WISON>Insert IntoT_10Select*FromTWhereRownum <= 10;
  6. 10RowsCreated.
  7. <Strong> Elapsed: 00:00:00. 06 insert time
  8. </Strong>
  9. Statistics
  10. ----------------------------------------------------------
  11. 451 recursive cballs
  12. 56 db block gets
  13. 337 consistent gets
  14. 1 physical reads
  15. & Lt; strong & gt; 7284 redoSize</Strong>
  16. 919 bytes sent via SQL * NetToClient
  17. 1018 bytes encoded ed via SQL * NetFromClient
  18. 4 SQL * Net roundtripsTo/FromClient
  19. 2 sorts (memory)
  20. 0 sorts (disk)
  21. 10RowsProcessed
  22. Scott @ WISON>Commit;
  23. CommitComplete.
  24. Elapsed: 00:00:00. 00
S3: insert row 1000
  1. Scott @ WISON>Insert IntoT_10Select*FromTWhereRownum <= 1000;
  2. 1000RowsCreated.
  3. Elapsed: 00:00:00. 02
  4. Statistics
  5. ----------------------------------------------------------
  6. 39 recursive cballs
  7. 143 db block gets
  8. 180 consistent gets
  9. 7 physical reads
  10. & Lt; strong & gt; 104880 redoSize
  11. </Strong> 919 bytes sent via SQL * NetToClient
  12. 1020 bytes encoded ed via SQL * NetFromClient
  13. 4 SQL * Net roundtripsTo/FromClient
  14. 1 sorts (memory)
  15. 0 sorts (disk)
  16. 1000RowsProcessed
  17. Scott @ WISON>Commit;
  18. CommitComplete.
  19. <Strong> Elapsed: 00:00:00. 12 </strong>
  20. Scott @ WISON>
Insert row 10000
  1. Scott @ WISON>Insert IntoT_10Select*FromTWhereRownum <= 10000;
  2. 10000RowsCreated.
  3. Elapsed: 00:00:00. 10
  4. Statistics
  5. ----------------------------------------------------------
  6. 487 recursive cballs
  7. 1808 db block gets
  8. 596 consistent gets
  9. 121 physical reads
  10. & Lt; strong & gt; 1102708 redoSize
  11. </Strong> 919 bytes sent via SQL * NetToClient
  12. 1021 bytes encoded ed via SQL * NetFromClient
  13. 4 SQL * Net roundtripsTo/FromClient
  14. 1 sorts (memory)
  15. 0 sorts (disk)
  16. 10000RowsProcessed
  17. Scott @ WISON>Commit;
  18. CommitComplete.
  19. <Strong> Elapsed: 00:00:00. 01 </strong>
  20. Scott @ WISON>
We found that the time for inserting 10 rows, 1000 rows, 10000 rows, and commit is very short.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.