title: MySQL query not using primary key, I don't understand why
body: <p>I have a table called product categories. Structure is as follows:</p>
  
  <pre><code>+---------------+------------+------+-----+---------+-------+
  | Field         | Type       | Null | Key | Default | Extra |
  +---------------+------------+------+-----+---------+-------+
  | sku           | char(50)   | NO   | PRI |         |       |
  | sorting_field | char(20)   | NO   | PRI |         |       |
  | category      | char(255)  | NO   | PRI |         |       |
  | hide          | tinyint(1) | NO   | PRI | 0       |       |
  +---------------+------------+------+-----+---------+-------+
  </code></pre>
  
  <p>The following query runs an excessive amount of time on this table:</p>
  
  <pre><code>SELECT category FROM product_categories WHERE hide!=1 AND sorting_field="item_type"  GROUP BY category;
  </code></pre>
  
  <p>When I run EXPLAIN, I get the following result:</p>
  
  <pre><code>+----+-------------+-----------------------------+-------+---------------+---------+---------+------+-------+-----------------------------------------------------------+
  | id | select_type | table              | type  | possible_keys | key     | key_len | ref  | rows  | Extra                                                     |
  +----+-------------+-----------------------------+-------+---------------+---------+---------+------+-------+-----------------------------------------------------------+
  |  1 | SIMPLE      | product_categories | index | NULL          | PRIMARY | 976     | NULL | 43568 | Using where; Using index; Using temporary; Using filesort |
  +----+-------------+-----------------------------+-------+---------------+---------+---------+------+-------+-----------------------------------------------------------+
  </code></pre>
  
  <p>I don't understand why this is happening at all! Why is the primary key not considered a possible key? This just doesn't make sense to me. By the way, here is the result of SHOW KEYS on this table:</p>
  
  <pre><code>+-----------------------------+------------+----------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+
  | Table              | Non_unique | Key_name | Seq_in_index | Column_name   | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
  +-----------------------------+------------+----------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+
  | product_categories |          0 | PRIMARY  |            1 | sku           | A         |        8713 |     NULL | NULL   |      | BTREE      |         |
  | product_categories |          0 | PRIMARY  |            2 | sorting_field | A         |       43568 |     NULL | NULL   |      | BTREE      |         |
  | product_categories |          0 | PRIMARY  |            3 | category      | A         |       43568 |     NULL | NULL   |      | BTREE      |         |
  | product_categories |          0 | PRIMARY  |            4 | hide          | A         |       43568 |     NULL | NULL   |      | BTREE      |         |
  +-----------------------------+------------+----------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+
  </code></pre>
  
  <p>Can anybody shed light on this dilemma for me?</p>