Speed up statistics queries

dbirider - November 1, 2009 - 05:52
Project:Advanced Forum
Version:6.x-2.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:active
Description

I noticed my forum listing pages were taking a while to load. After checking it with the devel module, the problem seems to be with the forum statistics, which are taking between 1 and 3 seconds to load. Is there any way to speed this up?

Executed 87 queries in 2547.8 milliseconds:
2091.28ms - advanced_forum_statistics_latest_user
273.77ms - advanced_forum_statistics_users
...

#1

Michelle - November 1, 2009 - 14:28
Title:advanced_forum_statistics_latest_user query is slow» Speed up statistics queries
Version:6.x-1.1» 6.x-2.x-dev
Category:bug report» task

My first response to this was, "If I knew how to make it faster, don't you think I would have?". Luckily, I decided to be grumpy on IRC rather than in the issue queue, and ended up being pleasantly surprised when a couple of the folks there stepped up to help out my weak SQL skills. I'm not up for working on this today as I'm already trying to do a major site upgrade while fighting a nasty bug, possibly of the pig variety, so I'm going to make note of what they said and come back to this.

From dereine:
return db_fetch_object(db_query_range('SELECT uid, name FROM {users} WHERE status = 1 AND access > 0 ORDER BY created DESC', 0, 1));

From killes:
* function advanced_forum_statistics_online_users() { <== if you only want the authenticated users you can omit the join on the session table
* you can use users.access instead

Michelle

 
 

Drupal is a registered trademark of Dries Buytaert.