Skip to content

Make PostgreSQL authority export and restore set-based #215

Description

@ian-pascoe

Problem

PostgreSQL authority recovery paths perform N+1 work at supported bounds: export fetches referenced generations one query per distinct receipt generation, while restore awaits individual INSERTs for receipt/session/security-event rows. A large canonical restore can issue tens of thousands of round trips inside one transaction.

Acceptance criteria

  • Export fetches all referenced generations with one bounded JOIN/ANY query.
  • Restore uses set-based INSERT/UNNEST or bounded batches inside the same transaction.
  • Identity, digest, watermark, receipt replay, and maintenance-fence invariants remain unchanged.
  • Tests exercise documented maximum-domain shapes and demonstrate bounded query count.

Evidence

Review anchors: packages/core/src/storage/sql/authority.ts around PostgreSQL export (~2378) and restore (~2498).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions