MySQL: Force to use an Index
Make the mysql query analyzer force use a specific index because i know better:
SELECT fieldA, fieldB, ...
FROM sometable USE INDEX (IX_DocumentNumber)
WHERE ...
LIMIT 20;
This is a ‘explain select …’ output:
mysql> explain SELECT ... LIMIT 20\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: sometable
type: range
possible_keys: IX_DocumentNumber
key: IX_DocumentNumber
key_len: 19
ref: NULL
rows: 5122151
Extra: Using where; Using index; Using temporary