*

oscman

  • ****
  • 227 posts
Re: Urgent: CPU goes to 100% with veronika and plugins
« Reply #30 on: March 27, 2017, 03:17:23 PM »
Sorry for opening the threat again, i need a fix if its possible for a problem.
When i change LEFT OUTER to INNER after the else { code the server has lower cpu load at all but some messages in inbox are shown as unread even if you read them many times. do you know how i could solve this?

  if( isset($secret) && $secret <> '' ) {
    $this->dao->join( $this->getTable_messages() . ' as m', 't.i_thread_id = m.fk_i_thread_id AND ((t.i_from_user_id = ' . $user_id . ' AND m.i_type = 1  OR  t.i_to_user_id = ' . $user_id . ' AND m.i_type = 0) OR (t.s_from_secret = "' . $secret . '" AND m.i_type = 1  OR  t.s_to_secret = "' . $secret . '" AND m.i_type = 0))', 'INNER' );
  } else {
    $this->dao->join( $this->getTable_messages() . ' as m', 't.i_thread_id = m.fk_i_thread_id AND ((t.i_from_user_id = ' . $user_id . ' AND m.i_type = 1  OR  t.i_to_user_id = ' . $user_id . ' AND m.i_type = 0))', 'INNER' );
  }

Also any other way than changing to INNER to make this query run faster? If i make it INNER it will not send the message.
Code: [Select]
public function getThreadById( $id ) {
  $this->dao->select('t.i_thread_id, t.fk_i_item_id, t.i_from_user_id, t.s_from_user_name, t.s_from_user_email, t.s_from_secret, t.i_from_user_notify, t.i_to_user_id, t.s_to_user_name, t.s_to_user_email, t.s_to_secret, t.i_to_user_notify, t.s_title, t.d_datetime, count(m.pk_i_id) as i_count, t.i_flag');
  $this->dao->from( $this->getTable_threads() . ' as t' );
  $this->dao->join( $this->getTable_messages() . ' as m', 't.i_thread_id = m.fk_i_thread_id', 'LEFT OUTER' );
« Last Edit: March 27, 2017, 03:20:48 PM by oscman »

*

MB Themes

Re: Urgent: CPU goes to 100% with veronika and plugins
« Reply #31 on: March 27, 2017, 03:48:10 PM »
@oscman
Sometimes left outer join may not be used, in case thread or message does not exist and you need ID. Your problem is in database, you cannot run huge classifieds without having DBA that will analyze tables and create proper indexes (and maybe change database structure).
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots