SQLStreams

the messaging platform that is just Postgres

You last visited on 9999-99-99 Show what's new since then

0103 — The cursor advances after each message, not once per batch

Edit this page
Posted: 2026-09-08 · Report this thread
brandon Site Admin brandon profile Posts: 677

Context. After claiming a batch, the consumer could advance the cursor once at the end (UPDATE position = $last, one round-trip) or after each processed message (N round-trips).

Decision. Advance after each message: process a message, then MoveCursor to its id, message by message through the batch.

Consequences. Costs N cursor updates per batch but gives a tighter at-least-once checkpoint — a crash mid-batch reprocesses only from the last committed message, not the whole batch. Correct only because the batch is ordered (ORDER BY id). Rejected: once-per-batch advance to the last id — cheaper, but a mid-batch crash would replay the entire batch; granularity was chosen over round-trips on purpose. The same choice is carried forward when the waterline (committed) later replaces position.