billflare.

Bradley Leatherwood: on Durable Objects every SQLite row read is billed; a quiet-moment ANALYZE produced 20,006 reads to return 5 rows, and a plain ANALYZE on a 37,000-row object was billed about 2 million rows

On 2026-11-02, Bradley Leatherwood published an inKibra note, also linked from the X account @mayliveforever, about SQLite inside Cloudflare Durable Objects. The platform bills every row SQLite reads, not just the rows it returns: a lookup that returns 5 rows but checks 20,000 is billed for 20,000. The author says that for several days the Cloudflare bill ran around $66 a day, almost all of it rows read, because queries were reading every row when no index was used; the peak day came to $366, mostly rows written. These amounts are the author’s reported invoices, not a Billflare case total in this guide. The same event is already recorded as a Billflare case; this entry is the technical post-mortem, including later figures the case snapshot may not yet carry.

Products
Durable ObjectsSQLite
Source
Author experienceinKibra blog
Author
Bradley Leatherwood (@mayliveforever)

Key points

  • In a reproduction on Cloudflare’s workerd/Miniflare, a snapshot taken with ANALYZE at a quiet moment (when every request had been handled) taught the planner that the status index did not narrow anything down. After five new requests arrived, SQLite skipped the status index and read 20,006 rows to return 5. A second query read 8,000 old copies to return 3 current rows. The author notes that SQLite statistics are a snapshot from ANALYZE or PRAGMA optimize, and that a snapshot taken at the wrong moment can be exactly the wrong lesson for the rare status the queries actually ask for.
  • On a Durable Object in the author’s account, four objects were seeded with about 37,000 rows each. A plain ANALYZE was billed for everything it read: about 2 million rows for a 37,000-row object, roughly 53 reads per stored row, and it was also what produced the bad plan. PRAGMA optimize, which SQLite and the Cloudflare D1 guide recommend, never produced the bad plan in their reproduction and was billed for only a handful of rows on its first run (observed on 2026-10-28, not published pricing). Building an index was billed at about one read per stored row plus a write for every row it covers. INDEXED BY names the index in the query, was billed nothing extra, and makes a missing index fail with an error instead of silently scanning. The author chose INDEXED BY for queries their data layer can map to a declared index, keeps a 100,000 rows-read budget per request in production, and uses current-copy indexes so old versions stay out of everyday reads. The note says that if you keep statistics on Durable Objects, use PRAGMA optimize, never a plain ANALYZE. The reproduction is controlled and is not a replay of the bill.

Original sources

  1. Published

    Bradley Leatherwood: on Durable Objects every SQLite row read is billed; a quiet-moment ANALYZE produced 20,006 reads to return 5 rows, and a plain ANALYZE on a 37,000-row object was billed about 2 million rows

    Open original source

    On 2026-11-02, Bradley Leatherwood published an inKibra note, also linked from the X account @mayliveforever, about SQLite inside Cloudflare Durable Objects. The platform bills every row SQLite reads, not just the rows it returns: a lookup that returns 5 rows but checks 20,000 is billed for 20,000. The author says that for several days the Cloudflare bill ran around $66 a day, almost all of it rows read, because queries were reading every row when no index was used; the peak day came to $366, mostly rows written. These amounts are the author’s reported invoices, not a Billflare case total in this guide. The same event is already recorded as a Billflare case; this entry is the technical post-mortem, including later figures the case snapshot may not yet carry.

Community resourceWorkers +4

Cloudflare Billing Helper: a browser extension that shows free-allowance progress on the billing page

Meathill (@meathill1) built a Chrome extension that adds a panel to Cloudflare’s Billable Usage page: remaining free allowance for each billing line, projected exhaustion dates, estimated cost for the period, and a breakdown by Worker, KV namespace, D1 database, R2 bucket and Durable Object.

D1

Aaron Edwards: an accidental $1,200 D1 bill.

Aaron Edwards (@uglyrobot), replying to Jay’s D1 thread, says he had an accidental $1,200 D1 bill last month and advises caching reads heavily.

Community resourceWorkers +8

Cloudflare AI Usage Dashboard: per-app usage and a billing estimate

An open-source Worker that collects Cloudflare platform, Workers AI, AI Gateway, Anthropic and OpenAI usage every 5 minutes, attributes it to apps and shows a usage-times-list-price billing estimate behind Cloudflare Access.