Repository navigation
perf(billing): index invoice line charge lookups - #5506
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
c4929bd to
c44a368
Compare
turip
left a comment
There was a problem hiding this comment.
Reviewed the schema, generated index definition, concurrent up/down migrations, and charge lookup queries. The regenerated migration follows the existing migration sequence. Migration validation, targeted billing adapter tests, scoped fast lint, and CI passed. No actionable findings remain.
Summary
Adds a
(namespace, charge_id)index onbilling_invoice_lines.Why
Subscription reference updates on invoice lines filter by
namespaceandcharge_id:No index includes
charge_id, so on a table of about 300k lines the plan is a parallel sequential scan ofbilling_invoice_linesthat takes about 60 ms per call. These updates run once per charge during sync, so in large namespaces they add up to a large share of database time.The index is full rather than partial. The reference updates do not filter on
deleted_at, and the subscription line lookups also match oncharge_id IS NULL.Testing
make migrate-checkpasses.go test ./openmeter/billing/adapter/...passes.Summary by CodeRabbit


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Adds a full, non-unique index on
billing_invoice_linesusingnamespaceandcharge_idto speed up charge lookups.Reviews (2) · Last reviewed commit: "perf(billing): index invoice line charge..." · Reviewed by Greptile