| Bug #69173 | Wasted work in method Query_cache::check_integrity() | ||
|---|---|---|---|
| Submitted: | 8 May 2013 4:07 | Modified: | 26 Jun 2013 13:15 |
| Reporter: | Po-Chun Chang (OCA) | Email Updates: | |
| Status: | Won't fix | Impact on me: | |
| Category: | MySQL Server: Query Cache | Severity: | S5 (Performance) |
| Version: | 5.6, 5.7 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | patch, performance | ||
[8 May 2013 4:08]
Po-Chun Chang
Suggested patch
Attachment: patch.diff (text/plain), 440 bytes.
[8 May 2013 6:19]
MySQL Verification Team
Thank you for the bug report and contribution.
[8 May 2013 6:40]
Jon Olav Hauglid
Hi! Note that this function is used in debug builds only, so the wasted work has no consequences for normal release builds.
[8 May 2013 13:26]
Po-Chun Chang
Hi, Jon Thanks for your explanation !

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. This problem is similar to the already verified MySQL #69117. In method "Query_cache::check_integrity()" in sql_cache.cc, the loop on line 4665 should break immediately after "result" is set to "true". All the iterations after "result" is set to "true" do not perform any useful work, at best they just set "result" again to "true". How to repeat: Once Query_cache::check_integrity() is executed. Suggested fix: === modified file 'sql/sql_cache.cc' --- sql/sql_cache.cc 2013-02-28 15:36:00 +0000 +++ sql/sql_cache.cc 2013-05-08 04:03:23 +0000 @@ -4666,8 +4666,10 @@ { DBUG_PRINT("qcache", ("block 0x%lx, type %u...", (ulong) block, (uint) block->type)); - if (in_blocks(result_block)) + if (in_blocks(result_block)) { result= true; + break; + } result_block = result_block->next; } while (result_block != results);