Skip to content

Batch the admin joined connection read and key the email filter - #1580

Merged
RhysSullivan merged 1 commit into
mainfrom
fix/admin-users-connection-n1
Aug 13, 2026
Merged

Batch the admin joined connection read and key the email filter#1580
RhysSullivan merged 1 commit into
mainfrom
fix/admin-users-connection-n1

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

/admin/users/with-connections issued about 100 connection.findMany queries
per request. Two separate causes, one per caller.

The paged read fanned out

admin.listSubjectsWithConnections read a page of subjects and then queried
connections once per subject, sequentially. A default page is 100 subjects, so
one request made 100 round trips over a per-request socket. It now reads the
page and batches every subject's connections into a single query, so the cost
is two queries regardless of page size.

The batched in predicate carries the same owner: "user" clause and the same
tenant scoping the per-subject read had, so org-owned rows (whose subject is
the empty-string sentinel) and other tenants' rows stay out. A subject with no
connections still reports an empty array rather than dropping out of the page,
and ordering is unchanged: the query orders by (integration, name) across the
page and grouping walks those rows in order.

The email filter ran after the read

?email= resolved the address to a principal id and then read a full page of
subjects with their connections, only to keep the single row that matched. It
now reads that id directly through the keyed seam the single-user endpoint
already uses. An address the directory cannot resolve now costs no storage read
at all.

The same reordering applies to /admin/users, so the two endpoints keep one
set of semantics rather than disagreeing on an edge case.

Contract note

?email= combined with ?limit=/?offset= changes meaning: it is now
filter-then-page (the window applies to the selected row, so one row at
offset: 0 and empty beyond) rather than page-then-filter. Exact preservation
of the old behaviour is not possible without the scan this removes, since it
depended on where the row happened to fall in the tenant ordering. No caller
combines the two parameters in practice. The contract comment is updated to
state the order explicitly.

Tests

New tests cover the reads over a recording ExecutorAdmin (which storage call
the filter chooses) and the batched query over a real SQLite-backed platform
view (one connection query for a three-subject page, empty arrays preserved,
tenant and org-owned rows still excluded). Each was confirmed to fail against
the previous implementation before being kept.

format, lint, typecheck, the SDK, api, self-host and cloud-admin suites
all pass.

listSubjectsWithConnections issued one connection query per subject in the
page, so a default page cost 100 sequential round trips in one request. It
now batches the whole page into a single query.

The ?email= filter was also applied after the read, pulling a full page of
subjects and their connections to return one row. It now resolves the address
to a principal id and reads that id directly.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing a70b792 Commit Preview URL

Branch Preview URL
Aug 13 2026, 08:58 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud a70b792 Aug 13 2026, 08:58 AM

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Aug 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1580

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1580

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1580

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1580

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1580

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1580

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1580

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1580

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1580

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1580

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1580

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1580

executor

npm i https://pkg.pr.new/executor@1580

commit: a70b792

@RhysSullivan
RhysSullivan marked this pull request as ready for review August 13, 2026 09:33
@RhysSullivan
RhysSullivan merged commit d572658 into main Aug 13, 2026
21 checks passed
@RhysSullivan
RhysSullivan deleted the fix/admin-users-connection-n1 branch August 13, 2026 09:34
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