Like every dev in 🇪🇹, I finally caved… the “every ethiopian dev has a telegram channel” thing has reached me lol.
I’ll log my dev journey, resources and mixing in a bit of life.
Come hang: https://t.me/kalebdev
I’ll log my dev journey, resources and mixing in a bit of life.
Come hang: https://t.me/kalebdev
Telegram
Caleb
Caleb here ... a living proof that anyone can code. come see what I'm building and maybe learn something (or at least laugh at my struggles)
kalebalebachew.com
kalebalebachew.com
🔥10😁3
I recently ran into a tricky bug with Laravel’s whereDate().
the thing is i wanted to filter records of the past 24hrs and did this:
On my local database it behaved fine. But once deployed to production with millions of rows, the query kept timing out.
The issue was that whereDate() applies a DATE() function to the column, which disables index usage and forces a full table scan. On large datasets, this quickly leads to timeouts.
The fix was to switch to a range query that allows the index to work properly:
Lesson learned: Eloquent methods aren’t always safe at scale 😅
the thing is i wanted to filter records of the past 24hrs and did this:
Model::whereDate('created_at', today())->count();On my local database it behaved fine. But once deployed to production with millions of rows, the query kept timing out.
The issue was that whereDate() applies a DATE() function to the column, which disables index usage and forces a full table scan. On large datasets, this quickly leads to timeouts.
The fix was to switch to a range query that allows the index to work properly:
Model::whereBetween('created_at', [today()->startOfDay(), today()->endOfDay()]);Lesson learned: Eloquent methods aren’t always safe at scale 😅
⚡3