-
Notifications
You must be signed in to change notification settings - Fork 13
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
Improve pouchDB performances #1537
Conversation
The `view_update_changes_batch_size` parameter is used to determine the docs batch size when computing view updates. PouchDB default is 50, which is quite low, and badly hurt performancs when dealing with thousands of docs and the first view computation. With a 44K files database, in a react-native env: **Before:** Indexing time: 53 868 ms **After:** Indexing time: 31 833 ms
The react-native PouchDB adapter does not handle partialIndexes: it means that any predicate in partialIndex will not be evaluated at indexing time, but at querying time. When dealing with huge database, this can be quite impactful because it will result in full-scan of huge indexes. Therefore, we now force the indexing of any field in partialIndex, to guarantee a doc will be indexed if and only if it has all the necessary attributes. We measured performances for this query: https://github.com/cozy/mespapiers/blob/ e456faaa00dcefef13c6eee88459caffcac4f2d4/src/queries/index.js#L64-L105 **Before:** Query time: 51 499 ms **After:** Query time: 1 854 ms
indexedFields = Array.from( | ||
new Set([...indexedFields, ...Object.keys(partialFilter)]) | ||
) | ||
// FIXME: should properly handle n-level attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the impact for now? Should we handle this soon? Or it is for an hypothetical future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now it means that if we have queries with partialIndex having attributes not on the root level, i.e. with $and: [{...}]
, we won't benefit from this fix. Thus slow queries.
So hopefully there is no regression regarding the current offline, but we should test it carefully
`cozy-pouch-link` has been upgraded to `49.1.0` to retrieve performance improvements on Pouch queries Related PR: cozy/cozy-client#1537
Nice! 30s to index 40k documents is still huge :( |
`cozy-pouch-link` has been upgraded to `49.1.0` to retrieve performance improvements on Pouch queries Related PR: cozy/cozy-client#1537
`cozy-pouch-link` has been upgraded to `49.1.0` to retrieve performance improvements on Pouch queries Related PR: cozy/cozy-client#1537
`cozy-pouch-link` has been upgraded to `49.1.0` to retrieve performance improvements on Pouch queries Related PR: cozy/cozy-client#1537
`cozy-pouch-link` has been upgraded to `49.1.0` to retrieve performance improvements on Pouch queries Related PR: cozy/cozy-client#1537
`cozy-pouch-link` has been upgraded to `49.1.0` to retrieve performance improvements on Pouch queries Related PR: cozy/cozy-client#1537
`cozy-pouch-link` has been upgraded to `49.1.0` to retrieve performance improvements on Pouch queries Related PR: cozy/cozy-client#1537
We noticed severe performances issues when using pouchdb in a react-native environment.
See commit descriptions for more insights
BEFORE
AFTER