[{"data":1,"prerenderedAt":29},["ShallowReactive",2],{"$fu1xtKxq7SRItLVG_Bc5z2OpbTTtIgggHublhjpQPy20":3},{"slug":4,"title":5,"description":6,"date":7,"tags":8,"draft":13,"readingMinutes":14,"html":15,"related":16},"cloudflare-d1","Cloudflare D1: Where It Fits and Where It Doesn't","Cloudflare D1 in November 2026: rows read and written pricing, the 10 GB database cap, one query at a time, Time Travel and read replicas.","2026-11-29",[9,10,11,12],"cloudflare","d1","sqlite","databases",false,4,"\u003Cp>Cloudflare D1 is SQLite run by Cloudflare, sitting next to your Workers. You bind it to a Worker, write normal SQL, and pay for rows instead of servers. For a lot of small apps that&#39;s close to free. For some apps it&#39;s the wrong database, and the reasons are all written down in Cloudflare&#39;s own limits page, which people tend to read after they&#39;ve built on it.\u003C/p>\n\u003Cp>Everything below is from the \u003Ca href=\"https://developers.cloudflare.com/d1/platform/pricing/\">D1 pricing\u003C/a> and \u003Ca href=\"https://developers.cloudflare.com/d1/platform/limits/\">limits\u003C/a> pages, checked November 29, 2026.\u003C/p>\n\u003Ch2>What you pay for\u003C/h2>\n\u003Cp>D1 bills three things: rows read, rows written and storage.\u003C/p>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>\u003C/th>\n\u003Cth>Workers Free\u003C/th>\n\u003Cth>Workers Paid\u003C/th>\n\u003C/tr>\n\u003C/thead>\n\u003Ctbody>\u003Ctr>\n\u003Ctd>Rows read\u003C/td>\n\u003Ctd>5 million a day\u003C/td>\n\u003Ctd>25 billion a month included, then $0.001 per million\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>Rows written\u003C/td>\n\u003Ctd>100,000 a day\u003C/td>\n\u003Ctd>50 million a month included, then $1.00 per million\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>Storage\u003C/td>\n\u003Ctd>5 GB total\u003C/td>\n\u003Ctd>5 GB included, then $0.75 per GB-month\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>Databases\u003C/td>\n\u003Ctd>10\u003C/td>\n\u003Ctd>100,000 included, then $0.10 each a month\u003C/td>\n\u003C/tr>\n\u003C/tbody>\u003C/table>\n\u003Cp>No charge for compute time, connections, or data leaving Cloudflare. Writes cost a thousand times more than reads per row, but 50 million included writes is a lot for a small product.\u003C/p>\n\u003Ch2>The catch: &quot;rows read&quot; means rows scanned\u003C/h2>\n\u003Cp>This is the line that surprises people. D1 counts every row the query \u003Cem>looks at\u003C/em>, not the rows it returns. A \u003Ccode>SELECT * FROM orders WHERE customer_email = ?\u003C/code> on an unindexed column scans the whole table. With 2 million orders, that&#39;s 2 million rows read to return three.\u003C/p>\n\u003Cp>On the free plan&#39;s 5 million rows a day, the third request like that is already over the limit. On the paid plan 25 billion is a big allowance, but a hot unindexed query run on every page load still chews through it: 10,000 such requests is 20 billion rows.\u003C/p>\n\u003Cimg src=\"/blog/cloudflare-d1/d1-rows-read-index.webp\" alt=\"The same lookup on a 2 million row orders table: 2,000,000 rows read without an index, 3 rows read with one\" width=\"1600\" height=\"900\" loading=\"lazy\">\u003Cp>The fix is the same as on any SQLite or Postgres: index the columns you filter on. Run the query with \u003Ccode>EXPLAIN QUERY PLAN\u003C/code> first. If it says \u003Ccode>SCAN orders\u003C/code> instead of \u003Ccode>SEARCH orders USING INDEX\u003C/code>, you&#39;re paying for the whole table. The D1 dashboard also shows rows read per query, which is the fastest way to find the expensive one.\u003C/p>\n\u003Ch2>The limits that decide the architecture\u003C/h2>\n\u003Cp>The pricing is generous. The limits are what make D1 a fit or not:\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>10 GB per database\u003C/strong> on the paid plan (500 MB on free). You can&#39;t raise it. D1 is built for many small databases (up to a million per account), not one big one.\u003C/li>\n\u003Cli>\u003Cstrong>One query at a time per database.\u003C/strong> Each D1 database is single-threaded. Cloudflare&#39;s own example: queries averaging 1 ms give you about 1,000 queries a second, queries averaging 100 ms give you about 10.\u003C/li>\n\u003Cli>\u003Cstrong>30 seconds\u003C/strong> per query, and that includes a whole \u003Ccode>batch()\u003C/code> call.\u003C/li>\n\u003Cli>\u003Cstrong>1,000 queries per Worker invocation\u003C/strong> on paid, 50 on free.\u003C/li>\n\u003Cli>\u003Cstrong>100 bound parameters per query\u003C/strong>, which bites on bulk inserts. Chunk them.\u003C/li>\n\u003Cli>\u003Cstrong>2 MB\u003C/strong> maximum row, string or BLOB. Files belong in R2.\u003C/li>\n\u003C/ul>\n\u003Cp>That one-query-at-a-time line matters more than the 10 GB one. A single slow report query blocks every request behind it. Keep D1 queries short and indexed, and run anything heavy somewhere else.\u003C/p>\n\u003Ch2>Where D1 is a good fit\u003C/h2>\n\u003Cul>\n\u003Cli>\u003Cstrong>Per-tenant databases.\u003C/strong> One database per customer, per workspace, per site. Each stays small, they don&#39;t block each other, and deleting a tenant is deleting a database. This is the design D1 is built around, and it&#39;s genuinely nice.\u003C/li>\n\u003Cli>\u003Cstrong>Small apps already on Workers.\u003C/strong> Config, users, settings, a content table for a site. A few thousand users fit comfortably inside the free tier if the queries are indexed.\u003C/li>\n\u003Cli>\u003Cstrong>Read-heavy data close to users.\u003C/strong> Read replication through the Sessions API (\u003Ccode>withSession()\u003C/code>) sends reads to replicas near the user with no extra storage or compute charge, and gives sequential consistency within a session, so a user sees their own writes.\u003C/li>\n\u003C/ul>\n\u003Ch2>Where I&#39;d use something else\u003C/h2>\n\u003Cul>\n\u003Cli>\u003Cstrong>One big shared database that will pass 10 GB.\u003C/strong> Use Postgres. Neon, Supabase, or RDS all work from a Worker through Hyperdrive.\u003C/li>\n\u003Cli>\u003Cstrong>Heavy concurrent writes to the same data,\u003C/strong> like counters everyone updates, or a busy queue table. Single-threaded writes queue up. Durable Objects or a proper queue fit better.\u003C/li>\n\u003Cli>\u003Cstrong>Analytics and long reports.\u003C/strong> A 20-second query is legal in D1 and blocks everything else on that database while it runs.\u003C/li>\n\u003Cli>\u003Cstrong>Code that isn&#39;t on Workers.\u003C/strong> D1 has an HTTP API, but if your backend runs on a normal server, it&#39;s simpler to use a database built for normal connections.\u003C/li>\n\u003C/ul>\n\u003Ch2>Backups and the &quot;oops&quot; query\u003C/h2>\n\u003Cp>D1 has Time Travel: point-in-time restore to any minute in the last 30 days on paid, 7 on free, at no extra cost:\u003C/p>\n\u003Cpre>\u003Ccode class=\"language-bash\">wrangler d1 time-travel restore my-db --timestamp=1764374400\n\u003C/code>\u003C/pre>\n\u003Cp>It restores in place, overwriting the current database. So before running a risky migration, note the current bookmark (\u003Ccode>wrangler d1 time-travel info my-db\u003C/code>) so you know exactly where to go back to. For anything you&#39;d need for longer than 30 days, export with \u003Ccode>wrangler d1 export\u003C/code> on a schedule and put the file in R2.\u003C/p>\n\u003Ch2>The short version\u003C/h2>\n\u003Cp>D1 is a very good small database and an awkward big one. If your data splits naturally into small pieces, or your app is small and lives on Workers, it&#39;s cheap and pleasant. If you&#39;re planning one shared database for everything, read the 10 GB and single-threaded lines twice, then pick Postgres.\u003C/p>\n\u003Cp>If you&#39;re deciding between D1 and Postgres for something you&#39;re building, or a D1 app has started to slow down, \u003Ca href=\"https://calendly.com/director-norsky/meeting\">book a free call\u003C/a>. All consultation is free, and here&#39;s what I do for \u003Ca href=\"/services/nodejs-development\">Node.js backends\u003C/a>.\u003C/p>\n",[17,21,25],{"slug":18,"title":19,"description":20},"sqlite-vs-postgres","SQLite vs Postgres: Pick by Writers, Not by Size","SQLite vs Postgres in 2026: SQLite 3.54 and Postgres 18. Why the number of processes writing at once decides it, not traffic or data size.",{"slug":22,"title":23,"description":24},"postgres-vs-mongodb","Postgres vs MongoDB: Pick by the Questions You'll Ask Later","Postgres vs MongoDB in November 2026: Postgres 19 just shipped, MongoDB 8.3, JSONB vs documents, joins, transactions, licensing, and how I choose for a new app.",{"slug":26,"title":27,"description":28},"cloudflare-tunnel","Cloudflare Tunnel: Put a Server Online With No Open Ports","Cloudflare Tunnel checked November 2026: quick tunnels vs named ones, config.yml ingress rules, running cloudflared as a service, 1033 vs 502, and the limits.",1795910047459]