A range query on an indexed timestamp column silently skips the index due to a non-sargable predicate.
Codesql
CREATE INDEX idx_orders_created ON orders(created_at);
-- Report: all orders placed on 2024-01-15
SELECT o.id, o.total, c.name
FROM orders o
JOIN customers c ON c.id = o.customer_id
WHERE DATE(o.created_at) = '2024-01-15'
ORDER BY o.created_at;
The query runs slowly and the planner reports a full table scan on orders despite the index. What is the bug?