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

dev/core#748 Move UPPER() from sql to php domain #13732

Merged

Conversation

mattwire
Copy link
Contributor

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.

@civibot
Copy link

civibot bot commented Feb 28, 2019

(Standard links)

@mattwire mattwire force-pushed the refactor_smartgroupquery_upper1 branch from 2b37c0a to 52cda5d Compare February 28, 2019 22:32
@eileenmcnaughton
Copy link
Contributor

I did some quick tests and this works fine. Code is simpler & I know there is some test coverage of alphabet queries - merge -on-pass

@seamuslee001
Copy link
Contributor

Merging as per the tag

@seamuslee001 seamuslee001 merged commit f680a12 into civicrm:master Feb 28, 2019
@mattwire mattwire deleted the refactor_smartgroupquery_upper1 branch March 1, 2019 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants