Skip to content

perf: one-statement claims, a partial pending index, ack ids from row ids - #13

Merged
fahimfaisaal merged 2 commits into
feat/v03-apifrom
perf/lean-statements
Oct 23, 2026
Merged

fahimfaisaal merged 2 commits into
feat/v03-apifrom
perf/lean-statements

Conversation

@fahimfaisaal

@fahimfaisaal fahimfaisaal commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Stacked on #12 (feat/v03-api). Second of five for sqliteq v0.3.0.

What changes

  • Each claim and pop is now one UPDATE/DELETE ... RETURNING statement, sorted back into queue order. It replaces the select-then-update transaction.
  • Queue order is by row id (priority, id for priority queues) instead of created_at.
  • One partial index on pending rows. Opening a table drops the four v0.2 indexes and creates <name>__sqliteq_pending. The suffix keeps index names from colliding with queue names, since SQLite keeps tables and indexes in one namespace.
  • Ack ids are row ids. An ack matches only a processing row, so garbage ids, v0.2 cuids and repeat acks return false.
  • Statements are prepared once per handle, the pool keeps 8 idle connections, and the lucsky/cuid dependency is gone.

v0.2.x files migrate on open: their data is kept and the index swap is idempotent. The tests include a v0.2.3 file fixture.

Tests

go test -race ./... passes. New tests cover the migration from a v0.2.3 file, the index-name collision and concurrent claims without duplicates.

Fixes #6
Fixes #7

… ids

Claims and pops are one UPDATE/DELETE ... RETURNING statement, sorted back
into queue order. Queue order is id (priority, id for priority queues), not
created_at. Opening a table drops the four v0.2 indexes and creates one
partial index on pending rows. The ack id is the row id; acks match only
processing rows, so garbage, v0.2 cuids and repeat acks return false.
Statements are prepared once per handle, the pool keeps 8 idle connections,
and lucsky/cuid is gone.
SQLite keeps tables and indexes in one namespace. With the index named
<name>_pending, a single file could not hold queues orders and
orders_pending: whichever opened second failed. The index is now
<name>__sqliteq_pending.
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.39216% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
queue.go 79.31% 19 Missing and 11 partials ⚠️

📢 Thoughts on this report? Let us know!

@fahimfaisaal
fahimfaisaal merged commit 44746f7 into main Oct 23, 2026
1 of 2 checks passed
@fahimfaisaal
fahimfaisaal deleted the perf/lean-statements branch October 23, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant