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

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

commented May 31, 2018

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
resolves  #2937
@brandonkelly

This comment has been minimized.

Copy link
Member

commented Jun 2, 2018

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

brandonkelly added a commit that referenced this pull request Jun 2, 2018
resolves  #2937
@stephenfrank

This comment has been minimized.

Copy link
Author

commented Jun 4, 2018

Sweet 👍😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.