I expected either index to be used for my SELECT DISTINCT query below:
CREATE TABLE test(
value TEXT
);
INSERT INTO test (value) VALUES ('a');
INSERT INTO test (value) VALUES ('b');
INSERT INTO test (value) VALUES ('c');
CREATE INDEX value_i ON test(value(32));
CREATE FULLTEXT INDEX value_i_ft ON test(value);
SELECT DISTINCT value FROM test;
EXPLAIN SELECT DISTINCT value FROM test;
However, it seems not:
--------------
EXPLAIN SELECT DISTINCT value FROM test
--------------
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------+
| 1 | SIMPLE | test | ALL | NULL | NULL | NULL | NULL | 2 | Using temporary |
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------+
1 row in set (0.00 sec)
I'm using mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (i686) using readline 5.1. This kind of query is taking 1.5s on 70,000 rows with 250 distinct values, versus about 10ms on the same table for indexed integer columns.