Optimise thread load query.

Modify the query in `Thread->load()` to use sub-selects so that it's faster for tickets with a large number of attachments, messages and responses. Tested on MySQL 5.0.51 and 5.5.40.