-
Notifications
You must be signed in to change notification settings - Fork 17
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
API limit restrict output to user, but doesn't restrict amount of data from mongodb #549
Comments
Based on an initial investigation, API uses |
It does not pass limit parameter, and if we talk directly with mongodb it is way faster. Example, over mongo cli on staging, similar query:
As you can see, it is way not 5 seconds, both are same (cause field is indexed), and lesser limit also means lesser execution time (approx proportionally). |
If you have a way to find out how the fastapi queries are translated into mongodb query calls, that'd be the fastest way to figure out what's happening for sure. fastapi-pagination ends up doing this, but it's not clear to me how the |
Here is a summary of my further investigation:
For the request http://localhost:8001/nodes?kind=job&limit=1&offset=2, I received the below prints:
To summarize, |
Ooc, isn't it counterproductive that fastapi-pagination:paginate() calls count_documents on the query without the limit parameter to retrieve the total number of results before running the actual find query? What's the point? Maybe it won't be noticeable, but I doubt that that count is necessarily cached. |
I did some experiments, and i suspect more and more this pagination library is not efficient at all. But not sure what are best solution, i guess we discuss with @JenySadadia outcome and results of tests and decide what are solution.
And paginated:
|
The implementation has changed in the latest version for |
This issue states that the latest version uses |
If we do two queries:
curl "https://staging.kernelci.org:9000/latest/nodes?kind=test&limit=1"
real 0m5.994s
user 0m0.012s
sys 0m0.000s
curl "https://staging.kernelci.org:9000/latest/nodes?kind=checkout&limit=1"
real 0m0.023s
user 0m0.012s
sys 0m0.000s
We can notice significant difference in response time. While it should be fast both (kind is indexed).
On preliminary investigation reason is that search query submitted to mongodb without limit parameter, which is causing very large output in case of some queries.
We need to resolve that, as it is also causing excessive load on database and ram consumption.
The text was updated successfully, but these errors were encountered: