Bug #120638 The value of Rows_examined is incorrect when there is a query involving a union of derived tables
| Submitted: | 9 Jun 8:53 | Modified: | 10 Jun 6:43 |
|---|---|---|---|
| Reporter: | gang chen (OCA) | Email Updates: | |
| Status: | Duplicate | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
| Version: | 8.0.32 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[9 Jun 8:53]
gang chen
[10 Jun 6:43]
Øystein Grøvlen
Thank you, for your bug report. This is a duplicate of Bug#109034. The issue is not specific to derived tables with union, but can be observed for any derived table: mysql> SELECT SUM(num) as num FROM ( SELECT COUNT(1) num FROM test_Rows_examined ) a; +------+ | num | +------+ | 10 | +------+ 1 row in set (0.00 sec) mysql> select thread_id, digest_text, timer_wait/1000000000 "Time (ms)", rows_examined, rows_sent from performance_schema.events_statements_history order by timer_start desc limit 1\G *************************** 1. row *************************** thread_id: 69 digest_text: SELECT SUM ( `num` ) AS `num` FROM ( SELECT COUNT (?) `num` FROM `test_Rows_examined` ) `a` Time (ms): 0.8860 rows_examined: 1 rows_sent: 1 1 row in set (0.00 sec)
[1 Jul 9:53]
huahua xu
The reason for this issue is that the optimizer applies the UNQUALIFIED_COUNT operator optimization to the SELECT COUNT(1) FROM table statement. This operator directly uses the storage engine's custom interface, handler::records(), and as a result, it bypasses the actual row-by-row scanning process, which leads to the number of scanned rows (examined_rows) not being recorded.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.058 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.