Skip to content

Read live advert roles in one database round trip - #357

Draft
n30nex wants to merge 4 commits into
devfrom
codex/advert-roles-20261126
Draft

n30nex wants to merge 4 commits into
devfrom
codex/advert-roles-20261126

Conversation

@n30nex

@n30nex n30nex commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #356.

The old path read a full observer row and separately queried the claim. The ingest worker now fetches the two independent flags in one SQL statement. Existing public store methods remain available. The live event shape and all writes are preserved.

The regression counted two role reads before the change and one after it. Tests cover observer-only, claim-only, both, neither and a lookup error.

November 26 qualification

On a private restored PostgreSQL 16 database, both implementations agreed for 250 existing keys and four role combinations in a temporary fixture. Across seven alternating trials the median batch fell from 232.0 ms to 127.1 ms, with 500 queries reduced to 250. These are loopback results for the two role flags. Tested against dev 5fb32926f719 at 7be0c820d91c. CI · Preview handoff

November 29 review

The query now matches the current upstream definition, including a foreign claim or foreign readings received within the last 24 hours. A PostgreSQL regression exposed the earlier lost foreign role and verified that expired readings stop marking an observer as a poller. On a fresh private restore, 249 real keys and eight fixtures produced identical flags. Seven alternating trials reduced queries per batch from 498 to 249 and median role-read time from 40.5 ms to 23.9 ms. This draft at cc4f365ab3c5 merges cleanly into dev 0c1d7b7d0d84. The resulting files match both GitHub’s test-merge tree and the tested draft head. CI · Preview handoff

@n30nex n30nex added improvement Enhancement to existing feature p2-medium Medium priority release:patch Candidate patch work: fixes/hardening without a new feature line; not release acceptance. labels Nov 26, 2026
@MrAlders0n MrAlders0n added this to the 2.3.1 milestone Nov 27, 2026
…vert-roles-20261126

# Conflicts:
#	db/sqlc/polling.sql.go
…vert-roles-20261126

# Conflicts:
#	db/polling_foreign_integration_test.go
#	internal/ingest/ingest.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Enhancement to existing feature p2-medium Medium priority release:patch Candidate patch work: fixes/hardening without a new feature line; not release acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid two database reads for roles on each live advert

2 participants