-
Notifications
You must be signed in to change notification settings - Fork 29
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 composition #257
Comments
Let's consider the usual example of articles collection
if you retrieve 10 articles, some may come from the same author, so when you build the list of 10 author ids ([1,2,3,2,2,4,5,6,7,3] some are duplicates; when you pass them to mongo in a $in query, mongo will return a smaller set (i.e. the unique authors [1,2,3,4,5,6,7], not necessarily in this order) |
The same happens, but in a more complex way, with multiple reference ids like categories which could have the same id stored multiple times, as in the above example |
Closed by d103f62 |
For a field of type reference, currently API looks up every record in the relevant collection
Considering a collection with X fields of type reference, an API query for N records will turn into N * X + 1 DB queries.
In the case of multiple references, this grows exponentially.
However, the _ids for each referenced collection could be grouped into a single query, and composition could happen in memory, bringing down the total number of queries to X + 1, regardless of the multiplicity of the references.
The text was updated successfully, but these errors were encountered: