Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ElementsService optimization - switch to where-in statement when querying for elements with array of IDs #2937

Closed
wants to merge 1 commit into from

Conversation

stephenfrank
Copy link

Hi,

I found a performance bottleneck in a project that includes quite a complicated document search page...

When querying for entries by using a large set of IDs, ~4000 or so, (eg. $criteria->id = [large array]) the default behaviour creates a group of "OR" statements i.e.

... (elements.id='26819') OR (elements.id='27612') OR (elements.id='27968') ...

This query was taking in the area of 2500ms to return a result.

When I experimented and switched this to a IN statement i.e.

`elements`.`id` IN ('27612', '26819', '27613' ...)

... then the query time is dramatically improved to around 370ms. The total load is taken down from 10s to 2.5s.

For me this is a must keep update in the project I'm working on and I'd be interested to see if it could be included in the main project.

brandonkelly added a commit that referenced this pull request Jun 2, 2018
@brandonkelly
Copy link
Member

Fixed this from DbHelper::parseParam() instead, but thanks for the nudge!

brandonkelly added a commit that referenced this pull request Jun 2, 2018
@stephenfrank
Copy link
Author

Sweet 👍😀

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants