Details

    • Type: Sub-task
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.2
    • Fix Version/s: 4.7.5
    • Component/s: None
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      With logging on the change log tab is really slow to render. On a medium-large DB (300,000 contacts and 1 million activities) I'm seeing 3 queries taking 5 seconds or more each. These turn out to be badly written

      "INSERT IGNORE INTO civicrm_temp_civireport_logsummary SELECT entity_log_civireport.id as log_civic
      rm_entity_id, entity_log_civireport.log_action as log_civicrm_entity_log_action, 'log_civicrm_activity_for_target' as log
      _civicrm_entity_log_type, entity_log_civireport.log_user_id as log_civicrm_entity_log_user_id, entity_log_civireport.log_date as log_civicrm_entity_log_date, modified_contact_civireport.display_name as log_civicrm_entity_altered_contact, modified_contact_civireport.id as log_civicrm_entity_altered_contact_id, entity_log_civireport.log_conn_id as log_civicrm_entity_log_conn_id, modified_contact_civireport.is_deleted as log_civicrm_entity_is_deleted, altered_by_contact_civireport.display_name as altered_by_contact_display_name
      FROM log_civicrm_activity entity_log_civireport

      INNER JOIN log_civicrm_activity_contact fk_table ON (entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = 3)
      INNER JOIN civicrm_contact modified_contact_civireport
      ON (fk_table.contact_id = modified_contact_civireport.id )
      LEFT JOIN civicrm_contact altered_by_contact_civireport
      ON (entity_log_civireport.log_user_id = altered_by_contact_civireport.id) WHERE ( modified_contact_civireport.id = 278486 ) AND (entity_log_civireport.log_action != 'Initialization') GROUP BY entity_log_civireport.log_conn_id, entity_log_civireport.log_user_id, EXTRACT(DAY_MICROSECOND FROM entity_log_civireport.log_date), entity_log_civireport.id "

      Feb 24 14:46:53 [info] ** QUERY DONE IN 5.963534 seconds. 63 row(s)s subject to insert action

      INSERT IGNORE INTO civicrm_temp_civireport_logsummary SELECT entity_log_civireport.id as log_civicrm_entity_id, entity_log_civireport.log_action as log_civicrm_entity_log_action, 'log_civicrm_activity_for_assignee' as log_civicrm_entity_log_type, entity_log_civireport.log_user_id as log_civicrm_entity_log_user_id, entity_log_civireport.log_date as log_civicrm_entity_log_date, modified_contact_civireport.display_name as log_civicrm_entity_altered_contact, modified_contact_civireport.id as log_civicrm_entity_altered_contact_id, entity_log_civireport.log_conn_id as log_civicrm_entity_log_conn_id, modified_contact_civireport.is_deleted as log_civicrm_entity_is_deleted, altered_by_contact_civireport.display_name as altered_by_contact_display_name
      FROM log_civicrm_activity entity_log_civireport

      INNER JOIN `imba_civicrm_log`.log_civicrm_activity_contact fk_table ON entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = 1
      INNER JOIN civicrm_contact modified_contact_civireport
      ON (fk_table.contact_id = modified_contact_civireport.id )
      LEFT JOIN civicrm_contact altered_by_contact_civireport
      ON (entity_log_civireport.log_user_id = altered_by_contact_civireport.id) WHERE ( modified_contact_civireport.id = 278486 ) AND (entity_log_civireport.log_action != 'Initialization') GROUP BY entity_log_civireport.log_conn_id, entity_log_civireport.log_user_id, EXTRACT(DAY_MICROSECOND FROM entity_log_civireport.log_date), entity_log_civireport.id "

      Feb 24 14:46:58 [info] ** QUERY DONE IN 5.195286 seconds. 1 row(s)s subject to insert action

      $Query = string(1509) "INSERT IGNORE INTO civicrm_temp_civireport_logsummary SELECT entity_log_civireport.id as log_civicrm_entity_id, entity_log_civireport.log_action as log_civicrm_entity_log_action, 'log_civicrm_activity_for_source' as log_civicrm_entity_log_type, entity_log_civireport.log_user_id as log_civicrm_entity_log_user_id, entity_log_civireport.log_date as log_civicrm_entity_log_date, modified_contact_civireport.display_name as log_civicrm_entity_altered_contact, modified_contact_civireport.id as log_civicrm_entity_altered_contact_id, entity_log_civireport.log_conn_id as log_civicrm_entity_log_conn_id, modified_contact_civireport.is_deleted as log_civicrm_entity_is_deleted, altered_by_contact_civireport.display_name as altered_by_contact_display_name
      FROM `log_civicrm_activity entity_log_civireport

      INNER JOIN `log_civicrm_activity_contact fk_table ON entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = 2
      INNER JOIN civicrm_contact modified_contact_civireport
      ON (fk_table.contact_id = modified_contact_civireport.id )
      LEFT JOIN civicrm_contact altered_by_contact_civireport
      ON (entity_log_civireport.log_user_id = altered_by_contact_civireport.id) WHERE ( modified_contact_civireport.id = 278486 ) AND (entity_log_civireport.log_action != 'Initialization') GROUP BY entity_log_civireport.log_conn_id, entity_log_civireport.log_user_id, EXTRACT(DAY_MICROSECOND FROM entity_log_civireport.log_date), entity_log_civireport.id "

      Feb 24 14:47:04 [info] ** QUERY DONE IN 5.717618 seconds. 90 row(s)s subject to insert action

        Attachments

          Activity

            People

            • Assignee:
              monish.deb Monish Deb
              Reporter:
              eileen Eileen McNaughton
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: