polycratia

A fast database is often the reason your API is slow. Cheap queries make it feel safe to hold a transaction open across work that has nothing to do with the database.

The mechanics are boring and consistent.

A handler opens a transaction, writes a row, then calls something external while still inside it: a KYC provider, a chain RPC node, a carrier rate quote, a payment gateway. The query took two milliseconds. The connection is now held for as long as the provider takes, and the provider's tail is not yours to control. Add a retry and you hold it twice.

The pool is finite. Once connections are occupied by waiting instead of working, requests start queueing for a slot, and endpoints that never touch the slow dependency get slow too. That is the part that confuses people: the symptom shows up far away from the cause, and every database metric still looks healthy, because the database genuinely is.

What I do instead: the transaction boundary contains database work only. Write the intent, commit, then call out (with an idempotency key, so a retry is cheap and safe) and let a worker reconcile the result. External latency becomes a state to resolve rather than time spent holding a resource.

The metric worth watching is not query time. It is how long a request waits to get a connection, and how long it keeps one.

Your slowest endpoint spends its time somewhere: the query, waiting for a pool slot, or a dependency you don't own...

react

$ new-project --brief

or email hey@polycratia.com