<div>Folks,</div><div><br></div><div>We're in the midst of migrating from RT 3.6.4 to RT 3.8.2, and having some "interesting" issues with the Attachments table.</div><div><br></div><div>Here's what queries against Attachments looked like on our old RT instance:</div>
<div><br></div><div>previous RT install (3.6.4):</div><div><br></div><div>mysql> explain SELECT main.* FROM Attachments main  WHERE (main.Content IS NOT NULL AND main.Content != '') AND (main.Parent = '1208717') AND (main.ContentType = 'text/plain')  ORDER BY <a href="http://main.id">main.id</a> ASC;</div>
<div>+----+-------------+-------+------+---------------+--------------+---------+-------+------+-----------------------------+</div><div>| id | select_type | table | type | possible_keys | key          | key_len | ref   | rows | Extra                       |</div>
<div>+----+-------------+-------+------+---------------+--------------+---------+-------+------+-----------------------------+</div><div>|  1 | SIMPLE      | main  | ref  | Attachments3  | Attachments3 | 4       | const |    2 | Using where; Using filesort |</div>
<div>+----+-------------+-------+------+---------------+--------------+---------+-------+------+-----------------------------+</div><div>1 row in set (0.00 sec)</div><div><br></div><div>mysql></div><div><br></div><div>
<br></div><div>Now, here's what (what should be the self-same queries...) is being produced on our new RT host, running 3.8.2:</div><div><br></div><div>new RT host:</div><div><br></div><div>mysql> explain SELECT main.* FROM Attachments main  WHERE (main.Content IS NOT NULL AND main.Content != '') AND (main.Parent = '1208717') AND (main.ContentType = 'text/plain')  ORDER BY <a href="http://main.id">main.id</a> ASC;</div>
<div>+----+-------------+-------+-------+---------------+---------+---------+------+---------+-------------+</div><div>| id | select_type | table | type  | possible_keys | key     | key_len | ref  | rows    | Extra       |</div>
<div>+----+-------------+-------+-------+---------------+---------+---------+------+---------+-------------+</div><div>|  1 | SIMPLE      | main  | index | Attachments3  | PRIMARY | 4       | NULL | 2199950 | Using where |</div>
<div>+----+-------------+-------+-------+---------------+---------+---------+------+---------+-------------+</div><div>1 row in set (0.11 sec)</div><div><br></div><div>mysql></div><div><br></div><div>Obviously, on the new host, it isn't using the index on the Attachments table - and that's REALLY making things go slowly for some bits of RT.</div>
<div><br></div><div>Anybody got a clue how to fix this, or an idea of what we can do to coerce it to use the proper index? </div><div><br></div><div>[We have quite a lot of tickets, and a fairly scary amount of spam has leaked into our RT instance - I'm going to need to run the shredder on a large number of deleted tickets, but the Attachments table is currently so big that doing so is a bit daunting...]</div>
<div><br></div><div>This is on a new host, and we imported via a mysqldump and re-import, so the data in the table should be defragmented... but the end result is clearly problematic.  </div><div><br></div><div>thanks in advance,</div>
<div><br></div><div>--elijah</div><div><br></div>