这是用户在 2024-6-29 22:09 为 https://developers.cloudflare.com/d1/platform/pricing/ 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?
Cloudflare 云层 flare Docs 文档
Edit this page 编辑此页面
Report an issue with this page
Log into the Cloudflare dashboard
登录 Cloudflare 仪表板
Set theme to dark (⇧+D)

Pricing 定价

D1 bills based on: D1 基于账单:

  • Usage: Queries you issue against D1 will count as rows read, rows written, or both (for transactions or batches).
    使用方法:您对 D1 发出的查询将计为读取行数、写入行数或两者(对于事务或批处理)。
  • Scale-to-zero: You are not billed for hours or capacity units. If you are not issuing queries against your database, you are not billed for compute.
  • Storage: You are only billed for storage above the included limits of your plan.

​​ Billing metrics 计费指标

Workers Free 工人自由Workers Paid 工人付款
Rows read 行读5 million / day 每天 500 万First 25 billion / month included + $0.001 / million rows
每月首 25 亿条免费,超出部分每百万条收费$0.001
Rows written 行写100,000 / day 每天 10 万First 50 million / month included + $1.00 / million rows
每月首 5000 万条免费,超出部分每 100 万条收费 1 美元。
Storage (per GB stored) 存储(每 GB 存储)5 GB (total) 5 GB(总共)First 5 GB included + $0.75 / GB-mo
首 5 GB 包含在内 + $0.75 / GB-月

​​ Definitions 定义

  1. Rows read measure how many rows a query reads (scans), regardless of the size of each row. For example, if you have a table with 5000 rows and run a SELECT * FROM table as a full table scan, this would count as 5,000 rows read. A query that filters on an unindexed column may return fewer rows to your Worker, but is still required to read (scan) more rows to determine which subset to return.
    行读取度量查询读取(扫描)多少行,而不考虑每行的大小。例如,如果您有一个包含 5000 行的表,并运行 SELECT * FROM table 作为全表扫描,这将计为 5000 行读取。在未索引列上进行过滤的查询可能会向您的 Worker 返回较少的行,但仍需要读取(扫描)更多行以确定要返回的子集。
  2. Rows written measure how many rows were written to D1 database. A query that INSERT 10 rows into a users table would count as 10 rows written.
    行写入度量了写入到 D1 数据库的行数。将 10 行写入到 users 表的查询将计为 10 行写入。
  3. Row size or the number of columns in a row does not impact how rows are counted. A row that is 1 KB and a row that is 100 KB both count as one row.
    行大小或行中列的数量不影响行数的计算。一个大小为 1 KB 的行和一个大小为 100 KB 的行都算作一行。
  4. Defining indexes on your table(s) reduces the number of rows read by a query when filtering on that indexed field. For example, if the users table has an index on a timestamp column created_at, the query SELECT * FROM users WHERE created_at > ?1 would only need to read a subset of the table.
    在您的表上定义索引会减少查询时读取的行数,当在具有索引字段的过滤器上进行过滤时。例如,如果 users 表在时间戳列 created_at 上有一个索引,查询 SELECT * FROM users WHERE created_at > ?1 只需要读取表的一个子集。
  5. Indexes will add an additional written row when writes include the indexed column, as there are two rows written: one to the table itself, and one to the index. The performance benefit of an index and reduction in rows read will, in nearly all cases, offset this additional write.
  6. Storage is based on gigabytes stored per month, and is based on the sum of all databases in your account. Tables and indexes both count towards storage consumed.
  7. Free limits reset daily at 00:00 UTC. Monthly included limits reset based on your monthly subscription renewal date, which is determined by the day you first subscribed.
    每日免费限额在 UTC 00:00 重置。每月包含的限额根据您的每月订阅续订日期重置,该日期由您首次订阅的日期确定。
  8. There are no data transfer (egress) or throughput (bandwidth) charges for data accessed from D1.
    从 D1 访问的数据没有数据传输(出口)或吞吐量(带宽)费用。

​​ Frequently Asked Questions

Frequently asked questions related to D1 pricing:
与 D1 定价相关的常见问题:

  • Will D1 always have a Free plan?
    D1 是否会一直有免费计划?

Yes, the Workers Free plan will always include the ability to prototype and experiment with D1 for free.
是的,工人自由计划将始终包括免费使用 D1 进行原型设计和实验的能力。

  • What happens if I exceed the daily limits on reads and writes, or the total storage limit, on the Free plan?

