Skip to content
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

Use static cache for UFMatch lookups to improve performance #12628

Merged
merged 1 commit into from
Aug 20, 2018

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Aug 6, 2018

Overview

Avoid excessive database hits by caching the UF/CID match records.

Before

More db lookups; slower

After

Fewer db lookups; faster

Notes

This is a supplement to #12576 which can potentially cause the CRM_Core_BAO_UFMatch::getUFId() to be called dozens of times per request. This caching ensures that we don't suffer a performance hit in doing so.

@civibot
Copy link

civibot bot commented Aug 6, 2018

(Standard links)

@eileenmcnaughton
Copy link
Contributor

@colemanw ... nope

@colemanw
Copy link
Member Author

colemanw commented Aug 6, 2018

Whoops, php really don't like it when you try to check a key for a nonexistent array. Now fixed.

@colemanw
Copy link
Member Author

colemanw commented Aug 7, 2018

@civicrm-builder retest this please

@colemanw
Copy link
Member Author

colemanw commented Aug 7, 2018

@eileenmcnaughton ... yep

@eileenmcnaughton
Copy link
Contributor

I read through this & stepped through this. The getUFId function is called 4 times from the contact summary page so this eliminated 3 DB queries.

The getContactID is called when editing a user but no obvious query reduction.

I only tried this on a single domain but I feel like it's pretty safe having stepped through it in a debugger & I guess it can sneak through without a test

@eileenmcnaughton eileenmcnaughton merged commit 77727ea into civicrm:master Aug 20, 2018
@eileenmcnaughton eileenmcnaughton deleted the Use branch August 20, 2018 03:00
@colemanw colemanw restored the Use branch January 12, 2019 01:05
@colemanw colemanw deleted the Use branch January 12, 2019 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants