Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-2137

Slow and useless queries being caused by contact creation

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 1.7
    • Fix Version/s: 1.8
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      Inside the isLocationEmpty function (CRM/Core/BAO/Location.php), there are several calls leading to potentially slow and definitely useless queries. Here are some examples:

      $location->find( true ); [calls the query->] SELECT * FROM civicrm_location
      $email->find( ); [calls the query->] SELECT * FROM civicrm_email
      $address->find( true ) [calls the query->] SELECT * FROM civicrm_address

      with no WHERE or ORDER BY clauses.

      To give more context, I have a Drupal site where anonymous users can sign petitions, and where a contact is created with crm_create_contact if their email is new. This site has nearly 200,000 contacts, and sometimes these petitions undergo heavy loads. I started noticing the above queries popping up, and causing massive MySql slowdowns (as you might imagine with so many contacts). I'm attaching the relevant parts of a trace generated by the wonderful civicrm_error Drupal module, which I called manually in _query when one of the above queries was made.

        Attachments

          Activity

            People

            • Assignee:
              sunil Sunil Pawar
              Reporter:
              mcarbone Marco Carbone
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: