Bug #5879 Fix for Examined_rows in UNION's with 4.0
Submitted: 4 Oct 2004 13:04 Modified: 5 Oct 2004 11:54
Reporter: SINISA MILIVOJEVIC Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0 OS:Any (Any)
Assigned to: CPU Architecture:Any

[4 Oct 2004 13:04] SINISA MILIVOJEVIC
Description:
When slow query log is enabled, number of examined rows is wrongly reported with UNION's are used.

Instead of total number of examined rows, only rows from temporary tables are reported. 

How to repeat:
create table foo (id int(11));
insert into foo values (1),(2),(3),(4);
Turn on slow query logging in the long format, with:

--log-slow-queries --log-long-format

select count(*) from foo a, foo b, foo c where a.id=1;

select count(*) from foo a, foo b, foo c where a.id=1 union select count(*) from foo a, foo b, foo c where a.id=1;

drop table foo;

First entry will have many examined rows while second will have zero rows reported.