whereDate('created_at', $date) looks clean, but on a big table it quietly drops your index and does a full scan. The Problem Say you want notifications created on a specific day. The obvious call: UserNotification::query() ->whereDate('created_at', '2026-04-23') ->get(); Laravel generates this SQL: SELECT * FROM user_notifications WHERE DATE(created_at) = '2026-04-23' See DATE(created_at
Laravel whereDate() Silently Kills Your Index
Ivan Mykhavko·Dev.to··1 min read
D
Continue reading on Dev.to
This article was sourced from Dev.to's RSS feed. Visit the original for the complete story.