When your account hits the daily read and/or write limits, you will not be able to issue queries against D1. D1 API will return errors to your client indicating that your daily limits have been exceeded. Once you have reached your included storage limit, you will need to delete unused databases or clean up stale data before you can insert new data, create or alter tables or create indexes and triggers.
当您的帐户达到每日读取和/或写入限制时,您将无法对 D1 发出查询。 D1 API 将向您的客户端返回错误,指示您的每日限制已超出。 一旦达到包含的存储限制,您将需要删除未使用的数据库或清理陈旧数据,然后才能插入新数据,创建或更改表或创建索引和触发器。

Upgrading to the Workers Paid plan will remove these limits, typically within minutes.

  • What happens if I exceed the monthly included reads, writes and/or storage on the paid tier?

You will be billed for the additional reads, writes and storage according to D1’s pricing metrics.
根据 D1 的定价指标,您将收到额外阅读、写入和存储的账单。

  • When will D1 start billing me?
    D1 什么时候开始向我收费?

For Workers Paid plan users, Cloudflare intends to start billing for additional usage beyond the included reads, writes and storage by (no earlier than) September 2023. Cloudflare will notify all customers via email (the super administrator address on their account) prior to this change.
对于付费计划用户,Cloudflare 打算从 2023 年 9 月开始对超出包含的读取、写入和存储量进行计费。Cloudflare 将在此变更之前通过电子邮件(其帐户上的超级管理员地址)通知所有客户。

  • How can I estimate my (eventual) bill?

Every query returns a meta object that contains a total count of the rows read (rows_read) and rows written (rows_written) by that query. For example, a query that performs a full table scan (for instance, SELECT * FROM users) from a table with 5000 rows would return a rows_read value of 5000:
每个查询都会返回一个包含读取行数( rows_read )和写入行数( rows_written )的总计的对象。例如,对一个包含 5000 行的表进行全表扫描的查询(例如, SELECT * FROM users )将返回一个 rows_read 值为 5000

"meta": {
"duration": 0.20472300052642825,
"size_after": 45137920,
"rows_read": 5000,
"rows_written": 0

These are also included in the D1 Cloudflare dashboard and the analytics API, allowing you to attribute read and write volumes to specific databases, time periods, or both.
这些也包含在 D1 Cloudflare 仪表板和分析 API 中,使您能够将读取和写入量归因于特定数据库、时间段或两者。

  • Does D1 charge for data transfer / egress?
    D1 是否收取数据传输/出站流量费用?


  • Does D1 charge additional for additional compute?
    D1 是否会为额外的计算收取额外费用?

D1 itself does not charge for additional compute. Workers querying D1 and computing results: for example, serializing results into JSON and/or issuing queries, are billed per Workers pricing, in addition to your D1 specific usage.
D1 本身不收取额外的计算费用。查询 D1 并计算结果的工作人员(例如,将结果序列化为 JSON 和/或发出查询)将按照工作人员定价计费,除了您的 D1 特定使用情况。

  • Do queries I issue from the dashboard or wrangler (the CLI) count as billable usage?
    我从仪表板或 wrangler(CLI)发出的查询算作计费使用吗?

Yes, any queries you issue against your database, including inserting (INSERT) existing data into a new database, table scans (SELECT * FROM table), or creating indexes count as either reads or writes.
是的,您对数据库发出的任何查询,包括将现有数据插入( INSERT )到新数据库、表扫描( SELECT * FROM table )或创建索引都算作读取或写入。

  • Can I use an index to reduce the number of rows read by a query?

Yes, you can use an index to reduce the number of rows read by a query. Creating indexes for your most queried tables and filtered columns reduces how much data is scanned and improves query performance at the same time. If you have a read-heavy workload (most common), this can be particularly advantageous. Writing to columns referenced in an index will add at least one (1) additional row written to account for updating the index, but this is typically offset by the reduction in rows read due to the benefits of an index.

  • Does a freshly created database, and/or an empty table with no rows, contribute to my storage?

Yes, although minimal. An empty table consumes at least a few kilobytes, based on the number of columns (table width) in the table. An empty database consumes approximately 100 KB of storage.
是的,尽管很少。根据表中的列数(表宽度),一个空表至少会消耗几千字节。一个空数据库大约消耗 100 KB 的存储空间。