Resume a Bounded Backfill Batch
Return the next three events after event_id 104, without reading beyond high-water event_id 110.
- Filtering
- Sorting
- Top-N
Exercise brief
Understand the request
Data migration engineer A resumable backfill must stop at the high-water mark captured when the run began.
Resume a keyset-paginated backfill after event_id 104 while respecting the event_id 110 high-water mark.
Return
- Return event_id, event_time, stream, and severity.
- Return the next ascending three-row batch.
Constraints
- Use exclusive lower and inclusive upper event_id bounds.
- Order by event_id and apply a three-row limit.
- Do not use OFFSET.
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
page_events
event_idINTEGERevent_timeTIMESTAMPstreamTEXTseverityINTEGER
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
The saved cursor is an exclusive lower bound.
Hint 2
The run high-water mark is an inclusive upper bound.
Hint 3
Filter 104 < event_id <= 110, order by event_id, then take three.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT event_id, event_time, stream, severity FROM page_events WHERE event_id > 104 AND event_id <= 110 ORDER BY event_id LIMIT 3;Why this works
A high-water bound prevents a long-running backfill from chasing rows inserted after the run started. The lower cursor makes each batch resumable without rescanning skipped rows.
Success check
The batch resumes after 104 while remaining inside the frozen 110 boundary.
Expected result
Use this output to verify values, aliases, ordering, and row count.
| event_id | event_time | stream | severity |
|---|---|---|---|
| 105 | 2025-05-04 08:00:00 | payments | 2 |
| 106 | 2025-05-03 09:00:00 | orders | 4 |
| 107 | 2025-05-03 09:00:00 | payments | 4 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Build the next SQL skill
ORDER BY & Sorting
Practice deterministic SQL ordering with tie-breakers, custom priorities, NULL placement, expressions, joined data, aggregates, and portable top-N patterns.
Ranking & NTH Value
Solve deterministic ranking, top-N, distribution, positional-frame, and rolling-window problems.
SELECT Statements
Select columns, filter rows, remove duplicates, and order query results.
Open the interactive workspace and practice across SQL topics.