Skip to content

perf(server): scope refreshIdeas status queries - #109

Open
kvnloo wants to merge 3 commits into
CopilotKit:mainfrom
kvnloo:perf/refresh-ideas-scoped-status
Open

kvnloo wants to merge 3 commits into
CopilotKit:mainfrom
kvnloo:perf/refresh-ideas-scoped-status

Conversation

@kvnloo

@kvnloo kvnloo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Problem

refreshIdeas() performs three full-table reads and then filters by status in JavaScript:

  • all tasks → status === "succeeded"
  • all ideas → status === "new"
  • all goals → status === "active"

Terminal task history is retained, so the task scan grows without bound and runs on both maintenance refreshes and on-demand idea refreshes.

A downstream PGlite benchmark measured the largest hotspot (2,000 ~2KB tasks) at roughly:

  • full task list + filter: ~423.6ms / ~3.0MB
  • status-scoped query: ~17.7ms

Change

Add Store.listByStatus() with the same updated_at DESC,id ordering as list(), then use it for those three status predicates only.

All remaining filters and side effects stay unchanged:

  • messageId checks;
  • obsolete idea CAS;
  • empty-milestone goal check;
  • mail/sent dedupe;
  • final full ideas return.

Regression

Persistence coverage compares the scoped query directly with the previous list().filter(item.status === value) semantics and verifies owner/kind isolation.

No idea ranking, task lifecycle, or goal behavior changes.

This branch has not been deployed

No deployments
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.

1 participant