We moved our RT server from mysql 4.0 to 5.1 and we are having some slow query issues on the Attachments table not finding the correct index<br><br><br>mysql> explain SELECT main.* FROM Attachments main WHERE (main.Parent = '308267') AND (main.ContentType = 'text/plain') ORDER BY <a href="http://main.id">main.id</a> ASC;<br>
+----+-------------+-------+-------+----------------------------------+---------+---------+------+---------+-------------+<br>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<br>
+----+-------------+-------+-------+----------------------------------+---------+---------+------+---------+-------------+<br>| 1 | SIMPLE | main | index | Attachments3,Attachments4,Parent | PRIMARY | 4 | NULL | 1321158 | Using where | <br>
+----+-------------+-------+-------+----------------------------------+---------+---------+------+---------+-------------+<br>1 row in set (0.00 sec)<br><br><br>mysql> explain SELECT main.* FROM Attachments main FORCE INDEX(Attachments3) WHERE (main.Parent = '308267') AND (main.ContentType = 'text/plain') ORDER BY <a href="http://main.id">main.id</a> ASC;<br>
+----+-------------+-------+------+---------------+--------------+---------+-------+------+-----------------------------+<br>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<br>
+----+-------------+-------+------+---------------+--------------+---------+-------+------+-----------------------------+<br>| 1 | SIMPLE | main | ref | Attachments3 | Attachments3 | 4 | const | 1 | Using where; Using filesort | <br>
+----+-------------+-------+------+---------------+--------------+---------+-------+------+-----------------------------+<br>1 row in set (0.00 sec)<br><br><br>It works if I choose to force the index. <br><br>I have been trying to find where in the code this is to at least force the index but I have not found it. <br>