Drupal 5's forum module is OK. It lets you create multiple forums with taxonomy terms. Forum posts are true nodes so you get all the benefits of nodeness. And Drupal keeps track of which posts you've read. All that is great. But I've had some trouble scaling up a site that relies heavily on the forum module, even when using advcache. Investigating how the database was spending its time, I found lots of queries like this:
SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM node n INNER JOIN node_comment_statistics l ON n.nid = l.nid INNER JOIN term_node r ON n.nid = r.nid AND r.tid = 123 WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, l.last_comment_timestamp desc
An EXPLAIN shows how nasty this is:
id |
select_type |
table |
type |
possible_keys |
key |
key_len |
ref |
rows |
Extra |
1 |
SIMPLE |
n |
ref |
PRIMARY,node_type,status,node_status_type,nid |
node_status_type |
102 |
const,const |
30679 |
Using where; Using temporary; Using filesort |
1 |
SIMPLE |
l |
eq_ref |
PRIMARY |
PRIMARY |
4 |
drupal.n.nid |
1 |
|
1 |
SIMPLE |
r |
eq_ref |
PRIMARY,nid,tid |
PRIMARY |
8 |
const,drupal.l.nid |
1 |
Using where; Using index |
Searching Drupal's code turns up this query in theme_forum_topic_navigation(). It turns out the database is smoking, grinding away, eating up cycles generating previous and next links for forum topics. I thought about it for a minute, and realized that I don't think I've ever used those links. Which would you rather have? Blazing speed or a link to the next forum topic? Fortunately, the slow query is in a themable function, which means we can get our performance back with a few lines added to our theme's template.php:
// No previous/next links for forum topics.
function phptemplate_forum_topic_navigation($node) {
return '';
}
In my case, server load dropped from 46 to 0.5. Sometimes it's the little things.