Repository navigation
perf(people): Bound the People list to 90 days and index Turn metrics - #3647
Merged
Merged
Conversation
The list reads each person's Turn range through actor index probes and counts range Conversations from the last 90 days only. It drops the all-time totals the dashboard never showed. Migration 0121 adds a partial covering index on duration, token and cost metric rows. Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
17 screenshot changes — 17 changed · 0 added · 0 removed Review screenshots in Frameshift Show 11 more changed screenshots |
BYK
approved these changes
Nov 18, 2026
24 tasks done
This branch was successfully deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Gets
GET /api/peopleunder 1 s: 2.29 s goes to 0.72 s on the local bench. Follows #3629.Changes
Turn range from index lookups. Who is listed,
firstSeenAt,lastSeenAtand the Slack fields stay all-time. They come from lookups on the existing(actor_identity_id, occurred_at)index: one lookup for each verified identity's first Turn and one for its last. A person whose last Turn is older than every range still appears, with zero windows.Range counts from the last 90 days only. Per-range Conversation counts read only
duration_msrows since the start of the 90-day range. They are grouped before any join. The list no longer joins root Conversations for status. It is still 5 statements in 1 round.Dropped list fields. The list item no longer has
active,activeDays,conversations,durationMs,failedortokens. These were all-time totals that nothing read: the dashboard shows onlywindows[1|7|30|90],firstSeenAt,lastSeenAtand the actor. The People profile keeps its all-timetotals. Ties onlastSeenAtin the server sort are now broken by 90-day Conversations.Index. Migration 0121 adds
junior_conversation_metrics_turn_metric_occurred_at_idx:(metric, occurred_at, actor_identity_id, conversation_id, value) WHERE metric IN ('duration_ms', 'total_tokens', 'cost_micro_usd').CONCURRENTLY IF NOT EXISTSin its own migration.Index cost (local bench)
Rollout
The index builds without blocking writes. Until it exists, the new query runs at about 0.85 s. Any client that still expects the six dropped fields fails the strict list schema. The only such clients were the dashboard and its mocks, and both change here.
Bench
Local synthetic data: 400 people, 100k Conversations, 2.25M metric rows over 240 days. Per statement means totals / day activity / hour / six-hour / spend.
mainmainapart from the six dropped fields.Migration number
0121_people_list_metric_indexcollides with #3615 (0121) and #3392 (0122/0123). If either lands first, this PR renumbers its own migration to the next free number. Theirs stay as they are.via @BYK.
--
View Session [Sentry]