Skip to content

perf(storage): skip the slug recompute query on non-slug connection updates - #6247

Open
pedrofrxncx wants to merge 1 commit into
mainfrom
perf/skip-slug-lookup-non-slug-updates-w2
Open

perf(storage): skip the slug recompute query on non-slug connection updates#6247
pedrofrxncx wants to merge 1 commit into
mainfrom
perf/skip-slug-lookup-non-slug-updates-w2

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Follows #6240, which stopped ConnectionStorage.update() decrypting secrets for the slug-merge lookup but still ran that lookup (and the slug recompute) unconditionally on every call.

Most calls to update() never touch app_name/connection_url/title — the fields the slug is derived from. The hottest one is on the proxy request path (apps/api/src/api/routes/proxy.ts), which calls update(connectionId, { status: "active" | "error" }) on connection recovery/failure and was paying an extra unnecessary SELECT round-trip for a slug that can't have changed.

This adds a presence check ("app_name" in data || ...) before running the lookup+recompute, so a pure status/heartbeat write skips it entirely. Behavior is unchanged: any update that does touch a slug-source field still goes through the exact same lookup/merge/recompute path as before.

How to confirm: read apps/api/src/storage/connection.ts update() — the recompute block is now gated on touchesSlugField, and serializeConnection still only writes fields present in data, so a status-only update still doesn't touch slug.

Local checks: bun run fmt, bunx tsc --noEmit (apps/api, clean), bunx oxlint apps/api/src/storage/connection.ts (0 warnings/errors). No unit test exists for this path (only Postgres-backed integration tests in connection.integration.test.ts, not runnable here) — full CI validates those.


Summary by cubic

Skip slug lookup and recompute in ConnectionStorage.update() when the update does not touch slug-source fields, removing an extra SELECT on hot status/heartbeat writes. Previously update() always fetched app_name, connection_url, and title to recompute the slug; now it does so only if any of those keys are present in data.

Behavior for slug-affecting updates is unchanged: the same lookup/merge/recompute path runs, and serializeConnection still only persists provided fields, so status-only updates leave slug untouched. This targets the proxy path in apps/api/src/api/routes/proxy.ts that calls update(connectionId, { status: ... }).

Written for commit 2292c28. Summary will update on new commits.

Review in cubic

@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) August 19, 2026 15:49
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