环境说明
MySQL8.0
1、binlog_format为ROW
A.查看相关参数值
mysql> show variables like 'binlog_row_image';+------------------+-------+| Variable_name | Value |+------------------+-------+| binlog_row_image | FULL |+------------------+-------+1 row in set, 1 warning (0.00 sec)mysql> show variables like 'binlog_format';+---------------+-------+| Variable_name | Value |+---------------+-------+| binlog_format | ROW |+---------------+-------+1 row in set, 1 warning (0.00 sec)mysql> show variables like 'transaction_isolation';+-----------------------+-----------------+| Variable_name | Value |+-----------------------+-----------------+| transaction_isolation | REPEATABLE-READ |+-----------------------+-----------------+1 row in set, 1 warning (0.00 sec)
B.测试步骤
session1:select
mysql> use test;Database changedmysql> select * from user where id = 1;+----+---------+-----+------+---------------------+-----------+| id | user_id | age | name | login_time | address |+----+---------+-----+------+---------------------+-----------+| 1 | 11 | 18 | Fc | 2020-07-23 22:16:57 | 北京市 |+----+---------+-----+------+---------------------+-----------+1 row in set (0.00 sec)mysql> show engine innodb status\Gshow master status\G*************************** 1. row ***************************Type: InnoDBName:Status:=====================================2020-07-24 14:17:04 0x3b50 INNODB MONITOR OUTPUT=====================================Per second averages calculated from the last 2 seconds-----------------BACKGROUND THREAD-----------------srv_master_thread loops: 17 srv_active, 0 srv_shutdown, 23290 srv_idlesrv_master_thread log flush and writes: 0----------SEMAPHORES----------OS WAIT ARRAY INFO: reservation count 12OS WAIT ARRAY INFO: signal count 11RW-shared spins 0, rounds 0, OS waits 0RW-excl spins 125, rounds 242, OS waits 1RW-sx spins 0, rounds 0, OS waits 0Spin rounds per wait: 0.00 RW-shared, 1.94 RW-excl, 0.00 RW-sx------------TRANSACTIONS------------Trx id counter 16774Purge done for trx's n:o < 16773 undo n:o < 0 state: running but idleHistory list length 54LIST OF TRANSACTIONS FOR EACH SESSION:---TRANSACTION 283929911700120, not started0 lock struct(s), heap size 1136, 0 row lock(s)---TRANSACTION 283929911699248, not started0 lock struct(s), heap size 1136, 0 row lock(s)--------FILE I/O--------I/O thread 0 state: wait Windows aio (insert buffer thread)I/O thread 1 state: wait Windows aio (log thread)I/O thread 2 state: wait Windows aio (read thread)I/O thread 3 state: wait Windows aio (read thread)I/O thread 4 state: wait Windows aio (read thread)I/O thread 5 state: wait Windows aio (read thread)I/O thread 6 state: wait Windows aio (write thread)I/O thread 7 state: wait Windows aio (write thread)I/O thread 8 state: wait Windows aio (write thread)I/O thread 9 state: wait Windows aio (write thread)Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,ibuf aio reads:, log i/o's:, sync i/o's:Pending flushes (fsync) log: 0; buffer pool: 01065 OS file reads, 1161 OS file writes, 330 OS fsyncs0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s-------------------------------------INSERT BUFFER AND ADAPTIVE HASH INDEX-------------------------------------Ibuf: size 1, free list len 0, seg size 2, 0 mergesmerged operations:insert 0, delete mark 0, delete 0discarded operations:insert 0, delete mark 0, delete 0Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 6 buffer(s)0.00 hash searches/s, 0.00 non-hash searches/s---LOG---Log sequence number 34446419Log buffer assigned up to 34446419Log buffer completed up to 34446419Log written up to 34446419Log flushed up to 34446419Added dirty pages up to 34446419Pages flushed up to 34446419Last checkpoint at 34446419330 log i/o's done, 0.00 log i/o's/second----------------------BUFFER POOL AND MEMORY----------------------Total large memory allocated 137363456Dictionary memory allocated 429080Buffer pool size 8192Free buffers 6969Database pages 1212Old database pages 458Modified db pages 0Pending reads 0Pending writes: LRU 0, flush list 0, single page 0Pages made young 1, not young 00.00 youngs/s, 0.00 non-youngs/sPages read 1042, created 170, written 7230.00 reads/s, 0.00 creates/s, 0.00 writes/sNo buffer pool page gets since the last printoutPages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/sLRU len: 1212, unzip_LRU len: 0I/O sum[0]:cur[0], unzip sum[0]:cur[0]--------------ROW OPERATIONS--------------0 queries inside InnoDB, 0 queries in queue0 read views open inside InnoDBProcess ID=472, Main thread ID=00000000000039CC , state=sleepingNumber of rows inserted 246, updated 426, deleted 194, read 338390.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s----------------------------END OF INNODB MONITOR OUTPUT============================1 row in set (0.00 sec)*************************** 1. row ***************************File: binlog.000021Position: 3434Binlog_Do_DB:Binlog_Ignore_DB:Executed_Gtid_Set:1 row in set (0.00 sec)mysql>
session2:update
mysql> update user set user_id = 11 where id = 1;Query OK, 0 rows affected (0.00 sec)Rows matched: 1 Changed: 0 Warnings: 0mysql> show engine innodb status\Gshow master status\G*************************** 1. row ***************************Type: InnoDBName:Status:=====================================2020-07-24 14:21:11 0x3b50 INNODB MONITOR OUTPUT=====================================Per second averages calculated from the last 3 seconds-----------------BACKGROUND THREAD-----------------srv_master_thread loops: 17 srv_active, 0 srv_shutdown, 23537 srv_idlesrv_master_thread log flush and writes: 0----------SEMAPHORES----------OS WAIT ARRAY INFO: reservation count 12OS WAIT ARRAY INFO: signal count 11RW-shared spins 0, rounds 0, OS waits 0RW-excl spins 125, rounds 242, OS waits 1RW-sx spins 0, rounds 0, OS waits 0Spin rounds per wait: 0.00 RW-shared, 1.94 RW-excl, 0.00 RW-sx------------TRANSACTIONS------------Trx id counter 16775Purge done for trx's n:o < 16773 undo n:o < 0 state: running but idleHistory list length 54LIST OF TRANSACTIONS FOR EACH SESSION:---TRANSACTION 283929911700120, not started0 lock struct(s), heap size 1136, 0 row lock(s)---TRANSACTION 283929911699248, not started0 lock struct(s), heap size 1136, 0 row lock(s)--------FILE I/O--------I/O thread 0 state: wait Windows aio (insert buffer thread)I/O thread 1 state: wait Windows aio (log thread)I/O thread 2 state: wait Windows aio (read thread)I/O thread 3 state: wait Windows aio (read thread)I/O thread 4 state: wait Windows aio (read thread)I/O thread 5 state: wait Windows aio (read thread)I/O thread 6 state: wait Windows aio (write thread)I/O thread 7 state: wait Windows aio (write thread)I/O thread 8 state: wait Windows aio (write thread)I/O thread 9 state: wait Windows aio (write thread)Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,ibuf aio reads:, log i/o's:, sync i/o's:Pending flushes (fsync) log: 0; buffer pool: 01065 OS file reads, 1161 OS file writes, 330 OS fsyncs0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s-------------------------------------INSERT BUFFER AND ADAPTIVE HASH INDEX-------------------------------------Ibuf: size 1, free list len 0, seg size 2, 0 mergesmerged operations:insert 0, delete mark 0, delete 0discarded operations:insert 0, delete mark 0, delete 0Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 6 buffer(s)0.00 hash searches/s, 0.00 non-hash searches/s---LOG---Log sequence number 34446419Log buffer assigned up to 34446419Log buffer completed up to 34446419Log written up to 34446419Log flushed up to 34446419Added dirty pages up to 34446419Pages flushed up to 34446419Last checkpoint at 34446419330 log i/o's done, 0.00 log i/o's/second----------------------BUFFER POOL AND MEMORY----------------------Total large memory allocated 137363456Dictionary memory allocated 429080Buffer pool size 8192Free buffers 6969Database pages 1212Old database pages 458Modified db pages 0Pending reads 0Pending writes: LRU 0, flush list 0, single page 0Pages made young 1, not young 00.00 youngs/s, 0.00 non-youngs/sPages read 1042, created 170, written 7230.00 reads/s, 0.00 creates/s, 0.00 writes/sNo buffer pool page gets since the last printoutPages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/sLRU len: 1212, unzip_LRU len: 0I/O sum[0]:cur[0], unzip sum[0]:cur[0]--------------ROW OPERATIONS--------------0 queries inside InnoDB, 0 queries in queue0 read views open inside InnoDBProcess ID=472, Main thread ID=00000000000039CC , state=sleepingNumber of rows inserted 246, updated 426, deleted 194, read 338400.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s----------------------------END OF INNODB MONITOR OUTPUT============================1 row in set (0.00 sec)*************************** 1. row ***************************File: binlog.000021Position: 3434Binlog_Do_DB:Binlog_Ignore_DB:Executed_Gtid_Set:1 row in set (0.00 sec)mysql>
session3:update
mysql> update user set user_id = 11 where id = 1;Query OK, 0 rows affected (0.00 sec)Rows matched: 1 Changed: 0 Warnings: 0mysql> show engine innodb status\Gshow master status\G*************************** 1. row ***************************Type: InnoDBName:Status:=====================================2020-07-24 14:28:37 0x3b50 INNODB MONITOR OUTPUT=====================================Per second averages calculated from the last 19 seconds-----------------BACKGROUND THREAD-----------------srv_master_thread loops: 17 srv_active, 0 srv_shutdown, 23983 srv_idlesrv_master_thread log flush and writes: 0----------SEMAPHORES----------OS WAIT ARRAY INFO: reservation count 12OS WAIT ARRAY INFO: signal count 11RW-shared spins 0, rounds 0, OS waits 0RW-excl spins 125, rounds 242, OS waits 1RW-sx spins 0, rounds 0, OS waits 0Spin rounds per wait: 0.00 RW-shared, 1.94 RW-excl, 0.00 RW-sx------------TRANSACTIONS------------Trx id counter 16776Purge done for trx's n:o < 16773 undo n:o < 0 state: running but idleHistory list length 54LIST OF TRANSACTIONS FOR EACH SESSION:---TRANSACTION 283929911700120, not started0 lock struct(s), heap size 1136, 0 row lock(s)---TRANSACTION 283929911699248, not started0 lock struct(s), heap size 1136, 0 row lock(s)--------FILE I/O--------I/O thread 0 state: wait Windows aio (insert buffer thread)I/O thread 1 state: wait Windows aio (log thread)I/O thread 2 state: wait Windows aio (read thread)I/O thread 3 state: wait Windows aio (read thread)I/O thread 4 state: wait Windows aio (read thread)I/O thread 5 state: wait Windows aio (read thread)I/O thread 6 state: wait Windows aio (write thread)I/O thread 7 state: wait Windows aio (write thread)I/O thread 8 state: wait Windows aio (write thread)I/O thread 9 state: wait Windows aio (write thread)Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,ibuf aio reads:, log i/o's:, sync i/o's:Pending flushes (fsync) log: 0; buffer pool: 01065 OS file reads, 1161 OS file writes, 330 OS fsyncs0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s-------------------------------------INSERT BUFFER AND ADAPTIVE HASH INDEX-------------------------------------Ibuf: size 1, free list len 0, seg size 2, 0 mergesmerged operations:insert 0, delete mark 0, delete 0discarded operations:insert 0, delete mark 0, delete 0Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 6 buffer(s)0.00 hash searches/s, 0.05 non-hash searches/s---LOG---Log sequence number 34446419Log buffer assigned up to 34446419Log buffer completed up to 34446419Log written up to 34446419Log flushed up to 34446419Added dirty pages up to 34446419Pages flushed up to 34446419Last checkpoint at 34446419330 log i/o's done, 0.00 log i/o's/second----------------------BUFFER POOL AND MEMORY----------------------Total large memory allocated 137363456Dictionary memory allocated 429080Buffer pool size 8192Free buffers 6969Database pages 1212Old database pages 458Modified db pages 0Pending reads 0Pending writes: LRU 0, flush list 0, single page 0Pages made young 1, not young 00.00 youngs/s, 0.00 non-youngs/sPages read 1042, created 170, written 7230.00 reads/s, 0.00 creates/s, 0.00 writes/sBuffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/sLRU len: 1212, unzip_LRU len: 0I/O sum[0]:cur[0], unzip sum[0]:cur[0]--------------ROW OPERATIONS--------------0 queries inside InnoDB, 0 queries in queue0 read views open inside InnoDBProcess ID=472, Main thread ID=00000000000039CC , state=sleepingNumber of rows inserted 246, updated 426, deleted 194, read 338410.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.05 reads/s----------------------------END OF INNODB MONITOR OUTPUT============================1 row in set (0.00 sec)*************************** 1. row ***************************File: binlog.000021Position: 3434Binlog_Do_DB:Binlog_Ignore_DB:Executed_Gtid_Set:1 row in set (0.00 sec)mysql>

