The reason why MySQL does not change from the database com_insert is that com_insert and other com_xxx parameters can be used to monitor the access volume of database instances, that is, the QPS we often call. Based on the MySQL replication principle, all operations performed by the master database are replayed from the slave database to ensure data consistency. Therefore, the com_insert of the master database and the com_insert of the slave database should be equal in theory.
As shown below, the second column represents the master database, and the third column represents the slave database:
com_select22 1138com_update36 37com_insert 133135com_delete 00qcache_hits00Com_replace00Connections 13 24
But let's look at another business:
com_select 0 95com_update 00com_insert920com_delete200qcache_hits06Com_replace00Connections06
We can clearly see that the master database has 92 writes but 0 writes from the database. why?
The only difference between the two businesses is that the binlog_format settings are different.
First Business
Show global variables like '% binlog_format %'; + --------------- + ----------- + | Variable_name | Value | + --------------- + --------- + | binlog_format | STATEMENT | + --------------- + ------------- +
Second business
Show global variables like '% binlog_format %'; + --------------- + ------- + | Variable_name | Value | + --------------- + ------- + | binlog_format | ROW | + --------------- + ------- +
Let's take a look at the definition of the official com_xxx document:
The Com_xxx statement counter variables indicate the number of times each xxx statement has been executed. There is one status variable for each type of statement. For example, Com_delete and Com_update count DELETE and UPDATE statements, respectively. Com_delete_multi and Com_update_multi are similar but apply to DELETE and UPDATE statements that use multiple-table syntax.
From the above documents, we can only see how com_xxx works, but it does not explain why com_insert does not change after RBR is used.
Next, let's take a look at the following documents.
You cannot examine the logs to see what statements were executed, nor can you see on the slave what statements were received from the master and executed.However, you can see what data was changed using mysqlbinlog with the options --base64-output=DECODE-ROWS and --verbose.
The reason for combining the two paragraphs is as follows:
1. the statement is received on the master database. Therefore, com_insert meets the trigger conditions and will increase as the business grows.
2. the slave database obtains the binlog of the master database and replays the updated data. However, the log format of the master database is row format. as a result, the statement is not recorded in the binlog, it is a data change record.
3. Although the slave database can still update records, the data changes cannot be parsed because of one statement or multiple statment statements, therefore, the statment counter of com_insert is not updated.
Basically, inferences are in line with the actual situation, but there is no code to prove, it is a pity.
In addition, if we cannot monitor the write status of the slave database through com_insert, what status should we monitor?
We recommend that you monitor the write status of instances in row format by monitoring innodb_rows_inserted.
show global status like 'innodb_rows_inserted';+----------------------+------------+| Variable_name| Value|+----------------------+------------+| Innodb_rows_inserted | 2666049650 |+----------------------+------------+
Appendix: (link to the official documents of the two documents)
Http://dev.mysql.com/doc/refman/5.6/en/server-status-variables.html#statvar_Com_xxx
Http://dev.mysql.com/doc/refman/5.5/en/replication-sbr-rbr.html