task Query plans & SARGable filters · medium
Make the event-day filter SARGable
The starting approach is SELECT id,event_at,amount FROM market_query_log WHERE date(event_at)='2025-01-04' ORDER BY event_at,id. Rewrite the filter, create a full index on exactly (event_at), and return the same rows using an indexed search.
what to return
- Columns
idevent_atamountin this order- Rows
- 1444 rows · in the order asked
- Watch for
- Timestamps are normalized UTC ISO strings. Include midnight on January 4, exclude midnight on January 5.
- Order by event_at then id ascending. Do not change source rows or use an expression index.
- Skill
- Preserve day-filter semantics while enabling a timestamp index search. Refresher: Partitioning & workload trade-offs →
expected result
Your query should return exactly these columns and values. Run it and compare.
expected result1444 rows · in this order
| id | event_at | amount |
|---|---|---|
| 4320 | 2025-01-04 00:00:00 | 320 |
| 12001 | 2025-01-04 00:00:00 | 700 |
| 4321 | 2025-01-04 00:01:00 | 321 |
first 3 of 1444 rows
data you can query
Sample rows from each table. Each column shows its type underneath; → marks a link to another table.
market_query_log5 columns · 0 rows
all 0 rows
solution.sql
Hints and the answer are always available. Using them counts the question as solved with help.