Skip to content

perf(platform): index user_notifications on (user_id, org_id, seq DESC) #5158

Closed

Description

@tale-code-bot

Split from #4708 (item 6 of 7), as triaged on TALE-117.

What the read does now

At feature-train 9173785 (paths under services/platform/backend/):

  • listMyNotifications (domains/collab/service.ts:533-563) pages app.user_notifications:
    • WHERE user_id = … AND org_id = …, ORDER BY seq DESC;
    • a LIMIT of 30 by default, at most 100, with a seq cursor.
  • The table's indexes are user_notifications_user_created (user_id, org_id, created_at_ms DESC) and user_notifications_user_unread (user_id, org_id, read, seq DESC) (db/migrations/0028_collab.sql:29-32), plus two partial ones.
  • No index has (user_id, org_id, seq DESC). So the "All" view, which has no read filter, must either merge the two read ranges or read every row of the user and sort them before the LIMIT.
  • Callers: GET /api/app/collab/notifications (domains/collab/routes.ts:44-66, useMyNotificationsList) and GET /notifications/sync (rest/v1-notifications.ts:98,159).

What to do

  • A migration with CREATE INDEX IF NOT EXISTS … ON app.user_notifications (user_id, org_id, seq DESC).
  • An EXPLAIN probe proving that the "All" page walks that index.

Done means:

  • the "All" page reads at most one page of index entries;
  • the probe proves the plan.

Activity

  1. added
    agent-ready
    on Oct 30, 2026
  2. added a commit that references this issue on Oct 31, 2026
    5bc08c1
  3. added 2 commits that reference this issue on Oct 31, 2026
    1cdb7b0
    dd90ba2
  4. tale-code-bot commented on Oct 31, 2026

    @tale-code-bot
    CollaboratorAuthor

    Landed on release/0.6 with feature train #5197 (#5197, rebased in at 2026-10-31 11:15:15Z) as 1cdb7b0 (TALE-254, "perf(platform): index the bell's All page by seq"). release/0.6 was then rebased onto main df6105c at 11:25Z, where this commit is now dd90ba2. It ships with 0.6.0. GitHub closes an issue only for a commit on main, so the feature-train role (TALE-239) closes it.

  5. added
    perf
    on Oct 31, 2026
  6. added 19 commits that reference this issue on Oct 31, 2026
    5f945a3
    2f50914
    349df2f
    291a9d1
    0601c65
    d0b8cc3
    7cf9c2c
    29f6e45
    2686a0b
    a1f7289
    a5c1b3a
    d29a069
    8577518
    79d9e4d
    f522397
    2f821b7
    4407e71
    9857953
    c3b665f
  7. added a commit that references this issue on Nov 15, 2026
    c921fc1
  8. added a commit that references this issue on Nov 23, 2026
    cf59f48
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-readyperf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions