-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REF] Remove ACL join on temp table creation in Member ContributionDe… #17723
[REF] Remove ACL join on temp table creation in Member ContributionDe… #17723
Conversation
(Standard links)
|
Note that the ACL join is still added in the main query https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Form/Member/ContributionDetail.php#L456 and the whereClause is added appropriately in the main report query https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Form.php#L2783. All this is doing is joining onto the acl contact cache without any where attached so its just adding rows to scan for no reason |
@seamuslee001 so there are 2 logics in play here
My suspicion is that performance would vary by site - for example a user with a relatively small permissioned set on a large site would build a much smaller temp table. I would also note that my take on the queries is that the temp table is not doing anything that I would expect to be making the query faster & my guess is that bypassing the temp table would be just as fast & would avoid the 'create a huge temp table in obscure circumstances' issue
the final query uses both mechanisms
|
@eileenmcnaughton so what would be your suggestion here? kill the temp table? |
@seamuslee001 yeah - possibly? Are you coming at this from a performance POV? Leaving well enough alone is one option - but if you are hitting performance issues that suggests you have a site you could do some tests on & see if the query would be better without the temp table |
yeh @johntwyman shared with me a situation where this temp table had caused write level lock on acl_contact_cache table which was then causing a deadlock for another ACLed user |
Hmm - and this recurred? |
We're starting to collect a lot more data for this so we'll have more exact info to share in due course, but broadly speaking we're seeing deadlocks hurt us rather than straight out, "this query takes too long" performance issues. Over the last couple of months we've been seeing deadlocks on the ACL cache table enough times to notice it (along with civicrm_contact, civicrm_group_contact_cache). I'll try and get more exact data for you. |
@johntwyman I would note that in my testing I found that replacing the foreign keys on acl_contact_cache with indexes helped. The reason being it prevents the table getting involved in contact actions (notably but not only delete). We hit deadlocks on this cache even though it is always empty (under high load) With the FK gone the ON DELETE CASCADE no longer happens - but I would argue it shoudn't and likely doesn't need to |
We've already removed the Foreign Key. The problem was more the use of the
|
@johntwyman I'm happy to merge this based on your experience given that you are hammering this code - I suspect the whole temp table thing should go but that seems compelling enough to not block this |
…tail report
Overview
This removes an unnecessary join onto the civicrm_acl_contact_cache table when populating the temporary table. The ACL join and where clause is correctly applied in the main report query
Before
Unnecessary Join to acl_contact_cache
After
No unnecessary join to acl_contact_cache table
ping @eileenmcnaughton