2026-05-05 11:56:15+08
As databases grow, minor inefficiencies become major bottlenecks. This prompt helps you apply senior-level database optimization techniques to your existing queries.
Optimize the following SQL query for better performance on a large "orders" table with millions of rows: SELECT * FROM orders WHERE status = 'shipped' AND created_at > '2025-01-01' ORDER BY created_at DESC LIMIT 100;. Suggest necessary indexes.
The AI will analyze the "WHERE" and "ORDER BY" clauses to suggest composite indexes, which are the most effective way to speed up complex queries on large datasets.
Suggestion: Create a composite index on (status, created_at). This allows the database to filter and sort in a single operation without a full table scan.