Skip to content

Database picker: search on the server instead of listing every database - #68

Merged
eddietejeda merged 1 commit into
mainfrom
database-picker-search
Oct 25, 2026
Merged

eddietejeda merged 1 commit into
mainfrom
database-picker-search

Conversation

@eddietejeda

@eddietejeda eddietejeda commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #66. Loading every database (all pages) was slow in large workspaces and grows with workspace size.

  • Backend: the databases resource takes ?search= (passed to GET /v1/databases?search=, one page of 50) and ?id= (resolves one database via GET /v1/databases/{id}). Replaces ListDatabases with SearchDatabases.
  • Frontend: the query editor's database Combobox uses async options, searching as you type. A saved database id is resolved to its name for display.
  • Mock API filters by search.

Live timing (large workspace, through Grafana)

Request Before After
Open picker ~5x slower (all databases) 192ms (newest 50)
Search demo n/a (client-side) 77ms
Resolve saved id n/a 82ms

Testing

  • go test ./pkg/...: search, no-match returns [], lookup by id.
  • New Playwright e2e: type in the picker, matching database appears, non-match hides it, selecting shows its name. All 7 e2e tests pass locally.
  • npm run typecheck, npm run lint.

Listing every database took ~935ms on a 1,594-database workspace and grows with
workspace size. The picker now loads options per keystroke from
GET /v1/databases?search= (one page of 50, ~70ms), and resolves a saved
database id to its name via ?id=.
@eddietejeda
eddietejeda requested a review from a team as a code owner October 24, 2026 22:55
@eddietejeda
eddietejeda requested review from rohan-hotdata and removed request for a team October 24, 2026 22:55
useEffect(() => {
const id = query.databaseId;
if (!id) {
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Skip the id lookup when selected?.value === id (not blocking).

Selecting an option calls setSelected(v) and then onChange. The onChange changes query.databaseId, so this effect fires GET databases?id= for a database whose name is already known. Each pick costs one redundant backend and Hotdata API round trip. A custom value from createCustomValue also triggers a lookup that always fails with 502.

@eddietejeda
eddietejeda merged commit fa1cce8 into main Oct 25, 2026
11 checks passed
@eddietejeda
eddietejeda deleted the database-picker-search branch October 25, 2026 00:49
@eddietejeda eddietejeda mentioned this pull request Oct 25, 2026
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