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

Adds optimization for related relations #4345

Merged
merged 2 commits into from
Nov 14, 2017
Merged

Conversation

flovilmart
Copy link
Contributor

@flovilmart flovilmart commented Nov 13, 2017

So we ran a bit the aggregation optimization in prod and this was not satisfactory, not yielding enough benefits in terms of performance.

Went back to the drawing board and came up with this idea of leveraging the _id managed by mongoDB (which is ascending at creation time) to reduce the amount of keys pulled from the join table.

If you're sorting by createdAt ascending or descending, you'll benefit this optimization, otherwise, that will pretty much be the same.

@montymxb
Copy link
Contributor

Looks to be something up with the test case on postgres, maybe it doesn't know what to do with some of findOptions?

@codecov
Copy link

codecov bot commented Nov 14, 2017

Codecov Report

Merging #4345 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4345      +/-   ##
==========================================
+ Coverage   92.64%   92.64%   +<.01%     
==========================================
  Files         119      119              
  Lines        8426     8435       +9     
==========================================
+ Hits         7806     7815       +9     
  Misses        620      620
Impacted Files Coverage Δ
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 93.36% <100%> (+0.02%) ⬆️
src/Controllers/DatabaseController.js 94.84% <100%> (+0.07%) ⬆️
src/RestWrite.js 93.32% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7223add...5bd5cee. Read the comment docs.

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 👍 ! Also (if you've tested against this) how much of a benefit are you seeing from this change?

@flovilmart
Copy link
Contributor Author

Instead of pulling data from the full join (possibly 1000’s of objects) this will only pull a few. In only works you’re sorting on createdAt, as it’s represented on the mongoDB_id.

@montymxb
Copy link
Contributor

I got that, I just wanted to know if there was an actual benchmark of sorts that you might have had for a particular case. But that's just for my personal interest.

@montymxb
Copy link
Contributor

Beyond that we're good though!

@flovilmart
Copy link
Contributor Author

We're seeing very large data in some relations that are actually sorted this way, so that really helps if returning data faster :)

@flovilmart flovilmart merged commit 09fee7d into master Nov 14, 2017
@flovilmart flovilmart deleted the related-oid-sorting branch November 14, 2017 20:12
UnderratedDev pushed a commit to UnderratedDev/parse-server that referenced this pull request Mar 21, 2020
* Adds optimization for related relations

* Makes MongoStorageAdapter only able to sort on Join tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants