I’m currently experiencing an issue making my app unusable: very slow queries.
I have to retrieve about 30 entities, composed of simple components and pictures, but the requests are unusually long, around 30s.
I searched quite a bit for a solution, tried to better target the data to be recovered in the controller, and finally reduced the time by almost 2. But 14s is far too long for a correct user experience, especially considering the amount of data to get back.
I saw that several people encounter the same problem as me, and that it would be related to auto populate.
I have very few backend and databases knowledge and this is the first time I created a backend. (that’s why I use Strapi ^^’)
Can you share your ./api/*/models/*.settings.js files and the components that are related to this model? Also, the query request you use to fetch the data so we could make some tests locally.
I’ll 2nd @sunnyson here, if you can share your project code or the parts he mentioned so we can play locally that would help us try to figure out a good solution for you.
Also when it comes to relations, it’s generally my suggestion to use a SQL database as we are aware of some pain points when it comes to relation population performance on MongoDB.
Also when it comes to relations, it’s generally my suggestion to use a SQL database as we are aware of some pain points when it comes to relation population performance on MongoDB.
Strapi currently does not officially support Node v15.* . The recommended version is v14.*
Can you install nvm and switch to Node’s LTS version and repeat the tests? Also don’t forget to delete node_modules folder and reinstall all the packages before repeating the tests.
Interesting behavior here. We need to make more tests. In my case for 10 events with 10pictures each is working fine, 500-600ms for the first request(after restarting strapi), and 50-100ms for others.
So you have 30 events? How many images your events do contain in main_pictures and additional_pictures ?
Yeah, it worked well during dev with my tests files too. I had like 5 events, with 2 iterations and something like 10 pictures max. I don’t really know from when the queries become so slow, I guess it’s more or less exponential.
So, there are currently 27 events. Each events has at least 2 iteration, up to 6 for now. And each iteration has between 15 to 20 main_pictures, and 20 to 100 additional_pictures.
To give you a bit of context, this is a site for a photographer that covers events every year. So there is an event which contains one iteration per year.
Indeed, I could replicate your issues after creating a few more events with pictures of them.
The Media library takes up to 15seconds to load 8 pictures. I’ve added the same pictures to all events.
At the first view, it seems that problem is related to files Relations.
GET /events → 5 seconds response time (10 events) GET /upload/files → 15 seconds response time (8 pictures)
If I restart strapi after creating events & pictures, it gets back to normal.
After strapi restart: GET /events → 100ms response time (10 events) GET /upload/files → 20ms response time (8 pictures)
We will look deeper into this case to have a bit more information about what’s happening to open a bug issue.
That’s a good thing that you could reproduce the slow query behavior.
In my case, however, the behavior is a little different. I have no slowdown to access the Media Librairy. And I tried to restart strapi but it doesn’t solve the slowness in requests.
I had the same issue couple days ago. Wasn’t even using images but rather 4 to 5 relation fields on mondoDB within one collection. Couldn’t figure out a fix and since it was the initial stage of the project decide to not use Strapi.
If you guys figure out a fix let me know
I too have the problem where the requests are very slow even on localhost using the build version. At first it’s about 300-500 ms and successive requests are about 50-150 ms.
When I wait around 10 seconds the request time is 300-500 ms again.