Skip to content

perf: replace idx_tx_last_seen with partial index WHERE last_seen=0 #1740

@Kpa-clawbot

Description

@Kpa-clawbot

Context

Raised by Carmack in PR #1735 (round-1 review). Currently idx_tx_last_seen indexes (last_seen, id) for ALL transmissions; the only consumer (chunkedTxLastSeenBackfill) only ever scans WHERE last_seen=0.

Proposal

Replace with a partial index:

CREATE INDEX idx_tx_last_seen_zero ON transmissions(id) WHERE last_seen=0;

Why

  • Index size shrinks to ~the count of unprocessed rows (typically 0 after backfill completes; bounded by ingest rate during normal ops).
  • Once the backfill finishes, the partial index becomes near-empty and stops competing for cache.

Risk

  • Requires CREATE INDEX migration via RunAsyncMigration (the new index) + a follow-up DROP INDEX idx_tx_last_seen once the partial is built and verified. Two-step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions