Which predicate on an indexed order_date column can use a B-tree index?
Correct answer
C. order_date >= '2024-01-01' AND order_date < '2025-01-01'
17 views
C. order_date >= '2024-01-01' AND order_date < '2025-01-01'
17 views
Sargability means the indexed column is compared directly with a value, without a function or arithmetic wrapping it, so the engine can seek a range instead of scanning. EXTRACT, CAST and arithmetic on the column force per-row evaluation and usually a full scan. Rewriting as a half-open range on the raw column also handles the time component correctly.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.