API calls to /stock/products/ are slow
See original GitHub issueI recently noticed that API calls to /stock/products/
are rather slow. First I thought it might be because the routing is not cached, but adding
$routeCollector = $app->getRouteCollector();
$routeCollector->setCacheFile(GROCY_DATAPATH . '/routecache');
to app.php
did not increase the performance significantly, therefore the problem is probably somewhere else. My current database has 246 products, 261 stock entries and around 3000 stock logs. Deleting the stock logs did not increase the performance. On average a /stock/products/
API call takes around 650ms, while a call like /stock/shoppinglist/remove-product
takes only around 100ms.
Unfortunately I did not find any causes for the problem, do you have any idea how to improve the speed?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Rest API Requests are slow - Magento Forums
Hi All, We are using the third party vendor for stock & product management. They are updating the custom attributes in Magento 2...
Read more >HTTP 429 Error and very slow execution using APIs from ...
When I explictly set my API key in the environment variable NASDAQ_DATA_LINK_API_KEY or read it from a file with nasdaqdatalink.read_key( ...
Read more >How can I deal with a slow API in PHP?
I've accessed the data, but it turns out that i have to query each product individually for stock data. With thousands of items...
Read more >Top 7 Best Stock Market APIs for Developers in 2022 - RapidAPI
In this article, we'll review the Best Stock Market APIs out there, including APIs such as Yahoo Finance, Alpha Vantage, Robinhood, and more ......
Read more >WP Rest API too slow? - Medium
In the example above i am pulling 12 products from the database and ... This is an extremely simple and common data request,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
/stock/products/*
endpoints should now be noticeable faster (done by @fipwmaqzufheoxq92ebc in #927).So I just ran some tests, and the DB calls themselves in that function are not the problem, it seems to be
function GetCurrentStock
inStockService
which takes 500-700ms, the root of the problem seems to be the line$currentStockMapped = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_GROUP|\PDO::FETCH_OBJ);
I will have a further look into it.