question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API calls to /stock/products/ are slow

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
berrndcommented, Aug 18, 2020

The /stock/products/* endpoints should now be noticeable faster (done by @fipwmaqzufheoxq92ebc in #927).

1reaction
Forceucommented, May 14, 2020

So I just ran some tests, and the DB calls themselves in that function are not the problem, it seems to be function GetCurrentStock in StockService 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found