Forum .LRN Q&A: Response to Message View in Forums is very slow on Postgresql

Post the "explain" for the query plan, Dave, it will be a lot easier to answer (remember the "pre" tag!).  That will tell us right off whether or not the subselect triggers a sequential scan.

If the forums data model carries its own tree sortkey in addition to the one for objects, make sure there's an index on it.  It would be easy enough to forget this when the port was made.

But posting the query plan is the first step.