The size of Oracle archived logs is much smaller than that of online logs.

Source: Internet
Author: User

The size of Oracle archived logs is much smaller than that of online logs.

Some users may be confused about the size of archived logs smaller than those of online logs:

First, check whether your archive log files are compressed:
SELECT to_char (first_time, 'yyyy-mm-dd hh24: mi: ss'), blocks * block_size/1024/1024, compressed from v $ archived_log;

If not, this issue may be related to the number of CPUs.
Check the number of CPUs:
Show parameter CPU_COUNT

The size of the archived log is the actual usage of the online log file, that is, the size of the content written before the online Log File switch.
However, in order to better reduce conflicts in parallel, Oracle splits each 16 CPUs into one strand (strand), and each strand independently allocates a portion of space from the redo buffer and redo log, when this redo buffer is used up, it will write the redo log and continue to allocate the same size of space from the redo log. If the free space cannot be allocated, it will switch the log, regardless of whether other strand files are written.
The following example illustrates the algorithm:
For example, if the number of CPUs is 64, there will be 64/16 = 4 strand
Example 1) when the log buffer size and redo log file size are both 256 M, each strand is M/4 = 64 M.
When each redo log file is enabled, the size of the redo log file is allocated 4 64M in advance, which corresponds to the log buffer,

Because the size of log buffer and redo log file are both 256 MB, there is no available unallocated space in the redo log file.

Redo generated by each process is allocated to one strand in 1, 2, 3, and 4 of the log buffer. A single process can only correspond to one strand,
In this way, when there are many redo operations generated by only some processes in the database (for example, in extreme cases, there is only one process), one of the strand will be quickly full, compared to strand 1 in the database:

When it is fully written, LGWR will write the strand 1 content in the log buffer to the redo log file and try to allocate a new 64 m space from the redo log file, write All strand content to the log and perform log switching.

In this way, the redo log file may write only one strand content. If the other part is almost empty, the generated archive log will be close to 64 M instead of 256 M.
When CPU_COUNT is large, the difference value is greater.

Example 2) when the size of log buffer is 256 M and the size of redo log file is 1 GB, each strand is still 256 M/4 = 64 M.
When each redo log file is enabled, the size of the redo log file is allocated 4 64M in advance, which corresponds to the log buffer,

In this case, the redo log file contains 1G-256 M = 768M of unallocated space.


If strand 1 is fully written, LGWR writes the strand 1 content in log buffer to the redo log file and tries to allocate a new 64 m space from the redo log file, and then keep writing down.

Until there is no allocable space in the redo log file, write all the content in strand into the log and switch the log.

 


Example 3) when the size of log buffer is 256 M and the size of redo log file is 256 M, each strand is still M/4 = 64 M.
However, the space in the redo log file will be allocated evenly based on the number of strand, that is, 100 M/4 = 25 M each piece.

In this way, when the content in each strand is written to 25 MB, the log is switched instead of 64 MB. This is equivalent to a waste of space in log buffer.

See the following documents:
1. Archive Logs Are Created With Smaller, Uneven Size Than The Original Redo Logs. Why? (Docid 388627.1)
With a high CPU_COUNT, a low load and a redo log file size smaller than the redolog buffer, you may small archived log files because of log switches at about 1/8 of the size of the define log file size.
This is because CPU_COUNT defines the number of redo strands (ncpus/16 ). with a low load only a single strand may be used. with redo log file size smaller than the redolog buffer, the log file space is divided over the available strands. when for instance only a single active strand is used, a log switch can already occur when that strand is filled.

<= High CPU_COUNT and low workload (in fact, the database is not necessarily busy, but when there are few redo processes), Archive logs are much smaller than redo logs, in addition, logs are frequently switched.

2. Archived redolog is (signiticant) smaller than the redologfile. (Doc ID 1356604.1)
The logfile space reservation algorithm
If the logfile is smaller than the log buffer, then the whole logfile space is divided/mapped/reserved equally among all the strands, and there is no unreserved space (ie no log residue ).
When any process fills a strand such that all the reserved underlying logfile space for that strand is used, AND there is no log residue, then a log switch is scheduled.

<= The algorithm of log strand and log switch is more clear in this note.

The strand here is shared. Redo strand refers to dividing the redo buffer into multiple blocks. Log strand refers to dividing logs into multiple bands.
Multiple processes share one strand, but one process can only use one strand, but not both.

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.