Mike Wexler wrote:
>
> Why isn't the key on the 'active' field used for the query?
>
> EXPLAIN SELECT storeId FROM accounts WHERE active=1;
> +----------+------+---------------+------+---------+------+------+------------+
> | table | type | possible_keys | key | key_len | ref | rows | Extra |
> +----------+------+---------------+------+---------+------+------+------------+
> | accounts | ALL | active | NULL | NULL | NULL | 797 | where used |
> +----------+------+---------------+------+---------+------+------+------------+
> 1 row in set (0.00 sec)
>
What does this show?
SELECT COUNT(*) FROM accounts;
Depending on the total number of rows, MySQL may decide a full table
scan will be more efficent than using an index.
jim...