Bug #110804 sql as "select count(*) from table" can't be logged in the slow query log.
Submitted: 25 Apr 2023 13:47 Modified: 26 Apr 2023 23:00
Reporter: Siliang Wu Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:8.0.32 OS:Any
Assigned to: CPU Architecture:Any

[25 Apr 2023 13:47] Siliang Wu
Description:
When the variable min_examined_row_limit is set as a number larger than 0.
A sql as "select count(*) from table_name" execute longer than long_query_time,
but the sql is not logged in the slow query log.

Because the rows_examined for "select count(*) from table_name" is 0. "select count(*) from table_name" will search the whole table, so the rows_examined shouldn't be zero.

How to repeat:
Set min_examined_row_limit larger than 0 such as 100.
Execute a query as "select count(*) from table_name" which take longer time than long_query_time.
The sql won't be logged in the slow query log.

Suggested fix:
The rows_examined for the query "select count(*) from table_name" should not be calculated as
[26 Apr 2023 23:00] MySQL Verification Team
Hi,

Thanks for the report, reproduced as described.