Skip to content

Conversation

vincent-pochet
Copy link
Collaborator

Context

Today, we are not able to use the cache system for organization using Clickhouse event store, because we are not able to easily identify if an event matches filters.

As a result all action requiring to compute the usage (current usage, daily_usage...) have to recompute the full usage from 0 every time for all billable metric having received at least 1 event during the period. This is highly inefficient especially for charges with filters, has one filter will lead to one DB query.

With Postgres event store, we are able to use a system with charge filter granularity, we would like to use the same logic for the Clickhouse one.

Description

This PR is a first step to add caching at Clickouse level, it adds a new flat_filters database view. This view will be used on event_processor side to check filters matching on all events received for organization using the Clickhouse store.

@vincent-pochet vincent-pochet force-pushed the chore-filter-view branch 4 times, most recently from b409ac5 to b70b5e8 Compare June 3, 2025 08:40
@vincent-pochet vincent-pochet force-pushed the chore-filter-view branch 3 times, most recently from 4dfff0a to 7c3fb6a Compare June 9, 2025 13:43
@vincent-pochet vincent-pochet merged commit 9766fc2 into main Jun 9, 2025
14 checks passed
@vincent-pochet vincent-pochet deleted the chore-filter-view branch June 9, 2025 15:13
rsempe pushed a commit that referenced this pull request Jun 11, 2025
## Context

Today, we are not able to use the cache system for organization using
Clickhouse event store, because we are not able to easily identify if an
event matches filters.

As a result all action requiring to compute the usage (current usage,
daily_usage...) have to recompute the full usage from 0 every time for
all billable metric having received at least 1 event during the period.
This is highly inefficient especially for charges with filters, has one
filter will lead to one DB query.

With Postgres event store, we are able to use a system with charge
filter granularity, we would like to use the same logic for the
Clickhouse one.

## Description

This PR is a first step to add caching at Clickouse level, it adds a new
`flat_filters` database view. This view will be used on event_processor
side to check filters matching on all events received for organization
using the Clickhouse store.
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.

3 participants