billflare.

SQL queries · Content tag

Browse content discussing sql queries.

57 matching items

Cases · 17

D1

hiromsaeden: an unindexed D1 query loop billed $2,129.00; a $953.74 courtesy credit left $645.38 due.

Cloudflare Community user hiromsaeden, in a post-mortem of a personal hobby project on Workers and D1, says an unindexed GROUP BY aggregate query scanned about 877,000 rows to return 30 rows, and an unintended loop triggered about 315,000 runs across two billing cycles. In the Oct 15 – Nov 15 cycle alone, 1,447,580,203,670 rows (1.44 trillion rows) were read, on top of the previous cycle’s usage. The author says the October invoice IN-83890481 was $529.88 USD, paid in full out of pocket; the November invoice IN-89082487 was $1,599.12 USD ($1,447.58 D1 Rows Read + $6.16 Workers CPU + $145.38 tax); and the total billed was $2,129.00 USD against an expected budget of about $20/month. After noticing the issue on Nov 2–3, the author deleted the Worker and the D1 database; Support confirmed all reads had stopped. In case #02408621, Support offered a $275.00 courtesy credit for October and advised holding it until the November invoice was issued on Nov 15. In case #02434399, Support applied a one-time courtesy credit of $953.74 (which included the held $275.00), leaving a final balance of $645.38 USD, and said the review was complete and no further adjustments can be made. The author, having already paid $529.88, says the remaining $645.38 cannot be afforded and the account will be downgraded on Nov 22. The author also says a budget alert fired once at the $37 mark but did not stop the charges, and that D1 currently has no hard spending cap. There is no Cloudflare staff reply on the public thread; the Support actions are reported by the author.

Reported amount · USD

$2,129

Reported cause: Unbounded loopcommunity.cloudflare.com
First reported: Latest update:
Durable Objects

maylivesforever: after moving from GCP to save money, a single day’s Cloudflare bill exceeded the whole monthly GCP bill.

maylivesforever says services were moved from GCP to Cloudflare to save money, and then a single day’s Cloudflare bill came in bigger than the whole monthly GCP bill. The author explains that Durable Objects bill every row SQLite reads, not every row it returns, and that one of their queries read 20,006 rows to return 5. A follow-up reply links the author’s write-up on how to avoid the mistake. No amount is given.

Reported amount · USD

Not disclosed

Reported cause: Read volumex.com
First reported: Latest update:
D1

edwardindiedev: a billing alert revealed an AI-written query scanning the whole table; the screenshot shows $98.49 of D1 Rows Read.

edwardindiedev says a Cloudflare billing alert arrived unexpectedly; the author first suspected a traffic spike on a recently launched site, but found that an AI-written query in their own backlink platform scanned the full table every time the platform was opened to check backlink-pool usage. The attached cost breakdown shows D1 Rows Read of 123.49B total, 98.49B billable, costing $98.49, with daily cost rising sharply around October 31–November 1, 2026 (UTC).

Reported amount · USD

$98.49

Reported cause: Read volumex.com
First reported: Latest update:
D1

prince (@prince_twets): a D1 full-scan bug led to an unexpected ~$200 bill for a pre-launch SaaS; asks for a one-time credit.

prince (@prince_twets) says the pre-launch JobClaw SaaS, which has no customers or revenue, received an unexpected bill of about $200 after a D1 full-scan bug. The author says their own report attributes about $182 of it to D1 read overage, that the query paths were removed and production was shut down, and that they cannot afford it. The author asks whether Cloudflare Billing could review a one-time credit, offers to share details privately, and tags Cloudflare accounts and staff in a follow-up reply.

Reported amount · USD

$200

Reported cause: Read volumex.com
First reported: Latest update:
D1

Kun Save Point (@Savepoint_kk): a D1 bug rewrote unchanged data into a $2,739.12 bill; $2,141 goodwill credit granted.

