System Configuration: Civi - 5.52.3 (8-30-22) Drupal - 7.94 PHP - 7.4.33
From advanced contact search, deleting contacts in small groups works okay, but if we try to select and then delete 50 or more, the operation fails with no real error message, maybe a time out? We would like to be able to delete 50 or more records at once. That's our main issue. Below is what I can see might be going wrong...
I turned on SQL trace/capture trace to see if I could find where it was going wrong. All SQL ops are very quick, normally < 0.01sec. There is 1 query related to the attempted delete that is taking 7-10sec for each of the contact ids being deleted:
SELECT cc.id, cc.display_name FROM civicrm_address ca1 INNER JOIN civicrm_address ca2 ON ca1.id = ca2.master_id INNER JOIN civicrm_contact cc ON ca2.contact_id = cc.id WHERE ca1.contact_id = 1560824;
I checked available indexes and every index I would have added is already on the tables. I then noticed all of our civicrm_address.master_id's are null, so this query runs very quickly:
SELECT cc.id, cc.display_name FROM civicrm_address ca1 INNER JOIN civicrm_address ca2 ON ca1.id = ca2.master_id INNER JOIN civicrm_contact cc ON ca2.contact_id = cc.id WHERE ca1.contact_id = 1560824 and ca1.master_id is not null;
Both the fast and slow versions return zero rows.
Guessing here, but this query seems to be a test to make sure the master_id is not deleted. Our app is not using civicrm_address.master_id and we don't know its purpose in Civi. Is there some way to tell Civi not to do this test? Thanks