Customer meter usage aggregation
The PlanetScale query fingerprint sums a numeric field fromevents.user_metadata. It combines two sums with UNION ALL:
one filters by customer_id, the other by external_customer_id. Both filter by
organization, event name, and source. The query has no time bound.
The indices below cover the external_customer_id branch. The partial predicate
limits each index to one organization and event name. Including user_metadata
lets PostgreSQL check the JSON value’s type and compute the sum from the index when
an index-only scan is possible.
ix_events_meter_ prefix for these manually managed indices. Alembic
autogeneration ignores database-only indices with this prefix on events.

