EXPLAIN
will show ALL
in the type
column when MySQL
uses a table scan to resolve a query. This happens usually when:
ON
or WHERE
clause
for indexed columns.
WHERE
Clauses.
What you can do to avoid a 'wrong' table scan for big tables are:
ANALYZE TABLE
for the scanned table to update key distributions.
See section 4.5.2 ANALYZE TABLE
Syntax.
FORCE INDEX
for the scanned table to tell MySQL that table
scans are very expensive compared to use one of the given index. See section 6.4.1 SELECT
Syntax.
SELECT * FROM t1,t2 force index(index_for_column) WHERE t1.column=t2.column;
mysqld
with --max-seeks-for-key=1000
or do SET
MAX_SEEKS_FOR_KEY=1000
to tell the optimiser that for no key scan will
cause more than 1000 key seeks.