Comparison of the two modes:
Statement Advantages
long history, mature technology;
The resulting binlog file is small;
The binlog contains all the database modification information, which can be used to audit the database security and so on.
Binlog can be used for real-time restores, not just for replication;
Master-slave version can be different from the server version can be higher than the main server version;
Statement Disadvantages:
Not all UPDATE statements can be copied, especially when there is an indeterminate operation;
Replication may also occur when invoking a UDF with uncertainties;
Statements that use the following functions cannot be duplicated:
* Load_file ()
* UUID ()
* USER ()
* Found_rows ()
* Sysdate () (unless the –sysdate-is-now option is enabled at startup)
INSERT ... SELECT produces more row-level locks than RBR;
Replication requires more row-level locks than row requests when performing a full-table scan (where the index is not used in the) UPDATE;
For InnoDB tables with auto_increment fields, the INSERT statement blocks other INSERT statements;
For some complex statements, the consumption of resources from the server will be more serious, and in row mode, only the change of the record will have an impact;
A stored function (not a stored procedure) executes the now () function at the same time it is called, which can be said to be bad or good;
The identified UDF also needs to be executed from the server;
The data table must be almost consistent with the primary server, or it may cause replication errors;
Executing complex statements can consume more resources if there is an error;
Row Advantages
Any situation can be copied, which is the most safe and reliable for replication;
As with most other database systems, as well as replication skills;
In most cases, the copy will be much faster if there is a primary key from the table on the server.
There are fewer row locks when copying the following statements:
* INSERT ... SELECT
* INSERT containing the auto_increment field
* UPDATE or DELETE statements with no strings attached or changes to many records
Fewer locks when executing insert,update,delete statements;
It is possible to perform replication from a server with multithreading;
Row Disadvantage
The generated Binlog log volume is much larger;
A complex rollback will contain a large amount of data in the Binlog;
When an UPDATE statement is executed on the primary server, all changed records are written to Binlog, and statement is only written once, which results in frequent binlog write concurrent requests;
Large BLOB values produced by UDFs can cause replication to become slower;
Can not see from the Binlog to copy what statements (encrypted);
When executing a stack of SQL statements on a non-transactional table, it is best to adopt statement mode, otherwise it is easy to cause the data inconsistency of the master-slave server;
In addition, for the system library MySQL inside the table changes when the processing criteria are as follows:
If the use of Insert,update,delete direct operation of the table, the log format according to the Binlog_format set up records;
If the use of Grant,revoke,set PASSWORD and other management statements to do, then in any case to use the statement mode record;
With statement mode, you can handle many of the original primary key duplication problems
MySQL Binlog_format row and Statement comparison