dev/core#748 Move UPPER() from sql to php domain #13732
Merged
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.
Overview
Extracted from #13713
Using UPPER()/LOWER() in SQL queries causes the query to stop using indexes. The query for the
the first, slowest, query when doing a search is just to generate any extended characters for the alphabet pager across the top of the search results!
Before
Very slow query for complex smartgroups / larger datasets.
After
Removed both "UPPER()" functions from the "alphabet" query (as that stops it using indexes) and moved that to the PHP level. Query much faster and no functional change.
Technical Details
Combined with further work in #13713 to reduce left joins this reduced a number of queries from infinity to < 1 second on a site with a number of complex smartgroups.
Comments
There is precedent for removing UPPER/LOWER from SQL as it is known to cause performance issues.
@eileenmcnaughton I've extracted
alphabetQuery()
in this too.