perf(home): denormalize recent workflows into WorkspaceRecentWorkflow#1003
Open
anish-work wants to merge 3 commits into
Open
perf(home): denormalize recent workflows into WorkspaceRecentWorkflow#1003anish-work wants to merge 3 commits into
anish-work wants to merge 3 commits into
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
b19f24a to
4a51d7c
Compare
The home page derived "recent workflows" by scanning a workspace's entire SavedRun history with DISTINCT ON, which is O(total runs) and measured ~2.4s on the heaviest workspace (1.78M runs collapsing to 1 distinct workflow). Add a denormalized WorkspaceRecentWorkflow table keyed by (workspace, uid, published_run) storing last_saved_run + last_used_at, upserted on run creation in create_new_run (covers UI + API paths). The home read now hits an index for ~4 rows instead of disk-sorting millions, and renders the card via a select_related PK join (no SavedRun index needed). Includes a one-time DISTINCT ON backfill migration for existing history. Co-authored-by: Cursor <cursoragent@cursor.com>
4a51d7c to
cd03051
Compare
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.
The home page derived "recent workflows" by scanning a workspace's entire SavedRun history with DISTINCT ON, which is O(total runs) and measured ~2.4s on the heaviest workspace (1.78M runs collapsing to 1 distinct workflow).
Add a denormalized WorkspaceRecentWorkflow table keyed by (workspace, uid, published_run) storing last_saved_run + last_used_at, upserted on run creation in create_new_run (covers UI + API paths). The home read now hits an index for ~4 rows instead of disk-sorting millions, and renders the card via a select_related PK join (no SavedRun index needed).
Includes a one-time DISTINCT ON backfill migration for existing history.
Q/A checklist
How to check import time?
You can visualize this using tuna:
To measure import time for a specific library:
To reduce import times, import libraries that take a long time inside the functions that use them instead of at the top of the file:
Legal Boilerplate
Look, I get it. The entity doing business as “Gooey.AI” and/or “Dara.network” was incorporated in the State of Delaware in 2020 as Dara Network Inc. and is gonna need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Dara Network Inc can use, modify, copy, and redistribute my contributions, under its choice of terms.