Skip to content

perf(platform): list reads behind everyday screens grow with the organization, not the page #4708

Closed

Description

@yannickmonney

Summary

Several reads behind everyday screens grow with the organization rather than with the page. Found in the million-user analysis; each item verified on main at aa53363 (paths under services/platform/backend/).

Read What it does now Suggested fix
listThreads (domains/chat/threads.ts) "Deliberately unpaginated", and every call reads the thread ids of all generations of the organization (generatingThreadIds, SELECT thread_id FROM app.generations WHERE org_id = …) Keyset pages; join the user's threads to app.generations instead of an org-wide set
GET /chat/threads/:id/messages and the stream's settle (domains/chat/message-views.ts listMessageViews) The whole thread, every message's parts The existing tail reader (limit 200); the settle sends only the settled row
Members list (domains/members/service.ts:142) A correlated count(*) FROM "passkey" per member, and the task actor directory and the inbox load the whole list for every member A search or page endpoint; the passkey count only in the admin view
listProjects (domains/projects/service.ts:2772) No limit; used by Home and the all-projects task views Pages; visibility as a join instead of ANY(<ids>)
Org bell unreadCount and markAllRead (domains/notifications/service.ts:174-191, 215-235) count(*) over all of the organization's notifications with a NOT EXISTS per row; read-all inserts one row per notification A per-user read watermark
listMyNotifications ORDER BY seq over indexes (user_id, org_id, created_at_ms) and (user_id, org_id, read, seq) — the full list sorts every row of the user (user_id, org_id, seq DESC)
Home "assigned to me" The filter is (${assigneeId}::text IS NULL OR t.assignee_id = ${assigneeId}) (domains/tasks/service.ts:3798), and tasks_assignee (org_id, assignee_type, assignee_id) (db/migrations/0009_tasks.sql:77) could not serve assignee_id = ? ORDER BY updated_at_ms on PG16 anyway (no skip scan), so the organization's tasks are walked by updated_at_ms A separate branch for the assigned case; (org_id, assignee_id, updated_at_ms DESC) WHERE archived_at_ms IS NULL

Activity

  1. added
    priority: medium
    perf
    service: platform
    service: db
    on Oct 10, 2026
  2. added
    agent-ready
    on Oct 29, 2026
  3. tale-code-bot commented on Oct 30, 2026

    @tale-code-bot
    Collaborator

    Split as triaged on TALE-117 (decision of 2026-10-30). Items 1-6 are now issues of their own, and item 7 stays here:

    1. listThreads: keyset pages, with generations read per page. perf(platform): page the chat thread list and read generations per page #5153
    2. Chat messages: a tail read, and the client applies the settled row the stream already sends. perf(platform): read a chat thread's tail and apply the settled row #5154
    3. Members: a search or page endpoint, with the passkey count only in the admin view. perf(platform): members search or page endpoint, passkeys in admin only #5155
    4. listProjects: pages, with visibility as a join. perf(platform): page listProjects and read visibility as a join #5156
    5. Bell unread count and read-all: a per-user read watermark. perf(platform): a per-user read watermark for the notification bell #5157
    6. user_notifications (user_id, org_id, seq DESC) index. perf(platform): index user_notifications on (user_id, org_id, seq DESC) #5158
    7. Home "assigned to me": a statement of its own and the index (org_id, assignee_id, updated_at_ms DESC) WHERE archived_at_ms IS NULL. This item is worked on TALE-117, and its commit closes this issue.

    Three items differ from the table above at feature-train 9173785:

    • Item 2: the server's settle already sends one row, but the client re-reads the whole thread.
    • Item 4: project visibility is an array-overlap clause, and the ANY(<ids>) sits in the readers that take the project list.
    • Item 6: listMyNotifications is already paginated, but it has no (user_id, org_id, seq DESC) index.

    Each split issue says so.

  4. added a commit that references this issue on Oct 30, 2026
    b715f53
  5. added 3 commits that reference this issue on Oct 31, 2026
    a80a4e3
    b1c10c4
    7616a50
  6. tale-code-bot commented on Oct 31, 2026

    @tale-code-bot
    Collaborator

    Landed on the feature line: feature train #5184 merged into release/0.6 on 2026-10-31 by rebase, and this issue's change is commit 7616a50 (perf(platform): read assigned tasks through an index of their own, task TALE-117). It ships with Tale 0.6.0. GitHub closes an issue only for a commit on main, so the feature-train role closes it here.

  7. added 3 commits that reference this issue on Oct 31, 2026
    26ceae9
    d4ce661
    9b1f57e
  8. 4 remaining items

  9. added 13 commits that reference this issue on Nov 2, 2026
    a4e4fe9
    f13d632
    13d4de8
    da287b3
    97b6c40
    9ebd9d5
    d2872ab
    6c0844d
    252be08
    b63c200
    e4caea1
    907a438
    cd4487f
  10. added a commit that references this issue on Nov 15, 2026
    ff7d4b1
  11. added a commit that references this issue on Nov 23, 2026
    5b4e4f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyperfpriority: mediumservice: dbservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions