Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[D1] Pricing Page Should Include How INSERT, DELETE, and UPDATE are Billed, and Clarify Which DDL Operations May Incur Charges #14630

Open
ciw1973 opened this issue May 17, 2024 · 0 comments
Assignees
Labels
content:edit Request for content edits documentation Documentation edits product:d1 D1: https://developers.cloudflare.com/d1/

Comments

@ciw1973
Copy link

ciw1973 commented May 17, 2024

Existing documentation URL(s)

https://developers.cloudflare.com/d1/platform/pricing/

What changes are you suggesting?

Update bullet 2 in Definitions, appending the following:

Write operations include UPDATE, DELETE, and INSERT.

Note - Any other DML/DQL operations which are considered writes for billing purposes should also be added to this list.

Add the following bullets under Definitions to make it clear where charges may be incurred as a result of DDL operations:

  1. There are no charges for CREATE TABLE, DROP TABLE, and DROP INDEX.
  1. A CREATE INDEX on a table which already contains data will immediately populate the index from that table data. In order to do this, every row in the table must be read, incurring read charges, and a corresponding row inserted into the new index, thus incurring write charges.
  1. An ALTER TABLE which removes columns requires all existing rows in the table to be updated to reflect this change, and you will be charged a write for each row.
  1. An ALTER TABLE which adds columns with a CHECK constraint, or generated column with a NOT NULL constraint, will require all existing data in the table be read in order to validate that this change can be made, and you will therefore be charged for a read operation on each row in the table. When adding new columns which don't have these constraints (even those with a default value) there is no requirement for the data in the table to be read or updated, and therefore no charges will be incurred based on the number of rows in the table.

Additional information

Whilst it's reasonable to expect most people will consider INSERT and UPDATE operations as writes to the database, it's not clear how DELETE operations should be considered, and whether they're even chargeable?

Most Cloudflare services charge for deletion operations, however R2 doesn't charge for deleting Objects and Buckets, despite these effectively mutating state, which one might expect would make them Class A operations, and therefore chargeable.

The D1 Client API documentation (https://developers.cloudflare.com/d1/build-with-d1/d1-client-api/#await-stmtrun) mentions that UPDATE, DELETE, and INSERT operations are writes, so the information is there, but buried, rather than being on the pricing page where it belongs. Having to go searching elsewhere for this, not even knowing if it's there at all, really isn't good.

With regard to DDL operations, I'd not expect CREATE TABLE, DROP TABLE, and DROP INDEX to incur any charges, but there are implications with a CREATE INDEX, and in some cases ALTER TABLE on tables which already contain data. Assuming things behave the same way under the hood as the do with regular SQLite, and that any necessary read and write operations on the affected table will be billed the same as regular client initiated table reads and writes, then it should be made clear on the Pricing page. Based on my understanding of this, I've provided suggested wording above.

@ciw1973 ciw1973 added content:edit Request for content edits documentation Documentation edits labels May 17, 2024
@github-actions github-actions bot added the product:d1 D1: https://developers.cloudflare.com/d1/ label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content:edit Request for content edits documentation Documentation edits product:d1 D1: https://developers.cloudflare.com/d1/
Projects
None yet
Development

No branches or pull requests

6 participants