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

Fix (sometimes serious) performance problem on submitting profiles for specified contacts #13606

Merged
merged 1 commit into from
Feb 17, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Prevents unnecessary soul-destroying & sometimes server-destroying queries when submitting a profile for a known contact id

Before

Despite the contact id being known ($form->_id) and ultimately used the code does expensive queries to retrieve possible duplicates (before discarding that information). When using a profile block with only tags in it with contactlayouteditor this creates a query that makes strong servers cry

After

Unnecessary queries not run

Technical Details

$form->_id is set when the contact id is known - e.g in edit, in contactlayouteditor profile
blocks. However, current logic still retrieves duplicates and then... does nothing
with them if ->_id is set. By moving the if up higher we can save the server from
doing unnecesary queries. Note that if you submit a tag profile with no other fields in it
the query is server-destroyingly bad with this

Comments

@colemanw here is the fix to civicrm/org.civicrm.contactlayout#46 following up on the preliminary refactor you reviewed.

@civibot
Copy link

civibot bot commented Feb 15, 2019

(Standard links)

…r specified contacts.

->_id is set when the contact id is known - e.g in edit, in contactlayouteditor profile
blocks. However, current logic still retrieves duplicates and then... does nothing
with them if ->_id is set. By moving the if up higher we can save the server from
doing unnecesary queries. Note that if you submit a tag profile with no other fields in it
the query is server-destroyingly bad with this
@colemanw
Copy link
Member

Looks great. Bonus points for snarky code comments.

@colemanw colemanw merged commit 094707c into civicrm:master Feb 17, 2019
@eileenmcnaughton eileenmcnaughton deleted the profile_perf branch February 17, 2019 01:03
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.

2 participants