-
Notifications
You must be signed in to change notification settings - Fork 282
chore(clickhouse): add projection for events table #2375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f5815c3
chore(clickhouse): add projection for events table
jakubno a8496f2
chore: add comment
jakubno aa504ef
chore: add if not exists
jakubno 4073dfd
Update packages/clickhouse/migrations/20260413080000_add_sandbox_even…
jakubno e2cbbd7
chore(clickhouse): drop redundant bloom filter and fix projection com…
jakubno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
packages/clickhouse/migrations/20260413080000_add_sandbox_events_team_projection.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| -- +goose Up | ||
| -- TEMPORARY: Add a projection ordered by (sandbox_team_id, timestamp) | ||
| -- so that queries filtering by sandbox_team_id can skip the full table scan. | ||
| -- The base ORDER BY is (sandbox_id, timestamp) which doesn't help when only | ||
| -- sandbox_team_id is provided. | ||
| -- This projection should be removed once we migrate the table's ORDER BY to | ||
| -- (sandbox_team_id, timestamp, sandbox_id) via a CREATE + RENAME swap. | ||
| -- Also drops the now-redundant bloom_filter index on sandbox_team_id since | ||
| -- the projection's primary index covers that filtering. | ||
| ALTER TABLE sandbox_events_local | ||
| ADD PROJECTION IF NOT EXISTS proj_team_id ( | ||
| SELECT * ORDER BY sandbox_team_id, timestamp | ||
| ); | ||
|
|
||
| ALTER TABLE sandbox_events_local | ||
| MATERIALIZE PROJECTION proj_team_id; | ||
|
|
||
| ALTER TABLE sandbox_events_local | ||
| DROP INDEX IF EXISTS idx_team_id; | ||
|
|
||
| -- +goose Down | ||
| ALTER TABLE sandbox_events_local | ||
| ADD INDEX IF NOT EXISTS idx_team_id sandbox_team_id TYPE bloom_filter(0.01) GRANULARITY 1; | ||
|
|
||
| ALTER TABLE sandbox_events_local | ||
| MATERIALIZE INDEX idx_team_id; | ||
|
|
||
| ALTER TABLE sandbox_events_local | ||
| DROP PROJECTION IF EXISTS proj_team_id; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.