Forum Running Slow
Quote from ryanpietras1984 on April 13, 2017, 8:50 pmWhen I go to the forum page where the short code [forum] is. It takes awhile for it to load just the main area to see the different topics and sub forums, when I remove the short code the page loads just fine. If it takes too long the server times out the connection.
When I go to the forum page where the short code [forum] is. It takes awhile for it to load just the main area to see the different topics and sub forums, when I remove the short code the page loads just fine. If it takes too long the server times out the connection.
Quote from Asgaros on April 13, 2017, 9:22 pmJust to make sure that I understand it correctly: You said that only the main area is slow. That means the following forum-areas:
- Overview (shows all forums/subforums)
- Forum-View (shows all topics in a forum and subforums)
Correct? Other areas like when you visit a topic are loading at normal speed? Leave me a short note again when I understood it correctly because that could help me to find the problem.
Another point: How many topics/posts has your forum?
Just to make sure that I understand it correctly: You said that only the main area is slow. That means the following forum-areas:
- Overview (shows all forums/subforums)
- Forum-View (shows all topics in a forum and subforums)
Correct? Other areas like when you visit a topic are loading at normal speed? Leave me a short note again when I understood it correctly because that could help me to find the problem.
Another point: How many topics/posts has your forum?
Quote from ryanpietras1984 on April 13, 2017, 9:45 pmIt doesn’t come up at all, I cant see the count of how many posts are on the forum, I think it might be over 10k.
It doesn’t come up at all, I cant see the count of how many posts are on the forum, I think it might be over 10k.
Quote from ryanpietras1984 on April 13, 2017, 9:55 pmI just tried going to individual forums and they work, it looks like its just the main area of the forum that is having issues, like the area on this forum where I picked Support.
I just tried going to individual forums and they work, it looks like its just the main area of the forum that is having issues, like the area on this forum where I picked Support.
Quote from Asgaros on April 13, 2017, 9:58 pmMh, I was curious about it because maybe it could be a problem when there are a lot of posts/topics inside a forum. You can see that information when the “Show statistics” option is enabled. Maybe it is already activated and its calculations slows the forum down?
Please check if disabling those three features temporarily has an effect:
- Show who is online
- Show statistics
Mh, I was curious about it because maybe it could be a problem when there are a lot of posts/topics inside a forum. You can see that information when the “Show statistics” option is enabled. Maybe it is already activated and its calculations slows the forum down?
Please check if disabling those three features temporarily has an effect:
- Show who is online
- Show statistics
Quote from ryanpietras1984 on April 14, 2017, 12:56 amNothing happens when I disable those options.
Nothing happens when I disable those options.
Quote from Asgaros on April 14, 2017, 10:37 amThank you for all your feedback! I will do some performance-tests with thousands of topics/posts and will try to do some improvements.
Thank you for all your feedback! I will do some performance-tests with thousands of topics/posts and will try to do some improvements.
Quote from Asgaros on April 14, 2017, 11:21 amHello again,
I think I found one possible solution. Please try this fix. Open the file /wp-content/plugins/asgaros-forum/includes/forum.php. Search for the following line:
return $this->db->get_row($this->db->prepare("SELECT (SELECT COUNT(p_inner.id) FROM {$this->tables->posts} AS p_inner WHERE p_inner.parent_id = p.parent_id) AS number_of_posts, p.id, p.date, p.parent_id, p.author_id, t.name FROM {$this->tables->posts} AS p INNER JOIN {$this->tables->topics} AS t ON p.parent_id = t.id INNER JOIN {$this->tables->forums} AS f ON t.parent_id = f.id WHERE f.id = %d OR f.parent_forum = %d ORDER BY p.id DESC LIMIT 1;", $id, $id));Replace it with:
return $this->db->get_row($this->db->prepare("SELECT (SELECT COUNT(p_inner.id) FROM {$this->tables->posts} AS p_inner WHERE p_inner.parent_id = p.parent_id) AS number_of_posts, p.id, p.date, p.parent_id, p.author_id, t.name FROM {$this->tables->posts} AS p, {$this->tables->topics} AS t WHERE p.id = (SELECT p_id_query.id FROM {$this->tables->posts} AS p_id_query INNER JOIN {$this->tables->topics} AS t_id_query ON p_id_query.parent_id = t_id_query.id INNER JOIN {$this->tables->forums} AS f_id_query ON t_id_query.parent_id = f_id_query.id WHERE f_id_query.id = %d OR f_id_query.parent_forum = %d ORDER BY p_id_query.id DESC LIMIT 1) AND t.id = p.parent_id;", $id, $id));This change makes a query which is used inside the overview much more faster so it needs less than 1% of the execution-time before when a forum has a lot of topics and posts.
Please give me feedback when you tested it so that I can release a fix for this as soon as possible.
Hello again,
I think I found one possible solution. Please try this fix. Open the file /wp-content/plugins/asgaros-forum/includes/forum.php. Search for the following line:
return $this->db->get_row($this->db->prepare("SELECT (SELECT COUNT(p_inner.id) FROM {$this->tables->posts} AS p_inner WHERE p_inner.parent_id = p.parent_id) AS number_of_posts, p.id, p.date, p.parent_id, p.author_id, t.name FROM {$this->tables->posts} AS p INNER JOIN {$this->tables->topics} AS t ON p.parent_id = t.id INNER JOIN {$this->tables->forums} AS f ON t.parent_id = f.id WHERE f.id = %d OR f.parent_forum = %d ORDER BY p.id DESC LIMIT 1;", $id, $id));
Replace it with:
return $this->db->get_row($this->db->prepare("SELECT (SELECT COUNT(p_inner.id) FROM {$this->tables->posts} AS p_inner WHERE p_inner.parent_id = p.parent_id) AS number_of_posts, p.id, p.date, p.parent_id, p.author_id, t.name FROM {$this->tables->posts} AS p, {$this->tables->topics} AS t WHERE p.id = (SELECT p_id_query.id FROM {$this->tables->posts} AS p_id_query INNER JOIN {$this->tables->topics} AS t_id_query ON p_id_query.parent_id = t_id_query.id INNER JOIN {$this->tables->forums} AS f_id_query ON t_id_query.parent_id = f_id_query.id WHERE f_id_query.id = %d OR f_id_query.parent_forum = %d ORDER BY p_id_query.id DESC LIMIT 1) AND t.id = p.parent_id;", $id, $id));
This change makes a query which is used inside the overview much more faster so it needs less than 1% of the execution-time before when a forum has a lot of topics and posts.
Please give me feedback when you tested it so that I can release a fix for this as soon as possible.
Quote from Asgaros on April 14, 2017, 2:50 pmI could identify more bottlenecks which are now hopefully all fixed. Please download this development-version of the plugin and replace the files on your server via an FTP-client:
https://github.com/Asgaros/asgaros-forum/archive/6690ba61446fa409304a06159d2d284bc4a9abb6.zip
That version should be stable and safe to use. I am looking forward to your feedback! 🙂
I could identify more bottlenecks which are now hopefully all fixed. Please download this development-version of the plugin and replace the files on your server via an FTP-client:
https://github.com/Asgaros/asgaros-forum/archive/6690ba61446fa409304a06159d2d284bc4a9abb6.zip
That version should be stable and safe to use. I am looking forward to your feedback! 🙂
Quote from ryanpietras1984 on April 14, 2017, 4:15 pmOk great, I will setup a staging area to test it out, I will let you know as soon as I can.
Ok great, I will setup a staging area to test it out, I will let you know as soon as I can.