A customer recently asked if I could help clarify the
relationship between rows_examined
(in the slow
query log) and the Handler% variables (in SHOW STATUS output) for
a simple UNION. I didn't know the answer off the top of my head,
but I didn't think it would be too terribly difficult to find it.
Several days and many hours of work later, I think I finally have
some idea of how this all works.
Let's first set up some sample data and get some information
about it. (I'm using MariaDB 5.2.4 for these tests because that's
the version the customer was using. This should basically all
apply to other versions/vendors, except specific changes I refer
to in MariaDB 5.3.)
maria 5.2.4> create table t1 (id int, key(id));
Query OK, 0 rows affected (0.01 sec)
maria 5.2.4> \! seq -f '(%.0f)' -s, 1 10
(1),(2),(3),(4),(5),(6),(7),(8),(9),(10)
maria 5.2.4> insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
Query OK, 10 …
[Read more]