Bug #79867 | unnecessary using temporary for update | ||
---|---|---|---|
Submitted: | 7 Jan 2016 5:00 | Modified: | 5 Sep 2016 9:06 |
Reporter: | zhang yingqiang (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Replication | Severity: | S3 (Non-critical) |
Version: | 5.6.26 5.7.10, 5.6.28 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | binlog image update temproray table |
[7 Jan 2016 5:00]
zhang yingqiang
[7 Jan 2016 12:15]
MySQL Verification Team
Hello zhang yingqiang, Thank you for the report and contribution. Thanks, Umesh
[7 Jan 2016 12:16]
MySQL Verification Team
// 5.6.28 worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009 binlog.rpl_79867 'mix' [ skipped ] Doesn't support --binlog-format='mixed' show variables like '%binlog_row_image%'; Variable_name Value binlog_row_image FULL set sql_log_bin=0; create table t1(id int primary key, a int) engine = innodb; insert into t1 select 1,1; insert into t1 select 2,1; insert into t1 select 3,2; insert into t1 select 4,2; set binlog_row_image= FULL; set sql_log_bin=1; explain update t1 set a=a+1 where id < 3; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 const 2 Using where; Using temporary update t1 set a=a+1 where id < 3; set binlog_row_image= MINIMAL; explain update t1 set a=a+1 where id < 3; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 const 2 Using where update t1 set a=a+1 where id < 3; set sql_log_bin=0; flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 #160107 15:12:37 server id 1 end_log_pos 120 CRC32 0x99631b4f Start: binlog v 4, server v 5.6.28-enterprise-commercial-advanced-log created 160107 15:12:37 at startup ROLLBACK/*!*/; BINLOG ' NVaOVg8BAAAAdAAAAHgAAAAAAAQANS42LjI4LWVudGVycHJpc2UtY29tbWVyY2lhbC1hZHZhbmNl ZC1sb2cAAAAAAAAAAAA1Vo5WEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAU8b Y5k= '/*!*/; # at 120 #160107 15:12:38 server id 1 end_log_pos 192 CRC32 0xa96bc13b Query thread_id=2 exec_time=0 error_code=0 SET TIMESTAMP=1452168758/*!*/; SET @@session.pseudo_thread_id=2/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=1073741824/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; # at 192 #160107 15:12:38 server id 1 end_log_pos 238 CRC32 0x69d472a4 Table_map: `test`.`t1` mapped to number 81 # at 238 #160107 15:12:38 server id 1 end_log_pos 310 CRC32 0xe49cfbc5 Update_rows: table id 81 flags: STMT_END_F BINLOG ' NlaOVhMBAAAALgAAAO4AAAAAAFEAAAAAAAEABHRlc3QAAnQxAAIDAwACpHLUaQ== NlaOVh8BAAAASAAAADYBAAAAAFEAAAAAAAEAAgAC///8AQAAAAEAAAD8AQAAAAIAAAD8AgAAAAEA AAD8AgAAAAIAAADF+5zk '/*!*/; ### UPDATE `test`.`t1` ### WHERE ### @1=1 ### @2=1 ### SET ### @1=1 ### @2=2 ### UPDATE `test`.`t1` ### WHERE ### @1=2 ### @2=1 ### SET ### @1=2 ### @2=2 # at 310 #160107 15:12:38 server id 1 end_log_pos 341 CRC32 0x17b600a0 Xid = 37 COMMIT/*!*/; # at 341 #160107 15:12:38 server id 1 end_log_pos 413 CRC32 0x69d65b92 Query thread_id=2 exec_time=0 error_code=0 SET TIMESTAMP=1452168758/*!*/; BEGIN /*!*/; # at 413 #160107 15:12:38 server id 1 end_log_pos 459 CRC32 0x8ae82807 Table_map: `test`.`t1` mapped to number 81 # at 459 #160107 15:12:38 server id 1 end_log_pos 515 CRC32 0x3bd7eb3c Update_rows: table id 81 flags: STMT_END_F BINLOG ' NlaOVhMBAAAALgAAAMsBAAAAAFEAAAAAAAEABHRlc3QAAnQxAAIDAwACByjoig== NlaOVh8BAAAAOAAAAAMCAAAAAFEAAAAAAAEAAgACAQL+AQAAAP4DAAAA/gIAAAD+AwAAADzr1zs= '/*!*/; ### UPDATE `test`.`t1` ### WHERE ### @1=1 ### SET ### @2=3 ### UPDATE `test`.`t1` ### WHERE ### @1=2 ### SET ### @2=3 # at 515 #160107 15:12:38 server id 1 end_log_pos 546 CRC32 0xbedb603a Xid = 40 COMMIT/*!*/; # at 546 #160107 15:12:38 server id 1 end_log_pos 594 CRC32 0x68c6788b Rotate to master-bin.000002 pos: 4 DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; drop table t1; binlog.rpl_79867 'row' [ pass ] 18
[26 Jul 2016 7:06]
Sujatha Sivakumar
Patch for Bug#79867 fix.
Attachment: Bug79867_mysql-5.6.diff (text/x-patch), 10.50 KiB.
[26 Jul 2016 7:07]
Sujatha Sivakumar
Please find the above patch that fixes the issue. Give it a try at your end and please let us know if you see any issues with it.
[5 Sep 2016 9:06]
David Moss
Posted by developer: Thank you for your feedback, this has been fixed in upcoming versions and the following was added to the 5.6.33 and 5.7.15 change logs: With binlog_row_image=FULL, when updating single tables temporary tables were unnecessarily being used. The fix ensures single table update follows the same pattern as multi-table update. Thanks to Zhang Yingqiang for the contribution that this fix was based on.
[7 Sep 2016 10:07]
David Moss
Posted by developer: Sorry, made a mistake and actually the patch was not based on Zhang's contribution. Therefore the changelog entry was modified to: With binlog_row_image=FULL, when updating single tables temporary tables were unnecessarily being used. The fix ensures single table update follows the same pattern as multi-table update.
[3 Jan 2017 11:47]
Erlend Dahl
Bug#80424 EXPLAIN output depends on binlog_format setting was marked as a duplicate.