Kun Save Point (@Savepoint_kk), an indie developer who says he recently lost his job, says a bug repeatedly rewrote unchanged data while inefficient queries amplified reads, producing a $2,739.12 Cloudflare bill already paid via PayPal (D1 rows written $2,641.00, rows read $64.06, other services $34.06); he says his bills were usually under $10 a month. Cloudflare granted a $2,141 goodwill account credit under case #02391058. He asks for it to be converted into a refund to the original PayPal payment, or at least for relief on the $2,641 write charges, and later writes that the initial request was declined and has been reopened for additional review. On October 25 he adds that he missed the only alert email Cloudflare sent, whose amount was not particularly high, and received no further warning before the large card charge; on October 26 he writes that the refund request to the original payment method is still under further review. On November 10 he posts a timeline saying that after following up on November 10–11, support again stated the $2,141 could only remain as account credit and the remaining $598.12 was still undecided while the ticket was being closed. On 26 November 2026 the author posted another public thread asking what a "final decision" means. He says that in the first case an agent called a refund impossible as a "final decision," then submitted it for further review; that after several business days he was told the account credits could not be refunded while the remaining amount was still under review; and that the first case was later closed without a clear resolution of that remaining amount. He opened a second case; an agent said the remaining amount had been definitively rejected, another "final decision." After the author posted on X, a senior billing specialist (Agent D) confirmed that the previously rejected amount had actually been refunded. The author asked whether the larger $2,141 account credit could be converted into a cash refund; after being told it was under review, an agent from the first case declared another "final decision": no refund. The author asks who reviews these requests and why a supposedly final rejection was later followed by an actual refund, and says D1 on Workers Paid still lacks a configurable hard spending cap. The posts cite cases #02391058 and #02447083. There is no staff reply on that public thread.

Reported amount · USD

$2,739.12

Reported cause: Write volumex.com
First reported: Latest update:
D1

Jay (@Cyberlane): a $513.20 D1 bill for two small personal databases; Cloudflare confirms a refund.

Jay (@Cyberlane) says two small D1 databases used only by himself for two little apps produced a bill of over $500 for reads and writes. He later quotes the invoice: 452,256,462 rows written ($453) and 60,197,421,138 rows read ($60.20) for Sep 17 – Oct 16, a D1 total of $513.20 before tax. Tyson Trautmann, whose profile lists Storage & Databases at Cloudflare, replies publicly and loops in the D1 engineering team.

Reported amount · USD

$513.20

Reported cause: Write volumex.com
First reported: Latest update:
D1

Sven Guettner: a D1 bug produced a $1,868 bill from about 1.89 trillion row reads.

Sven Guettner says a wrong database setting on offercompass.app made every small update read the whole table in the background between Aug 28 and Sep 22, 2026, totaling about 1.89 trillion rows and a $1,868 D1 bill. He fixed the bug, shut the project down, opened ticket 02338870 asking for a courtesy credit, and reports only AI replies so far.

Reported amount · USD

$1,868

Reported cause: Read volumecommunity.cloudflare.com
First reported: Latest update:
D1

zmuleyu (yourchars.com): a $1,481.11 invoice from 1.476 trillion D1 rows read, with a $976.11 account credit.

Community user zmuleyu (yourchars.com) says an unintended query pattern repeatedly ran high-volume D1 scans during the July 17–August 16 billing period, reading about 1.476 trillion rows and producing a US$1,481.11 invoice (US$1,476.11 for D1 plus US$5 for Workers Paid). The author restricted public access, fixed the query path and added controls and alerts. Cloudflare granted a US$976.11 account credit on August 19, leaving US$500 of the D1 charge uncredited. The author asks how the credit was calculated, why US$500 was left, and how the balance can be used; support said the amount came from a case-specific review by a Finance team, the balance applies automatically to future eligible invoices, and closed the case again. The author notes budget alerts on Workers Paid are informational, not a hard limit.

Reported amount · USD

$1,481.11

Reported cause: Read volumecommunity.cloudflare.com
First reported: Latest update:
D1

Rentier Digital: D1 billed a zero-user dev app like production traffic.

Phil (rentierdigital) reports a filing-monitor app still in development—zero users—reading about 47 million D1 rows in a day (averaging about 12.9 million against a 5 million free-tier daily cap, with a July 2 spike to 22 million). He traces the cost to a background poller scanning 18,000 rows per tick and returning empty 447 of 451 times, then migrates off D1. He does not state a dollar invoice amount.

Reported amount · USD

Not disclosed

Reported cause: Repeated pollingx.com
First reported: Latest update:
D1

Kent C. Dodds: full-table D1 aggregates produce a $195.05 rows-read line item.

Kent C. Dodds links a pull request on X calling it "an unfortunate lesson". The pull request says the Aug 8, 2026 Cloudflare invoice ($213.79 total) included a $195.05 D1 line item for 195 billion rows read (Jul 8–Aug 7), mostly attributed to two full-table PostRead aggregates cached only in per-isolate memory. The change moves those results to a shared KV-backed cache.

