Skip to content

Add event meter join table / materialization#8790

Merged
Yopi merged 1 commit intomainfrom
yopi/add-event-meter-materialization
Jan 12, 2026
Merged

Add event meter join table / materialization#8790
Yopi merged 1 commit intomainfrom
yopi/add-event-meter-materialization

Conversation

@Yopi
Copy link
Contributor

@Yopi Yopi commented Jan 7, 2026

Introduce a meter_events join table that joins meters with events that matches their filter. This will save us the need to find events via the complex matching logic, and instead we can do a simple select for the events that match. Initially only for create_billing_entries, but I believe we will be able to use this in the other tasks where we are querying events that match a meter definition.

I'll split this into three PRs if we think this makes sense.

Open questions:

  • Do we need to backfill the link between events and meters if a new meter is created? Or is it fine to only be forward looking
  • Do we need to backfill or remove the link if a meter is updated?

@vercel
Copy link

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Review Updated (UTC)
polar Ignored Ignored Preview Jan 8, 2026 2:40pm
polar-sandbox Ignored Ignored Preview Jan 8, 2026 2:40pm

@Yopi Yopi force-pushed the yopi/add-event-meter-materialization branch from 71e4663 to 69685b4 Compare January 7, 2026 11:45
@Yopi Yopi changed the title Add event meter join table / materilalization Add event meter join table / materialization Jan 7, 2026
@Yopi Yopi force-pushed the yopi/add-event-meter-materialization branch from 986d319 to fea3c56 Compare January 7, 2026 12:38
@Yopi Yopi force-pushed the yopi/add-event-meter-materialization branch 4 times, most recently from 3ed025f to f617a62 Compare January 8, 2026 14:30
… table

We introduce the ability to ecompare billing entries fetched via meter_events
with the previous functionality.

This allows us to roll this out as a comparison initially.

The ambition is that this will eliminate the expensive JSONB filter evaluation that was causing
703 second query times on large datasets.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Yopi Yopi force-pushed the yopi/add-event-meter-materialization branch from f617a62 to 5894053 Compare January 8, 2026 14:39
@Yopi Yopi merged commit cab707a into main Jan 12, 2026
15 checks passed
@Yopi Yopi deleted the yopi/add-event-meter-materialization branch January 12, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant