02 | log system: how to update a SQL statement is executed?

A, mysql update

We start with an updated table to begin with, the following statement is to build a table, the table has a primary key ID and an integer field c;

create table T(ID int primary kry,c int);
insert into T(c) values(1);

If you want to ID = 2 this line plus the value of 1, SQL statement will be written so

update T set c=2 where ID=0;

Mysql statement update process has two important log modules: redo log (redo logs) and binlog (archive log). If the contact MySQL, then these two words are certainly around, but

Second, the important log module

1、redo log

InnoDB redo log is a log module built in, his size is fixed, does not support the persistent storage, such as files arranged in groups of four, each file is 1GB, the recording operation can then 4G, and writes to the end to start the cycle over again, as shown in Fig.

 

write pos is the current record position, while writing while moving backward, he wrote at the end of the third file number when he returned to the beginning of file number 0. checkpoint is to be erased, the current position, is moved back and circulated, before erasing the recording should be updated to record the data file on the hard disk.
is a blank portion between write pos and checkpoint, to record a new operation. If you write pos catch checkpoint, said this document as well as 4G filled, and this time it can not perform the update, you need checkpoint data push, leaving out certain spatial location.
With the redo log, InnoDB database can ensure that even sending abnormal restart, the previous record submitted will not be lost.

 

Guess you like

Origin www.cnblogs.com/charon2/p/11755413.html