对比session2中的upadted发现updated一致
C.总结
在**binlog_format=row**和**binlog_row_image=FULL**时,由于MySQL 需要在 binlog 里面记录所有的字段,所以在读数据的时候就会把所有数据都读出来,那么重复数据的update不会执行。
即MySQL 调用了 InnoDB 引擎提供的“修改为 (1,11)”这个接口,但是引擎发现值与原来相同,不更新,直接返回。
2、binlog_format为STATEMENT
A.查看相关参数值
mysql> set session binlog_format = statement;Query OK, 0 rows affected (0.00 sec)mysql> show variables like 'binlog_row_image';+------------------+-------+| Variable_name | Value |+------------------+-------+| binlog_row_image | FULL |+------------------+-------+1 row in set, 1 warning (0.00 sec)mysql> show variables like 'binlog_format';+---------------+-----------+| Variable_name | Value |+---------------+-----------+| binlog_format | STATEMENT |+---------------+-----------+1 row in set, 1 warning (0.00 sec)mysql> show variables like 'transaction_isolation';+-----------------------+-----------------+| Variable_name | Value |+-----------------------+-----------------+| transaction_isolation | REPEATABLE-READ |+-----------------------+-----------------+1 row in set, 1 warning (0.00 sec)mysql>
B.测试步骤
session1:select
mysql> select * from user where id = 1;+----+---------+-----+------+---------------------+-----------+| id | user_id | age | name | login_time | address |+----+---------+-----+------+---------------------+-----------+| 1 | 11 | 18 | Fc | 2020-07-23 22:16:57 | 北京市 |+----+---------+-----+------+---------------------+-----------+1 row in set (0.00 sec)mysql> show engine innodb status\Gshow master status\G*************************** 1. row ***************************Type: InnoDBName:Status:=====================================2020-07-24 15:04:07 0x3b50 INNODB MONITOR OUTPUT=====================================Per second averages calculated from the last 56 seconds-----------------BACKGROUND THREAD-----------------srv_master_thread loops: 21 srv_active, 0 srv_shutdown, 26107 srv_idlesrv_master_thread log flush and writes: 0----------SEMAPHORES----------OS WAIT ARRAY INFO: reservation count 12OS WAIT ARRAY INFO: signal count 11RW-shared spins 0, rounds 0, OS waits 0RW-excl spins 125, rounds 242, OS waits 1RW-sx spins 0, rounds 0, OS waits 0Spin rounds per wait: 0.00 RW-shared, 1.94 RW-excl, 0.00 RW-sx------------TRANSACTIONS------------Trx id counter 16847Purge done for trx's n:o < 16779 undo n:o < 0 state: running but idleHistory list length 87LIST OF TRANSACTIONS FOR EACH SESSION:---TRANSACTION 283929911699248, not started0 lock struct(s), heap size 1136, 0 row lock(s)---TRANSACTION 283929911700120, not started0 lock struct(s), heap size 1136, 0 row lock(s)--------FILE I/O--------I/O thread 0 state: wait Windows aio (insert buffer thread)I/O thread 1 state: wait Windows aio (log thread)I/O thread 2 state: wait Windows aio (read thread)I/O thread 3 state: wait Windows aio (read thread)I/O thread 4 state: wait Windows aio (read thread)I/O thread 5 state: wait Windows aio (read thread)I/O thread 6 state: wait Windows aio (write thread)I/O thread 7 state: wait Windows aio (write thread)I/O thread 8 state: wait Windows aio (write thread)I/O thread 9 state: wait Windows aio (write thread)Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,ibuf aio reads:, log i/o's:, sync i/o's:Pending flushes (fsync) log: 0; buffer pool: 01122 OS file reads, 1306 OS file writes, 400 OS fsyncs0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s-------------------------------------INSERT BUFFER AND ADAPTIVE HASH INDEX-------------------------------------Ibuf: size 1, free list len 0, seg size 2, 0 mergesmerged operations:insert 0, delete mark 0, delete 0discarded operations:insert 0, delete mark 0, delete 0Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 7 buffer(s)0.00 hash searches/s, 0.00 non-hash searches/s---LOG---Log sequence number 34458677Log buffer assigned up to 34458677Log buffer completed up to 34458677Log written up to 34458677Log flushed up to 34458677Added dirty pages up to 34458677Pages flushed up to 34458677Last checkpoint at 34458677392 log i/o's done, 0.00 log i/o's/second----------------------BUFFER POOL AND MEMORY----------------------Total large memory allocated 137363456Dictionary memory allocated 473442Buffer pool size 8192Free buffers 6911Database pages 1267Old database pages 487Modified db pages 0Pending reads 0Pending writes: LRU 0, flush list 0, single page 0Pages made young 1, not young 00.00 youngs/s, 0.00 non-youngs/sPages read 1097, created 170, written 7970.00 reads/s, 0.00 creates/s, 0.00 writes/sNo buffer pool page gets since the last printoutPages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/sLRU len: 1267, unzip_LRU len: 0I/O sum[0]:cur[0], unzip sum[0]:cur[0]--------------ROW OPERATIONS--------------0 queries inside InnoDB, 0 queries in queue0 read views open inside InnoDBProcess ID=472, Main thread ID=00000000000039CC , state=sleepingNumber of rows inserted 250, updated 459, deleted 194, read 538260.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s----------------------------END OF INNODB MONITOR OUTPUT============================1 row in set (0.00 sec)*************************** 1. row ***************************File: binlog.000021Position: 3434Binlog_Do_DB:Binlog_Ignore_DB:Executed_Gtid_Set:1 row in set (0.00 sec)
session2:update
mysql> update user set user_id = 111 where id = 1;Query OK, 1 row affected (0.01 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> show engine innodb status\Gshow master status\G*************************** 1. row ***************************Type: InnoDBName:Status:=====================================2020-07-24 15:12:04 0x3b50 INNODB MONITOR OUTPUT=====================================Per second averages calculated from the last 34 seconds-----------------BACKGROUND THREAD-----------------srv_master_thread loops: 24 srv_active, 0 srv_shutdown, 26580 srv_idlesrv_master_thread log flush and writes: 0----------SEMAPHORES----------OS WAIT ARRAY INFO: reservation count 18OS WAIT ARRAY INFO: signal count 17RW-shared spins 0, rounds 0, OS waits 0RW-excl spins 125, rounds 242, OS waits 1RW-sx spins 0, rounds 0, OS waits 0Spin rounds per wait: 0.00 RW-shared, 1.94 RW-excl, 0.00 RW-sx------------TRANSACTIONS------------Trx id counter 16853Purge done for trx's n:o < 16853 undo n:o < 0 state: running but idleHistory list length 90LIST OF TRANSACTIONS FOR EACH SESSION:---TRANSACTION 283929911699248, not started0 lock struct(s), heap size 1136, 0 row lock(s)---TRANSACTION 283929911700120, not started0 lock struct(s), heap size 1136, 0 row lock(s)--------FILE I/O--------I/O thread 0 state: wait Windows aio (insert buffer thread)I/O thread 1 state: wait Windows aio (log thread)I/O thread 2 state: wait Windows aio (read thread)I/O thread 3 state: wait Windows aio (read thread)I/O thread 4 state: wait Windows aio (read thread)I/O thread 5 state: wait Windows aio (read thread)I/O thread 6 state: wait Windows aio (write thread)I/O thread 7 state: wait Windows aio (write thread)I/O thread 8 state: wait Windows aio (write thread)I/O thread 9 state: wait Windows aio (write thread)Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,ibuf aio reads:, log i/o's:, sync i/o's:Pending flushes (fsync) log: 0; buffer pool: 01122 OS file reads, 1335 OS file writes, 420 OS fsyncs0.00 reads/s, 0 avg bytes/read, 0.35 writes/s, 0.21 fsyncs/s-------------------------------------INSERT BUFFER AND ADAPTIVE HASH INDEX-------------------------------------Ibuf: size 1, free list len 0, seg size 2, 0 mergesmerged operations:insert 0, delete mark 0, delete 0discarded operations:insert 0, delete mark 0, delete 0Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 7 buffer(s)0.00 hash searches/s, 0.21 non-hash searches/s---LOG---Log sequence number 34460271Log buffer assigned up to 34460271Log buffer completed up to 34460271Log written up to 34460271Log flushed up to 34460271Added dirty pages up to 34460271Pages flushed up to 34460271Last checkpoint at 34460271402 log i/o's done, 0.15 log i/o's/second----------------------BUFFER POOL AND MEMORY----------------------Total large memory allocated 137363456Dictionary memory allocated 473442Buffer pool size 8192Free buffers 6911Database pages 1267Old database pages 487Modified db pages 0Pending reads 0Pending writes: LRU 0, flush list 0, single page 0Pages made young 1, not young 00.00 youngs/s, 0.00 non-youngs/sPages read 1097, created 170, written 8100.00 reads/s, 0.00 creates/s, 0.15 writes/sBuffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/sLRU len: 1267, unzip_LRU len: 0I/O sum[0]:cur[0], unzip sum[0]:cur[0]--------------ROW OPERATIONS--------------0 queries inside InnoDB, 0 queries in queue0 read views open inside InnoDBProcess ID=472, Main thread ID=00000000000039CC , state=sleepingNumber of rows inserted 250, updated 462, deleted 194, read 538290.00 inserts/s, 0.03 updates/s, 0.00 deletes/s, 0.03 reads/s----------------------------END OF INNODB MONITOR OUTPUT============================1 row in set (0.00 sec)*************************** 1. row ***************************File: binlog.000021Position: 4419Binlog_Do_DB:Binlog_Ignore_DB:Executed_Gtid_Set:1 row in set (0.00 sec)
session3:update
mysql> update user set user_id = 111 where id = 1;Query OK, 0 rows affected (0.00 sec)Rows matched: 1 Changed: 0 Warnings: 0mysql> show engine innodb status\Gshow master status\G*************************** 1. row ***************************Type: InnoDBName:Status:=====================================2020-07-24 15:12:17 0x3b50 INNODB MONITOR OUTPUT=====================================Per second averages calculated from the last 13 seconds-----------------BACKGROUND THREAD-----------------srv_master_thread loops: 25 srv_active, 0 srv_shutdown, 26592 srv_idlesrv_master_thread log flush and writes: 0----------SEMAPHORES----------OS WAIT ARRAY INFO: reservation count 19OS WAIT ARRAY INFO: signal count 18RW-shared spins 0, rounds 0, OS waits 0RW-excl spins 125, rounds 242, OS waits 1RW-sx spins 0, rounds 0, OS waits 0Spin rounds per wait: 0.00 RW-shared, 1.94 RW-excl, 0.00 RW-sx------------TRANSACTIONS------------Trx id counter 16855Purge done for trx's n:o < 16855 undo n:o < 0 state: running but idleHistory list length 91LIST OF TRANSACTIONS FOR EACH SESSION:---TRANSACTION 283929911699248, not started0 lock struct(s), heap size 1136, 0 row lock(s)---TRANSACTION 283929911700120, not started0 lock struct(s), heap size 1136, 0 row lock(s)--------FILE I/O--------I/O thread 0 state: wait Windows aio (insert buffer thread)I/O thread 1 state: wait Windows aio (log thread)I/O thread 2 state: wait Windows aio (read thread)I/O thread 3 state: wait Windows aio (read thread)I/O thread 4 state: wait Windows aio (read thread)I/O thread 5 state: wait Windows aio (read thread)I/O thread 6 state: wait Windows aio (write thread)I/O thread 7 state: wait Windows aio (write thread)I/O thread 8 state: wait Windows aio (write thread)I/O thread 9 state: wait Windows aio (write thread)Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,ibuf aio reads:, log i/o's:, sync i/o's:Pending flushes (fsync) log: 0; buffer pool: 01122 OS file reads, 1344 OS file writes, 426 OS fsyncs0.00 reads/s, 0 avg bytes/read, 0.69 writes/s, 0.46 fsyncs/s-------------------------------------INSERT BUFFER AND ADAPTIVE HASH INDEX-------------------------------------Ibuf: size 1, free list len 0, seg size 2, 0 mergesmerged operations:insert 0, delete mark 0, delete 0discarded operations:insert 0, delete mark 0, delete 0Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 0 buffer(s)Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 1 buffer(s)Hash table size 34679, node heap has 2 buffer(s)Hash table size 34679, node heap has 7 buffer(s)0.00 hash searches/s, 0.08 non-hash searches/s---LOG---Log sequence number 34460759Log buffer assigned up to 34460759Log buffer completed up to 34460759Log written up to 34460759Log flushed up to 34460759Added dirty pages up to 34460759Pages flushed up to 34460759Last checkpoint at 34460759405 log i/o's done, 0.23 log i/o's/second----------------------BUFFER POOL AND MEMORY----------------------Total large memory allocated 137363456Dictionary memory allocated 473442Buffer pool size 8192Free buffers 6911Database pages 1267Old database pages 487Modified db pages 0Pending reads 0Pending writes: LRU 0, flush list 0, single page 0Pages made young 1, not young 00.00 youngs/s, 0.00 non-youngs/sPages read 1097, created 170, written 8140.00 reads/s, 0.00 creates/s, 0.31 writes/sBuffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/sLRU len: 1267, unzip_LRU len: 0I/O sum[0]:cur[0], unzip sum[0]:cur[0]--------------ROW OPERATIONS--------------0 queries inside InnoDB, 0 queries in queue0 read views open inside InnoDBProcess ID=472, Main thread ID=00000000000039CC , state=sleepingNumber of rows inserted 250, updated 463, deleted 194, read 538300.00 inserts/s, 0.08 updates/s, 0.00 deletes/s, 0.08 reads/s----------------------------END OF INNODB MONITOR OUTPUT============================1 row in set (0.00 sec)*************************** 1. row ***************************File: binlog.000021Position: 4748Binlog_Do_DB:Binlog_Ignore_DB:Executed_Gtid_Set:1 row in set (0.00 sec)mysql> select * from user where id = 1;+----+---------+-----+------+---------------------+-----------+| id | user_id | age | name | login_time | address |+----+---------+-----+------+---------------------+-----------+| 1 | 111 | 18 | Fc | 2020-07-23 22:16:57 | 北京市 |+----+---------+-----+------+---------------------+-----------+1 row in set (0.00 sec)
C.总结
在**binlog_format=statement**和**binlog_row_image=FULL**时,InnoDB内部认真执行了update语句,即“把这个值修改成 (1,999)“这个操作,该加锁的加锁,该更新的更新。


