title: MySQL Sorting Results takes a long time
body: <p>Lately I've been getting MySQL to hang on specific queries. I have a table with 500,000+ records. Here is the query being run:</p>
  
  <blockquote>
    <p>SELECT * FROM <code>items</code> WHERE (itemlist_id = 115626)  ORDER BY tableOrder DESC LIMIT 1</p>
  </blockquote>
  
  <p>Here is the explain:</p>
  
  <blockquote>
    <p>|  1 | SIMPLE      | items | ALL  | NULL          | NULL | NULL    | NULL | 587113 | Using where; Using filesort |</p>
  </blockquote>
  
  <p>And here is the process_list entry:</p>
  
  <blockquote>
    <p>| 252996 | root | localhost | itemdb | Query   |    0 | Sorting result | SELECT * FROM <code>items</code>     WHERE (itemlist_id = 115642)  ORDER BY tableOrder DESC LIMIT 1 |</p>
  </blockquote>
  
  <p>Any idea what could be causing this query to take 10 minutes to process? When I run it manually it's done quickly. (1 row in set (0.86 sec))</p>
  
  <p>Thanks</p>