Very slow response... Hi Artisans
I've a query in my project that runs within 112ms in the dev environnement (with the same exact amount of data as on production )..
On production server it takes 7.28s ( TTFB)..
what causes that ?
is it from the web server ?
Thank you
What kind of environment do you have on the production server?
Are you hitting the database?
Is the database on the same server or a remote one?
Do you have large images?
1 - Ubuntu Vps
2 - Yes
3 - same server
4 - No
I think the issue is from the query..
because I tried to remove the query and the page loaded quickly ( so it's an issue from the application not the server)
I don't know why there is no issues in my local dev ..
That's my query..
$zones = Zone::withCount([
'trashes' => function ($query) {
$query->whereDoesntHave('pointings', function ($queryPointings) {
$queryPointings->whereMonth('created_at', Carbon::now()->month);
});
}])
->having('trashes_count', '>', 0)
->get();
I added an index on created_at field from pointings table but no way..
I also have an index on zone_id field from trashes table..
If you change the ->get() to ->toSQL() and then run the query generated in a database tool like tableplus or similar after adding the keyword explain in front of it.
explain select id from some_table;
Then show both the query and the resulting plan.
Please sign in or create an account to participate in this conversation.