Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.6, 4.7
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Needs Funding
Description
Some queries generated by the search builder takes forever (i have to stop them after more than one hour and no more disk space available).
Example of query generated by CiviCRM when doing a search for contacts that are in 3 groups at the same time (even 2 groups could be very long) :
SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name FROM civicrm_contact contact_a LEFT JOIN civicrm_group_contact `civicrm_group_contact-942` ON (contact_a.id = `civicrm_group_contact-942`.contact_id AND `civicrm_group_contact-942`.status IN ("Added")) LEFT JOIN civicrm_group_contact `civicrm_group_contact-943` ON (contact_a.id = `civicrm_group_contact-943`.contact_id AND `civicrm_group_contact-943`.status IN ("Added")) LEFT JOIN civicrm_group_contact `civicrm_group_contact-980` ON (contact_a.id = `civicrm_group_contact-980`.contact_id AND `civicrm_group_contact-980`.status IN ("Added")) LEFT JOIN civicrm_group_contact_cache `civicrm_group_contact_cache_942` ON contact_a.id = `civicrm_group_contact_cache_942`.contact_id LEFT JOIN civicrm_group_contact_cache `civicrm_group_contact_cache_943` ON contact_a.id = `civicrm_group_contact_cache_943`.contact_id LEFT JOIN civicrm_group_contact_cache `civicrm_group_contact_cache_980` ON contact_a.id = `civicrm_group_contact_cache_980`.contact_id WHERE ( ( ( ( `civicrm_group_contact-943`.group_id = 943 ) OR ( `civicrm_group_contact_cache_943`.group_id = 943 ) ) AND ( ( `civicrm_group_contact-980`.group_id = 980 ) OR ( `civicrm_group_contact_cache_980`.group_id = 980 ) ) AND ( ( `civicrm_group_contact-942`.group_id = 942 ) OR ( `civicrm_group_contact_cache_942`.group_id = 942 ) ) ) ) AND (contact_a.is_deleted = 0) GROUP BY contact_a.id ORDER BY UPPER(LEFT(contact_a.sort_name, 1)) asc