Reported amount · USD

$195.05

Reported cause: Read volumex.com
First reported: Latest update:
D1

D1 row reads: a $134.14 invoice from unindexed queries.

Justin Ahinon reports that his April 21, 2026 Cloudflare invoice was $134.14, with $127.60 from 127,599,130,859 D1 row reads on a 765,000-row database. He attributes it to full table scans in queries that ran on every page load.

Reported amount · USD

$134.14

Reported cause: Read volumefullstacksveltekit.com
First reported: Latest update:
D1

contact.freeicon: inefficient D1 queries produced about $748 in four days.

Community user contact.freeicon, running a non-profit free icon library on cloudflare-icon.pages.dev, reports unexpected D1 charges of about $748 from April 13–17, 2026 after a LEFT JOIN GROUP BY query scanned about 6.4 million rows on every page request and bot crawling drove about 200 billion reads. The author replaced the query with a pre-computed indexed column and 72-hour KV caching.

Reported amount · USD

$748

Reported cause: Read volumecommunity.cloudflare.com
First reported: Latest update:
D1

D1 import failures reset the database and inflated writes to about 550 million rows.

ken7 reports migrating a read-heavy site to Workers with D1, then repeated internal D1 failures that reset the instance and forced full re-imports. The author says about 550,456,381 rows written on the invoice reflect failed import retries rather than production usage, and requests a waiver or credit. No dollar amount is given.

Reported amount · USD

Not disclosed

Reported cause: Write volumecommunity.cloudflare.com
First reported: Latest update:

Guides · 39

GuideD1

yaobuilds: Auto-refresh on the stats page may use up the D1 free tier's daily quota of 5 million rows read

On 2026-11-19, X user @yaobuilds reminds: a D1 free account has a daily quota of 5 million rows read, counted by rows scanned. The author gives an example: assuming 10,000 rows are scanned per minute, 24 hours requires reading 14,400,000 rows. The suggestion is to look at meta.rows_read first, then multiply by the number of calls per day; when the total does not need to be updated in real time, it can be cached for a few minutes. The author writes that the busiest "user" may be one's own auto-refresh. This is a usage calculation method, not a bill that has already occurred.

GuideD1Workers

hontrandev: a Workers Free D1 board list query read about 15,000 rows to return 58

On 2026-11-18, X user @hontrandev wrote that Cloudflare emailed that D1 had reached 78% of the 5 million rows-read-per-day limit on Workers Free, for a small internal ticketing app. The author says one board list query was reading about 15,000 rows to return 58, and that they wrote up why and how they fixed it, with a link in a reply. This is a usage warning on the Free daily cap, not an invoice amount.

GuideD1Workers

hiromsaeden: an unindexed D1 GROUP BY loop produced $2,129.00 in invoices on a hobby project

On 2026-11-18, Cloudflare Community user @hiromsaeden published a post-mortem of a personal hobby project. An unindexed GROUP BY aggregate query scanned about 877,000 rows to return 30 rows; an unintended loop triggered about 315,000 runs across two billing cycles. In the 15 October–15 November cycle alone, 1,447,580,203,670 rows (1.44 trillion rows) were read. Invoice IN-83890481 was $529.88 USD (paid). Invoice IN-89082487 was $1,599.12 USD ($1,447.58 D1 Rows Read + $6.16 Workers CPU + $145.38 tax). Total billed was $2,129.00 USD; the expected budget was about $20/month. Support cases #02408621 and #02434399 led to a one-time courtesy credit of $953.74 (including a held $275.00), leaving a final balance of $645.38 USD; support said no further adjustments would be made. These amounts are the author’s invoices and credits, not a Billflare case total in this guide.

GuideD1

风易: On the free tier, do not brute-force concurrent D1 writes; queue first, then write serially

On 2026-11-17, X user @Michael_liyang (风易) wrote a new D1 write experience note: on the free tier, do not brute-force concurrent D1 writes; queue first, then write serially. The author says D1 writes are serial; when several requests write the same table at the same time and collide, the mild case is a retry and the severe case is a failure. The approach is: 1. Write requests enter the queue first; 2. The consumer writes serially, batch by batch; 3. On failure, return to the queue and wait for the next round. The chain is request → enter the queue → write D1 serially → return to the queue on failure. The author emphasizes that reads can be freely concurrent, and writes must be queued.

