Skip to content

perf: fix N+1 queries in session list API#410

Merged
yaojin3616 merged 1 commit intomainfrom
bugfix
Apr 15, 2026
Merged

perf: fix N+1 queries in session list API#410
yaojin3616 merged 1 commit intomainfrom
bugfix

Conversation

@yaojin3616
Copy link
Copy Markdown
Collaborator

scope=all was issuing 1+2N DB queries (1 count + 2 agent-name lookups per session). scope=mine was issuing 2N queries (1 user-count + 1 total per session). Both are now replaced with 3-4 bulk queries total, regardless of session count.

Affected endpoint: GET /api/agents/{id}/sessions?scope=all|mine

Summary

Checklist

  • Tested locally
  • No unrelated changes included

scope=all was issuing 1+2N DB queries (1 count + 2 agent-name lookups
per session). scope=mine was issuing 2N queries (1 user-count + 1 total
per session). Both are now replaced with 3-4 bulk queries total,
regardless of session count.

Affected endpoint: GET /api/agents/{id}/sessions?scope=all|mine
@yaojin3616 yaojin3616 merged commit 15de6e8 into main Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants