We were seeing some very very slow forum page loads about 2 weeks after upgrading to a new version of IPB – approaching 10-15 seconds in some cases. A server restart seemed to help initially. However, the slowdown showed up again shortly after.
I noticed the Processes were consistently showing a number of queries waiting for a table level lock. After refreshing for a while I saw cases where the queries were waiting for 7 seconds. They were waiting for “delete” queries on the sessions table. The sessions table had nearly 100,000 rows, as a note.
Looking at the delete query in a bit more detail, it was of this sort: “delete from sessions where (ip_address=x.x.x.x or running_time<142255332)
I noticed there was no index on ip_address, so we added one. Since adding that index on sessions.ip_address, there have been no queries waiting on a table level lock, and forum page load times have gone down even more.
Moral of the story? If you’re seeing slow page loads in your IPB forums and you have a lot of traffic to your forum, add an index to sessions.ip_address. There is no scenario where that would be a bad thing, and there are many scenarios where it is a good thing.
No comments:
Post a Comment