The output from
ALL in the
type column when MySQL uses a table scan to
resolve a query. This usually happens under the following
The table is so small that it is faster to perform a table scan than to bother with a key lookup. This is common for tables with fewer than 10 rows and a short row length.
There are no usable restrictions in the
for indexed columns.
You are comparing indexed columns with constant values and
MySQL has calculated (based on the index tree) that the
constants cover too large a part of the table and that a
table scan would be faster. See
Section 184.108.40.206, “How MySQL Optimizes
You are using a key with low cardinality (many rows match the key value) through another column. In this case, MySQL assumes that by using the key it probably will do many key lookups and that a table scan would be faster.
For small tables, a table scan often is appropriate and the performance impact is negligible. For large tables, try the following techniques to avoid having the optimizer incorrectly choose a table scan:
the key distributions for the scanned table. See
Section 220.127.116.11, “
ANALYZE TABLE Syntax”.
FORCE INDEX for the scanned table
to tell MySQL that table scans are very expensive compared
to using the given index:
SELECT * FROM t1, t2 FORCE INDEX (
index_for_column) WHERE t1.
Start mysqld with the
option or use
max_seeks_for_key=1000 to tell the optimizer to
assume that no key scan causes more than 1,000 key seeks.
See Section 5.1.4, “Server System Variables”.
Copyright © 1997, 2014, Oracle and/or its affiliates. All rights reserved. Legal Notices