Skip to:
Content

BuddyPress.org

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5341 closed defect (bug) (wontfix)

Avoid bloat in the activity table when recording blog post activity items

Reported by: henry.wright Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Core Keywords:
Cc:

Description

Currently the content of a new blog post is recorded to the database twice. Once in the BP activity table by function bp_blogs_record_post and once in the wp_posts table.

I'm wondering if this is unnecessary?

In bp_blogs_record_post, the bp_blogs_record_activity function records the $post_id as the secondary_item_id so if the content is needed at a later date then the content can be fetched from the wp_posts table via something like this:

$post = get_post( $post_id );
$excerpt = $post->post_excerpt;
$content = $post->post_content;

This makes it unnecessary for bp_blogs_record_activity to record blog post content.

The same approach to avoiding saving duplicate data could be taken for blog comments. As a result, the size of the activity table wouldn't grow as quickly.

Thoughts?

Change History (2)

#1 @boonebgorges
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

The biggest issue here is that, on a multisite setup, the posts come from all over the network. Thus, you'd need to switch_to_blog() for every post. This would create a huge amount of overhead on every pageload. Even on a non-multisite setup, loading 20 blog posts is much more resource-intensive than doing the single SQL query that the activity stream currently requires.

You might think of the excerpt stored in the activity table as a sort of cache: a readily accessible copy of the original data, optimized for quick access.

Thanks for the thought!

#2 @henry.wright
6 years ago

Right, I see - sorry for overlooking multisite (and performance)!

Note: See TracTickets for help on using tickets.