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

The main query should be fast assuming there is an index forums_messages.message_id.  Go into psql and try running each of the functions individually.  It should be obvious which function call is slow.

It seems likely that forums_message__root_message_id could be the culprit.  I'm assuming that it probably does some kind of recursion or tree query internally.