The database is hosted on Railway. I have enabled Smart Placement that should, depending on request time, automatically use an endpoint closer to the database to speed it up. When requesting a route that includes a database request, the response time on the US east coast is around 200ms and closer to 1000ms in Denmark. I am hoping that the Smart Placement will work better when I go live with the app (still in beta) and that it mainly needs more traffic to calculate optimal endpoint placement.
Have you given Hyperdrive[0] a try? In theory, it should improve performance in your use case where you have a central database (Railway) being connected to from the Edge (your Workers).
It moves the DB connection logic closer to your Workers, pools connections, and can also cache queries.
(Disclaimer: I work for Cloudflare, but on an unrelated team. Not personally used Hyperdrive, but heard good things!)
It actually looks very interesting, but my app is not particularly affected by database query time, but rather by the time spent on the various AI generations.
My app isn't database heavy; most pages renders without a single database call (user information stored in cookie) and the pages that do call the database contain maximum one call. Other data, like database schemas and subscription status, are requested in the background directly from the browser so it doesn't stall page rendering.