A booking page crash turned up two problems: huge unoptimized room photos that exhausted an iPhone's memory and a much deeper performance issue in availability checks. A trivial health SELECT from the API host took ~240-285 ms while the TCP round-trip to the Dublin database was ~47 ms, leading early analysis to blame network latency and to suggest moving infrastructure. That reasoning drove six months of surface-level optimizations (fewer requests, caching, gzip, Cloudflare) that improved some pages but never reduced the per-query cost. Timings showed availability checks taking ~8.06 seconds at median and other endpoints three- to four-times slower than they should be.
The real cause was Prisma 5.22’s pgbouncer=true interaction with Supabase’s Supavisor transaction-mode pooler: Prisma wraps every query with BEGIN, DEALLOCATE ALL, the SELECT and COMMIT, so each logical query incurred four 47 ms crossings. pg_stat_statements confirmed ~4 million BEGIN/DEALLOCATE/COMMIT calls. Switching DATABASE_URL from the Supavisor transaction port (6543) to the Postgres/session port (5432) with connection_limit=5 removed the extra round-trips and cut availability from 8.06 s to 1.88 s and health from 285 ms to 85 ms. Practical takeaways: if a cheap query’s latency >> RTT, investigate driver/pooler behavior; keep server config in the repo; re-measure rather than repeatedly patching symptoms. An automated agent helped find the root cause.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.