I already wrote in the blog as well mentioned in presentation there is often a choice you have to make between having prefix index - which can be significantly smaller in size and having index being covering index, which means query can be executed using only data from the index without reading the row itself.
Today I had a chance to do couple of experiments to see when
exactly it works or does not work:
PLAIN TEXT SQL:
- CREATE TABLE `t` (
- `i` int(11) DEFAULT NULL,
- `j` char(10) DEFAULT NULL,
- `k` int(11) DEFAULT NULL,
- KEY `i` (`i`,`j`(5),`k`)
- ) ENGINE=MyISAM
Now lets see if index can be used as covering index if it has some key parts which are prefixes:
PLAIN TEXT SQL:
- mysql> EXPLAIN SELECT k FROM t WHERE i=5 \G …