Bug #30757 "range checked for each record" is not well-documented
Submitted: 1 Sep 2007 14:09 Modified: 22 Feb 2008 15:23
Reporter: Baron Schwartz (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: qc

[1 Sep 2007 14:09] Baron Schwartz
Description:
The "range checked for each record" output in EXPLAIN is not fully documented.  It is shown incorrectly on the EXPLAIN manual page, and the meaning of the index map isn't documented.

How to repeat:
The manual page shows examples with "key map" instead of "index map."  This is from some older 3.x versions of MySQL code.  Newer versions use "index map."  Newer versions also use a hexadecimal output for the value.  These variations should probably be mentioned.

Looking at the source code, I am not sure, but I suspect the output has always been hexadecimal.  It is in the function select_describe() in sql/sql_select.cc.

The meaning of N is not documented.

Suggested fix:
The meaning of the value is as Sergey mentioned in a recent Internals thread: http://lists.mysql.com/internals/34970 It is a bitmap of candidate indexes that will be evaluated for each row.

A value of 0x1 means the first index in the table is a candidate, 0x2 means the second is a candidate, 0x3 means both first and second, and so on.  The order of indexes is the same as the order they are shown in SHOW CREATE TABLE.

See also the discussion in bug #991, where Sergei agrees with this.
[1 Sep 2007 20:09] Valeriy Kravchuk
Thank you for a reasonable documentation request.
[22 Feb 2008 15:23] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Added to explanation of "Range checked for ...":

"Indexes are numbered beginning with 1, in the same order as shown by
SHOW INDEX for the table. The index map value N is a bitmask value
that indicates which indexes are candidates. For example, a value of
0x19 (binary 11001) means that indexes 1, 4, and 5 will be
considered."

Also updated examples to use "index map" rather than "key map" and hex
values of N. (The change to "index map" occurred in ancient history, in
MySQL 3.22.5.)