-
Notifications
You must be signed in to change notification settings - Fork 729
perf: route member-filtered activity relations to member-sorted mirror #4499
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
+117
−1
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6a9b77e
perf: route member-filtered activity relations to member-sorted mirror
epipav f2b2c47
Merge branch 'main' into perf/member-sorted-relations-mirror
epipav 84ecd1f
chore: fix copy pipe formatting and local tinybird migration
epipav 24586c5
style: fix routing template formatting in relations pipe
epipav 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
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
44 changes: 44 additions & 0 deletions
44
services/libs/tinybird/datasources/activityRelations_by_member_ds.datasource
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,44 @@ | ||
| DESCRIPTION > | ||
| Member-sorted mirror of the enriched activityRelations buckets, serving the | ||
| member-feed fast path in `activities_relations_filtered` (single-member list/count | ||
| queries, the dominant traffic shape). Sorting by (memberId, timestamp) turns those | ||
| queries into a keyed range read instead of a segment+time scan of the bucket union | ||
| (measured: 213M -> 0.2M rows read for the heaviest member). Unpartitioned on | ||
| purpose: no query shape prunes by year and partitions only inflate part count. | ||
| Rebuilt nightly by `activityRelations_by_member_copy` (replace mode) from | ||
| `activityRelations_enriched_deduplicated_bucket_union`, so freshness matches the | ||
| nightly bucket snapshots. | ||
|
|
||
| SCHEMA > | ||
| `activityId` String, | ||
| `conversationId` String, | ||
| `createdAt` DateTime64(3), | ||
| `updatedAt` DateTime64(3), | ||
| `memberId` String, | ||
| `objectMemberId` String, | ||
| `objectMemberUsername` String, | ||
| `organizationId` String, | ||
| `parentId` String, | ||
| `platform` LowCardinality(String), | ||
| `segmentId` String, | ||
| `username` String, | ||
| `sourceId` String, | ||
| `type` LowCardinality(String), | ||
| `timestamp` DateTime64(3), | ||
| `sourceParentId` String, | ||
| `channel` String, | ||
| `sentimentScore` Int8, | ||
| `gitInsertions` UInt32, | ||
| `gitDeletions` UInt32, | ||
| `score` Int8, | ||
| `isContribution` UInt8, | ||
| `pullRequestReviewState` LowCardinality(String), | ||
| `gitChangedLines` UInt64, | ||
| `gitChangedLinesBucket` String, | ||
| `organizationCountryCode` LowCardinality(String), | ||
| `organizationName` String, | ||
| `snapshotId` DateTime | ||
|
|
||
| ENGINE MergeTree | ||
| ENGINE_PARTITION_KEY tuple() | ||
| ENGINE_SORTING_KEY memberId, timestamp |
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
18 changes: 18 additions & 0 deletions
18
services/libs/tinybird/pipes/activityRelations_by_member_copy.pipe
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,18 @@ | ||
| DESCRIPTION > | ||
| Nightly rebuild of `activityRelations_by_member_ds` (member-sorted mirror serving | ||
| the member-feed fast path in `activities_relations_filtered`). Reads the full | ||
| enriched bucket union (~920M rows, ~22 min) and replaces the mirror atomically; | ||
| a failed run keeps yesterday's data and self-heals on the next run. | ||
| Scheduled 03:35 UTC: the producing bucket rebuilds | ||
| (activityRelations_snapshot_merger_copy_0/1/2, 01:30-01:38) have a worst observed | ||
| finish of 02:00, and 03:35 sits in the quietest overnight copy-job window, | ||
| clearing before the 04:00 collection-bucket copy band. | ||
|
|
||
| NODE member_sorted_snapshot | ||
| SQL > | ||
| SELECT * FROM activityRelations_enriched_deduplicated_bucket_union | ||
|
|
||
| TYPE COPY | ||
| TARGET_DATASOURCE activityRelations_by_member_ds | ||
| COPY_MODE replace | ||
| COPY_SCHEDULE 35 3 * * * | ||
|
epipav marked this conversation as resolved.
|
||
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.