GuideD1Workers

风易: On the free tier, do not send write operations one by one; a D1 batch can write N rows at one time

On 2026-11-17, X user @Michael_liyang (风易) wrote: on the free tier, do not send write operations one by one; what one batch write saves is the number of rows written and the number of subrequests. D1's batch can carry multiple statements at one time, and one call writes N rows. The chain is request → accumulate a batch → write once with batch → retry the whole batch on failure, and use an idempotency key as a backstop. The author's judgment: do not accumulate when real-time requirements are high; accumulate only for logs, bookkeeping, and bulk imports; write how long to accumulate into the config, and force a flush to disk on timeout.

GuideD1Workers

风易: On the free tier, do not wait synchronously for bookkeeping and log writes; return first, then persist to the database in the background with waitUntil

On 2026-11-16, X user @Michael_liyang (风易) wrote: on the free tier, do not wait synchronously for bookkeeping and log writes; return the response first, and throw write operations to the background. A synchronous write to D1 both slows the response and burns CPU time. The approach is: the response contains only the business result; bookkeeping goes through waitUntil to persist in the background; on failure, enter the queue for a catch-up write. The chain is request → call upstream → return the result first → write the books in the background → catch-up write on failure.

GuideD1Workers

风易: What cache fears most is looking up things that do not exist; a crawler scanning random keys makes every request hit D1

On 2026-11-16, X user @Michael_liyang (风易) wrote: what cache fears most is looking up things that do not exist. A crawler scans random keys, penetrates every time, and hits D1 directly, so the cache is added for nothing. The approach is to cache empty results as well, and give the TTL only 5 minutes; log high-frequency nonexistent keys to D1, and blacklist them once confirmed to be a crawler. The chain is request → check cache → return on hit → query D1 on miss → write an empty-value cache if it does not exist. The author's judgment: the cache prevents repeated lookups; it does not block lookups of nonexistent things on the database's behalf.

GuideD1R2WorkersKVQueues

qianshuixia2026: D1 free row-read cap burned twice in one day, plus R2 and Workers pitfalls after the first paid orders

浅水虾 (@qianshuixia2026) published a 16 November 2026 X article after the first $12 and $29 orders. On 14 November a 10-minute cron full-table scan burned the D1 Free 5 million daily row-read cap in 2 hours 14 minutes; the same evening the author ran wrangler d1 execute --remote statistics that scanned about 4.08 million rows in 5 minutes and hit the cap again, then paid $5 to upgrade to Workers Paid. The article also covers an R2 multipart complete() customMetadata mismatch that failed a >24 MB export five times (50 credits sent as apology), 128 MB / 10 ms / 50-subrequest walls that a paid plan does not lift, and Queues’ 10,000 daily operations with three operations per delivered message.

GuideD1Workers

风易: On the free tier, do not log in full; logging in full burns the D1 rows-written count first

On 2026-11-14, X user @Michael_liyang (风易) wrote: on the free tier, do not log in full; what full logging burns first is the D1 rows-written count. The approach is: log all errors, with a trace id and an error code; sample only 1% of successes, enough to see the trend; write the sample rate into the config, temporarily raise it when investigating, then lower it back. The chain is request → assign a level → log all errors / sample successes → redact → persist to D1. The author's judgment: logs are for investigation, not for stockpiling for retirement; the rows written that are saved are left for real errors.

GuideD1

Community: D1 Free daily row-read block with about 12,000 rows showing after the UTC reset

On 14 November 2026, kaushalkrishna011 reported that production D1 reads on flexiyo.kaushalkrishnax.workers.dev were blocked with “Account has exceeded the daily D1 Free tier limit of 5,000,000 rows read,” while usage after the 00:00 UTC reset was only about 12,000 rows. A 24-hour dashboard view showed about 11 million rows, including usage before the reset. The account had one D1 database; Explore Data was also blocked. There was no staff reply as of this run.

GuideD1

D1 on the free plan: unindexed queries burn rows read

风易 (@Michael_liyang) says the costliest thing on the free plan is not writes but queries without an index: D1 bills by rows read and an unindexed query scans the whole table, multiplying rows read (a figure he marks as still to be confirmed). He recommends indexing hot query fields, selecting only needed columns and logging slow queries.

GuideD1Workers

