Skip to content

perf(api): count session posts without loading bodies - #245

Merged
benvinegar merged 1 commit into
mainfrom
perf/narrow-session-post-counts
Aug 11, 2026
Merged

perf(api): count session posts without loading bodies#245
benvinegar merged 1 commit into
mainfrom
perf/narrow-session-post-counts

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • count posts for GET /api/sessions through an optional narrow store capability
  • use one SQLite GROUP BY query without selecting or decoding surface/history bodies
  • avoid cloning and sorting posts in the loaded JSON store
  • preserve compatibility with custom stores through the existing listPosts() fallback
  • cover optimized dispatch, fallback behavior, both built-in stores, mutations, and exact SQL shape

Performance

A local synthetic 10,000-post SQLite probe measured approximately 32 ms for the previous full-post load versus 3.3 ms for the aggregate path (~9.7×). This is directional local evidence, not a CI benchmark.

Validation

  • npm test
  • npm run coverage
  • npm run test:worker
  • npm run typecheck
  • npm run lint
  • npm run format:check
  • focused API and store suites

npm run security:audit currently reports dependency advisories already present on main.

This PR description was generated by Pi using gpt-5.6-sol

@benvinegar
benvinegar force-pushed the perf/narrow-session-post-counts branch from f8bf988 to 521d7c9 Compare August 10, 2026 16:29
@benvinegar
benvinegar merged commit 287bb3d into main Aug 11, 2026
9 checks passed
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