-
-
Notifications
You must be signed in to change notification settings - Fork 280
perf: batch tag resolution to reduce action→query round-trips #112
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1125,6 +1125,14 @@ export const getVersionById = query({ | |
| handler: async (ctx, args) => ctx.db.get(args.versionId), | ||
| }) | ||
|
|
||
| export const getVersionsByIds = query({ | ||
| args: { versionIds: v.array(v.id('skillVersions')) }, | ||
| handler: async (ctx, args) => { | ||
| const versions = await Promise.all(args.versionIds.map((id) => ctx.db.get(id))) | ||
| return versions.filter((v): v is NonNullable<typeof v> => v !== null) | ||
| }, | ||
| }) | ||
|
Comment on lines
+1128
to
+1134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Also appears in Prompt To Fix With AIThis is a comment left during a code review.
Path: convex/skills.ts
Line: 1128:1134
Comment:
[P2] `getVersionsByIds` uses `Promise.all(versionIds.map(ctx.db.get))`, which will issue one `db.get` per ID anyway. This reduces action→query round-trips (good), but inside the query it can still be a large fan-out (up to all tags across the page). If `versionIds` can be large, consider adding a conservative cap/deduplication at the query boundary, or using an index-based fetch strategy if available.
Also appears in `convex/souls.ts:148-154`.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| export const getVersionByIdInternal = internalQuery({ | ||
| args: { versionId: v.id('skillVersions') }, | ||
| handler: async (ctx, args) => ctx.db.get(args.versionId), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.