dev/core#367: Query optimization for A-Z pager by adding indices to t… #12740
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…emp table.
Overview
As described at https://lab.civicrm.org/dev/core/issues/367, sites with large numbers of "spouse" relationships (or other reciprocally named relationship types) can encounter WSOD and/or minutes-long wait times when performing an Advanced Search on that relationship type with a "target contact is in group" criteria.
Before
As described in the ticket repro steps, a particular set of criteria for Advanced Search, performed on a sufficiently large contact base, results in either a minutes-long wait for search results, or a fatal error "Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred.
DB Error: unknown error"
After
On the same site with the same search criteria, wait time is reduced to mere seconds.
Technical Details
Just adding a couple of indices and matching column definitions (e,g, unsigned int 10) for columns that need them in the temporary table that's used to flatten relationships before searching.
Comments
Kinda hard to reproduce considering you need a fairly large contact base. Also not sure how we could test for this.