billflare.

Self-hosted analytics on D1: rows scanned, not rows returned, decide the bill

Lynn (@hizachlynn) estimates how a D1-backed analytics tool without pre-aggregated rollup tables scales: dashboard queries scan raw events, so at 1 million pageviews a month one load scans about 428 million rows; all figures are the author’s estimates.

Products
D1
Source
Author experience𝕏 post
Author
Lynn (@hizachlynn)

Key points

  • He says D1 bills by rows scanned, not returned, so without pre-aggregated rollup tables every dashboard view runs count(distinct) and group by over the raw event history.
  • His 30-day estimates: 10k pageviews/month ≈ 180k rows scanned per load; 100k ≈ 5 million, so one refresh uses the whole daily free read limit; 1 million ≈ 428 million, with heavy joins taking over 70 s in his local tests, past D1’s 30 s query timeout.
  • On the paid plan he puts 428 million rows at about $0.43 per load, so a small team opening stats 20 times a day would spend about $230 a month on reads (estimate). He says one pageview triggers about 9 row writes from session heartbeats and indexes.
  • He adds that D1 runs queries sequentially per database, so a slow dashboard query can block event ingestion. The D1 pricing page read on 2026-10-28 confirms that rows read count rows scanned and that Free includes 5 million rows read per day.

Original sources

  1. Published

    Original post

    Read on 𝕏

    Lynn (@hizachlynn) estimates how a D1-backed analytics tool without pre-aggregated rollup tables scales: dashboard queries scan raw events, so at 1 million pageviews a month one load scans about 428 million rows; all figures are the author’s estimates.

    Lynn

    @hizachlynn · Original 𝕏 post

    $29 lifetime for analytics sounds like a great deal until you calculate the actual d1 database bill. d1 bills by rows scanned, not returned. without pre-aggregated rollup tables, every dashboard view runs count(distinct) and group by directly over raw event history. do the basic math for a 30-day window: >> 10k pv/mo: ~180k rows scanned per load. fine. >>> 100k pv/mo: ~5m rows scanned. a single refresh burns your entire daily free read limit. after that, queries break and tracking drops. >>>> 1m pv/mo: ~428m rows scanned. heavy joins take 70s+ in local tests, way past d1's hard 30s query timeout. on the paid plan, 428m rows is ~$0.43 per load. a small team opening stats 20 times a day is looking at ~$230/mo just in read costs. and writes aren't cheap either. between session heartbeats and indexes, 1 pageview triggers ~9 row writes. at 1m pv/mo, you burn through the free daily write limit immediately. the real dealbreaker? d1 executes queries sequentially per db. one slow 30-second dashboard query will literally block incoming event ingestion and silently drop tracking data. $29 once looks cheap next to a monthly subscription, until one bad month on d1 hands you a cloudflare bill that wipes out years of savings.
Community resourceWorkers +5

Polaris: self-hosted Free-plan remaining-quota and cost dashboard on Workers

etak64n/polaris is an MIT-licensed dashboard on Cloudflare Workers that shows how much of each Free plan limit is left and the cost/metrics of Workers, D1, R2, KV, Durable Objects, Queues, Workflows, Hyperdrive, Browser Run and Workers AI. It deploys behind Cloudflare Access and reads Analytics with an API token kept as a secret.

Other

mateuspainhob17: charged $4.88 for a feature no longer in use, for a second month, and opened a ticket.

Cloudflare Community user mateuspainhob17 (toasty.pet) says a failed invoice email arrived for a $4.88 charge. The author says the same charge also occurred the previous month, and that the feature was then deactivated, but the $4.88 charge appeared again even though the feature is not being used. The post does not name the feature. Community MVP sjr asked which feature it was and pointed the author to the billing-ticket guide. The author later said a ticket had been created and asked what to do next; sjr said to wait for a reply on the ticket. There is no Cloudflare staff reply on the public thread, and no ticket outcome is reported.

Community resourceWorkers +8

Cloudflare Medivh: a self-hosted near-real-time bill estimator

An open-source, self-hosted monitor that adds today’s estimated usage cost to Cloudflare’s daily-updated billable usage, sends summaries, and calls a webhook when the current cycle crosses a budget.