Skip to content

perf: route API Postgres through Hyperdrive to cut per-request latency - #35

Merged
RogutKuba merged 1 commit into
mainfrom
RogutKuba/query-observability
Jul 28, 2026
Merged

perf: route API Postgres through Hyperdrive to cut per-request latency#35
RogutKuba merged 1 commit into
mainfrom
RogutKuba/query-observability

Conversation

@RogutKuba

Copy link
Copy Markdown
Member

Loading pages were slow because every DB-backed request opened a brand-new Postgres connection, paying the full TCP, TLS, and auth handshake on each invocation (~1-2s floor, even for trivial queries and the auth routes). This routes useDb() through a Cloudflare Hyperdrive binding so connections are pooled at the edge, with a fallback to INFISCAL_DATABASE_URL when the binding is absent (safe to deploy before/without the resource). It also adds a non-prod Drizzle query logger (params redacted) so we can see how many queries each endpoint fires, plus the HYPERDRIVE binding in wrangler.jsonc and the optional type in worker-configuration.d.ts. After deploy, the existing Cloudflare request logs should show DB-backed routes drop from ~2s to a few hundred ms.

🤖 Generated with Claude Code

Connect the DB via the Hyperdrive binding (edge-pooled connections) so
requests skip the per-invocation TCP, TLS, and auth handshake that added
~1-2s to every DB-backed route. Falls back to INFISCAL_DATABASE_URL when
the binding is absent. Also add a non-prod Drizzle query logger for
visibility into how many queries each endpoint fires.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 28, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
coderscreen-marketing Ready Ready Preview, Comment Jul 28, 2026 3:28am

Request Review

@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
coderscreen-api 2a08a62 Jul 28 2026, 03:28 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
coderscreen-web 2a08a62 Jul 28 2026, 03:29 AM

@RogutKuba
RogutKuba merged commit 5a549bf into main Jul 28, 2026
5 checks passed
@RogutKuba
RogutKuba deleted the RogutKuba/query-observability branch July 28, 2026 03:35
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