Skip to content

fix(odnelazm-ingest): Bulk writes for ingest and enrich operations #76

Description

@c12i

Right now every speaker upsert, bill mention insert, topic insert, and contributor link in ingest_sitting is a separate round trip. For a typical sitting with 20+ speakers and 10+ bills that is easily 100+ queries per sitting. ingest_members has the same pattern: one upsert_member per row in a loop.

What to change

  • Add bulk variants (or make bulk the defacto operation) to the DataStore trait for the hot paths:
    • upsert_speakers_bulk
    • upsert_bill_mentions_bulk / link_speakers_to_bill_mentions_bulk
    • upsert_topics_bulk / link_speakers_to_topics_bulk
    • upsert_members_bulk
  • Implement them in postgres.rs using UNNEST-based bulk upserts
  • Update IngestPipeline to collect extracted data per sitting and flush in one call per entity type instead of looping

The enrich store_*_summary methods are one-at-a-time by design (each summary is an independent AI call), so those can stay as-is.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestrustPull requests that update rust code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions