Consider a table ‘transactions’ with a composite index on (status, created_at). You execute the following query: SELECT id, amount FROM transactions WHERE status = ‘COMPLETED’ AND created_at > ‘2023-01-01’ OR status = ‘PENDING’; Given the operator precedence in SQL, how will the database engine likely process this filter, and what is the impact on index utilization?
Key points
- SQL operator precedence: AND is evaluated before OR.
- Impact of OR on index SARGability (Search ARGumentable).
- How logical grouping affects the query optimizer's execution plan.
Ready to go further?
