Skip to:
Content
Pages
Categories
Search
Top
Bottom

Major performance issue when viewing the Inbox


  • Cristian
    Participant

    @crosescu

    One major issue with the viewing the Inbox is that it’s checking if each message thread has been read or not. This is for BuddyPress 1.1.3

    This could become a huge performance issue if a message has tens/hundreds of threads because the code hits the database to check if each thread has been read by the user or not.

    The issue occurs in function get_current_threads_for_user()

    for ( $i = 0; $i < count($thread_ids); $i++ ) {

    $threads[$i] = new BP_Messages_Thread( $thread_ids[$i]->thread_id, false, $box );

    BP_Messages_Thread->populate() and then this checks if the the thread has been read or not $this->unread_count = $this->get_unread();

Viewing 4 replies - 1 through 4 (of 4 total)

  • Cristian
    Participant

    @crosescu

    Also there is no need to run these two queries one after the other

    SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id

    SELECT * FROM {$bp->messages->table_name_messages} WHERE id

    You only need to execute the second query and the number of queries that hit the database will be decreased a little bit

    No need for this line $this->last_sender_id = messages_get_message_sender( $this->last_message_id ) in BP_Messages_Thread::populate()

    Instead add the line below after “if ( $last_message ) {“

    $this->last_sender_id = $last_message->sender_id;


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Make a ticket in the trac with your suggestions? Your contributions could make it into the core. There are a few places where queries could probably be reduced.

    Create a defect ticket please.

    I may have fixed this with some updates I made to the messages component today.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Major performance issue when viewing the Inbox’ is closed to new replies.
Skip to toolbar