D1 adding more latency than expected
Im using sveltekit and i created 2 test routes. they essentially do the same but one does a select 1; in d1.
When warm the the difference in response time is 50ms which just seems super high considering the query takes less than 1ms.
I chose the cloest location to me when i created d1
I use workers with assets. here the code for both api endpoints i used to just test it out
Is this really the expected behaviour?
No Db:
With D1:
i tried without drizzle as well but i dont see a difference
4 Replies
Is there a good way to like trace the entire request and see all latencies or something?
https://developers.cloudflare.com/workers/runtime-apis/performance/ can perf.now before/after the sql and see how much latency it's adding directly
Cloudflare Docs
Performance and timers · Cloudflare Workers docs
Measure timing, performance, and timing of subrequests and other operations.
50ms doesn't sound too crazy though, your db is same region but not same data center as the one you're hitting, more then likely
ye its very consistently 40ms. and yea i wasnt considering the "same data center" fair enough