super-productivity/packages/super-sync-server/src
Johannes Millan 410dac6785 perf(sync): use indexed findFirst for op-download minSeq
Prisma operation.aggregate({ _min: { serverSeq } }) compiles to MIN()
over a `SELECT ... OFFSET 0` subquery. The OFFSET is a Postgres planner
optimization fence, so the (user_id, server_seq) index could not serve a
first-row seek and the query degraded to a per-user O(N) scan. Under a
client reconnect stampede this ran minutes inside the 60s interactive
download transaction, blowing the tx timeout (500s) and exhausting the
connection pool (cascading upload+download failures).

Replace it with findFirst ordered by serverSeq asc, which compiles to
ORDER BY server_seq ASC LIMIT 1 — a guaranteed index seek on the existing
unique (user_id, server_seq) index. Behaviour-preserving: same minSeq
value and same null-when-empty semantics.

Update both consuming specs (operation-download.service, gap-detection)
to the two-findFirst-call shape and add a regression test asserting the
indexed query is used and the aggregate path is not reintroduced.
2026-05-18 14:21:02 +02:00
..
sync perf(sync): use indexed findFirst for op-download minSeq 2026-05-18 14:21:02 +02:00
util perf(supersync): throttle daily old-ops cleanup so it cannot stall the server 2026-05-13 14:11:15 +02:00
api.ts perf(sync): SuperSync server speed + correctness hardening (#7621) 2026-05-15 17:24:16 +02:00
auth-cache.ts perf(sync): SuperSync server speed + correctness hardening (#7621) 2026-05-15 17:24:16 +02:00
auth.ts perf(sync): SuperSync server speed + correctness hardening (#7621) 2026-05-15 17:24:16 +02:00
config.ts perf(sync): SuperSync server speed + correctness hardening (#7621) 2026-05-15 17:24:16 +02:00
db.ts fix(sync): preserve own vector clock counter across full-state op resets 2026-04-01 15:41:13 +02:00
email-allowlist.ts feat(sync): add Helm chart and WebSocket push for SuperSync (#6971) 2026-03-30 21:34:30 +02:00
email.ts fix(sync-server): security hardening and GDPR log compliance 2026-03-18 20:48:51 +01:00
index.ts feat(syncServer): implement JWT authentication and user registration/login functionality 2025-12-12 20:46:04 +01:00
logger.ts feat(super-sync-server): Add basic monitoring tool 2025-12-12 20:48:40 +01:00
middleware.ts Pr 6741 (#6743) 2026-03-05 21:17:59 +01:00
pages.ts fix(sync): prevent magic link prefetch failures and improve auth resilience (#7175) 2026-04-10 14:46:57 +02:00
passkey.ts perf(sync): SuperSync server speed + correctness hardening (#7621) 2026-05-15 17:24:16 +02:00
server.ts perf(sync): SuperSync server speed + correctness hardening (#7621) 2026-05-15 17:24:16 +02:00
test-routes.ts perf(sync): SuperSync server speed + correctness hardening (#7621) 2026-05-15 17:24:16 +02:00