The following functions have poor database performance:
- forum_get_topics
- forum_get_forums
The problem is that they restrict by taxonomy terms (one table) and sort by latest updates (another table). This will always result in temp tables and filesorts. The solution is unifying the WHERE criteria and SORT BY criteria into one table. In the case of forum_get_topics, the table is term_node. For forum_get_forums, it's term_data or term_hierarchy.
By putting a latest_change_timestamp (which would contain either the node's latest change timestamp or the latest comment's) into these tables, we can paginate forums without expensive queries. Once paginated, it's okay to do something a bit more expensive with each item.