Nash: 115,937 D1 call-log rows since 22 October, after logging every uptime-monitor 402; sampling 1 in 100 cut the noise

On 2026-11-04, X user @NashBriggsy (Nash) wrote that their D1 call log had 115,937 rows since 22 October. Every request to their agent tools wrote one row with 17 columns (tool, status, paid, price, payer, ms, country, user agent and more). The flow was: the agent asks, gets a 402 with the price, signs, the facilitator settles, the tool answers, and the Worker writes the row. What went wrong, the author says, is that they also logged every uptime monitor’s 402, and that ran up the D1 bill. On 29 October they started sampling monitor 402s at 1 in 100 and added a time index for reports. The post does not state a dollar amount.

GuideDurable ObjectsSQLite

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.

GuideWorkersDurable ObjectsQueuesContainersCron Triggers

Lunora: codegen lints that name the billing meter a loop moves

Daniel (@_prisis_) says a Cloudflare bill spike is usually a loop, not traffic; his framework Lunora now flags count_without_index, queue_dispatch_cycle, cron_every_minute and container_long_sleep_after at codegen, before deploy, naming the meter each one moves.

GuideWorkersD1KVR2QueuesDurable ObjectsWorkers AIImages

WquGuru: a read-only Cloudflare billing audit prompt

WquGuru (@wquguru) shares a read-only audit prompt that checks account usage, D1 query plans, loops and retries, Durable Object wake-ups, high-priced operations and Worker config, then ranks risks by worst-month cost.

GuideD1Workers

A $500 D1 bill? Check rows written first

Layerbase walks through the D1 write meter using a public $513.20 invoice: writes cost 1,000× reads per row, indexes add written rows, and common causes include reprocessing jobs, upsert loops and writes on the read path.

GuideD1

FlareCost: what a D1 full table scan costs past 25 billion rows read

FlareCost's scenario scans the same 5-million-row table 200 times a day for 30 days: 30 billion rows read, 5 billion of them billed at $0.001 per million, totalling $10.00 on Paid including the $5 minimum. It stresses that D1 bills rows scanned, not rows returned, and that indexes cut reads but add a written row when the indexed column changes. Rates as published on 2026-11-02.

GuideD1

FlareCost: D1 on the Free plan, daily row caps and 500 MB per database

FlareCost's D1 Free page lists 5 million rows read and 100,000 rows written per day with 5 GB total storage, queries failing at the next row past a daily cap until midnight UTC, and per-database limits (ten databases of 500 MB each, 7 days of Time Travel, 50 queries per invocation). Reviewed against official pricing pages on 2026-11-02.

GuideD1

FlareCost: Cloudflare D1 queries per Worker invocation

FlareCost’s d1-queries-per-invocation page (reviewed 2026-11-02) is checked against the official Cloudflare pricing pages listed under Sources. Free plan: 50 queries per invocation. Paid plan: 1,000 queries per invocation. A `db.batch()` counts as one query against this limit, even if it contains many statements. Issuing 2,000 individual queries fails with `Too many API requests by single Worker invocation`. The batch still reads and writes the rows inside it. The invocation limit is not a billing discount.

GuideD1

FlareCost: Cloudflare D1 query duration

FlareCost’s d1-query-duration page (reviewed 2026-11-02) is checked against the official Cloudflare pricing pages listed under Sources. Free plan: 30 seconds, because the HTTP API itself must finish in 30 seconds. Paid plan: 30 seconds. A single statement that updates hundreds of thousands of rows can exceed execution limits. The docs say to batch work, for example 1,000 rows at a time. Time spent inside D1 still sits inside the Worker CPU and memory limits.

GuideD1

FlareCost: Cloudflare D1 rows-read allowance

FlareCost’s d1-rows-read-allowance page (reviewed 2026-11-02) is checked against the official Cloudflare pricing pages listed under Sources. Free plan: 5 million rows read per day, reset at 00:00 UTC. Queries fail after that. Paid plan: First 25 billion rows a month included, then $0.001 per million. A full scan counts every row. The official example is `SELECT * FROM table` on 5,000 rows counting as 5,000 reads. Paid reads are prorated. One billion rows past the allowance cost $1.

Skills · 1

Skill

Cloudflare billing risk audit skill

Ask your coding agent to check a Cloudflare project for loops, retries and repeated work that could drive up costs, with code locations and suggested improvements.

daftai-cloudflare-billing-audit