Bug #63373 thd->examined_row_count is set to 0 unproperly in JOIN::exec
Submitted: 22 Nov 2011 2:45 Modified: 17 Apr 2012 17:34
Reporter: xiaobin lin (OCA) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.1,5.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: examined_row_count, slow_log

[22 Nov 2011 2:45] xiaobin lin
Description:
The variable thd->examined_row_count is set to 0 at (sql_select.cc:1883, version 5.5.17)
It seems that when we call "count(*) from myisam table",  thd->examined_row_count is reset.

If I run "select count(*) from (xxxx) t", and if this query should be record in slow_log, the log will show "Rows_examined : 0"

How to repeat:
select count(*) from (select * from mytable)t;

gdb at : sql_select.cc:1883

Suggested fix:
As the variable thd->examined_row_count is reset at every beginning of query, I think statement at sql_select.cc:1883 can be commented directly.
[22 Nov 2011 6:16] xiaobin lin
Sorry, I forget to say that the mytable is an innobase table

in this statement:
select count(*) from (select * from mytable)t;
[23 Nov 2011 1:43] xiaobin lin
It seems necessary to re-post this issue.

==Description:
    Table "mytable" is an innobase table, but "select count(*) from (select * from mytable)t" shows "Rows_examined : 0" in the slow log, when it is a slow query.

==Repeat:
    make mytable to be a big  enough table and run select count(*) from (select * from mytable)t.
    or directly gdb at sql_select.cc:1883 (version 5.5.17)

==Perhaps reason:
    The reason seems to be that the result of the subquery "select * from mytable" is treate as a myisam table.
    So in the process of the outer query "select count(*) from t" , the variable thd->examined_row_count is set to 0.

==Suggested fix:
    As the variable thd->examined_row_count is reset at every beginning of query, I think statement at sql_select.cc:1883 can be commented directly.
[19 Dec 2011 18:14] Sveta Smirnova
Thank you for the report.

Verified as described. Actually this is fixed in development source tree, but marking bug as "Verified", so development can consider to backport the fix.
[17 Apr 2012 8:51] Ståle Deraas
The bug is is not repeatable in trunk (5.6).
[17 Apr 2012 17:34] xiaobin lin
Yes, the bug is fixed in 5.6. Thank you for notification.