#2421 closed defect (bug) (fixed)
bp_get_forum_topic_count causing massive memory requirements and timeouts
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 1.5 | Priority: | normal |
Severity: | Version: | ||
Component: | Core | Keywords: | |
Cc: |
Description
I previously reported that the BuddyPress /forums page (“Group Forums Directory”) was crashing due to memory limit errors on a BP Forum that had 20,000+ topics. I kept bumping it up until I finally got the page to render at a memory limit of 200M. The problem is the function bp_get_forum_topic_count is causing massive memory requirements and timeouts. This function that displays the total number of topics in the tab: “All Topics (23,466)” Even with the memory limit high enough, bp_get_forum_topic_count takes a good 4 seconds to generate that number (on a VPS that otherwise pulls up pages in a fraction of a second).
I’m wondering why this function even exists, and if it needs to exist, can it be fixed?? r-a-y suspects (and I agree) that this is probably an issue with the BB_Query instance.
bp_forum_pagination_count() already performs a similar function directly below the All Topics tab (“Viewing topic 1 to 20 (23,466 total topics)”) and all it does is call $forum_template->total_topic_count - very simple
Given that total_topic_count is already stored in the $forum_template, is bp_get_forum_topic_count a dog that serves no purpose and causes massive memory issues to boot?
Change History (5)
#2
@
14 years ago
Since this ticket was created 7 months ago, [3369] has happened which has prevented bbPress potentially load itself twice. I have looked through the main bbPress query class and can see no workarounds to significantly improve any further memory use; hopefully, new bbPress plugin will be more memory-friendly when we integrate that into BuddyPress.
I'm going to try creating manylots of forum topics to look at memory use but I think this will be a wontfix for now.
#3
@
14 years ago
I was so wrong. Even though this particular function is only used in one place in BP-Default, direct SQL was/is so much faster than using a BBPress query. Tested on a 10k topic group. Forum directory still very slow to load.
As reported in the forum thread, commenting out the do_action('bbpress_init') line in the bp_forums_total_topic_count() function fixes this:
http://pastebin.com/rqGPKxrD
The alternative is to rewrite the function to the following: