Bug #69377 Wasted work in method row_check_index_for_mysql()
Submitted: 1 Jun 2013 23:25 Modified: 4 Jul 2013 12:07
Reporter: Po-Chun Chang (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:5.6, 5.7 OS:Any
Assigned to: CPU Architecture:Any
Tags: patch, performance

[1 Jun 2013 23:25] Po-Chun Chang
Description:
The problem appears in version 5.6 and in the latest revision 5216 in
version 5.7.  I have attached a simple one-line patch (patch.diff) that
fixes it.

In method "row_check_index_for_mysql()" in row0mysql.cc, the loop on line 5418
should break immediately after "contains_null" is set to "TRUE". All the
iterations after "contains_null" is set to "TRUE" do not perform any useful
work, at best they just set "contains_null" again to "TRUE".

How to repeat:
Once row_check_index_for_mysql() is executed.

Suggested fix:
=== modified file 'storage/innobase/row/row0mysql.cc'
--- storage/innobase/row/row0mysql.cc	2013-03-26 13:01:45 +0000
+++ storage/innobase/row/row0mysql.cc	2013-06-01 23:18:32 +0000
@@ -5422,6 +5422,7 @@
 				    dtuple_get_nth_field(prev_entry, i))) {
 
 				contains_null = TRUE;
+				break;
 			}
 		}
[1 Jun 2013 23:25] Po-Chun Chang
Suggested patch

Attachment: patch.diff (text/plain), 308 bytes.

[2 Jun 2013 10:26] Shane Bester
thank you for the report.  fwiw, in 5.7.2, the function is row_scan_index_for_mysql
[26 Jun 2013 2:57] Po-Chun Chang
Suggested patch

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: patch.diff (text/plain), 308 bytes.

[27 Jun 2013 8:15] Ståle Deraas
Thanks a lot. We will include you contribution.
[4 Jul 2013 12:07] Bugs System
Added a changelog entry to 5.6.13, 5.7.2:

"The "row_check_index_for_mysql" method, which checks for NULL fields
during an index scan or "CHECK TABLE" operation, would iterate
unnecessarily."

Thank you for the bug report.
[24 Jul 2013 14:43] Paul Dubois
Addition to changelog entry:

Thanks to Po-Chun Chang for the patch to correct this issue.