Caleb
127 subscribers
49 photos
2 videos
49 links
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
Download Telegram
Channel created
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
🔥10😁3
Linkedin 😭🤦🏿‍♂️🤦🏿‍♂️
2🤣1
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:

 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