TLDR Tech / Dev
I got a $134 Cloudflare D1 bill. Here's how I cut it 95%
A SvelteKit site incurred a $134 Cloudflare D1 bill due to the database charging per row scanned, which, combined with a lack of indexes, resulted in 127.6 billion row reads from two full scans on every page load. The cost was cut by applying composite indexes, running ANALYZE for the query planner, and implementing KV cache-aside for layout-level data reads.
Read the full story