Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Won't Fix
-
Affects Version/s: 4.7.2
-
Fix Version/s: 4.7.5
-
Component/s: None
-
Labels:
-
Documentation Required?:None
-
Funding Source:Contributed Code
Description
We have been seeing terrible performance on Export. The export query exports 6 columns and 45000 rows and we were seeing it consistently time out (apparently it was completing in 4.2).
The query itself takes 10 seconds. Removing the group by contact_id would have brought it down to 5 but this turned out not to be the major issue.
The query was running 5 times in order to get the 45,000 rows. Given the group by clause these each took 10 seconds. In addition the query to get the state province id was running 45,000 times.
There are a bunch of other areas where it could be improved but addressing those 2 got it down to a minute, which is a good first step.
1a) Query limit. This was identified in https://issues.civicrm.org/jira/browse/CRM-7675 as a performance issue. However, Lobo said it was to manage memory usage. However, in CRM-17748 Steve Binkowski demonstrated a better way of managing memory usage for large queries. I have leveraged that and increased the rows 10-fold
1b) It turned out that an extra query was being run returning zero rows due to the loop only being broken at that point. I altered the logic to check if the return was less than the limit before doing another query
2) StateProvinceAbbreviation - this was not actually using the cache. I improved it so it works when an id is passed in but it's still pretty marginal when id isn't passed in. I don't think it's any worse in that case now though