Skip to content

Commit 94da6be

Browse files
committed
Adding a note to say writing to indexes count as additional rows.
1 parent 1408006 commit 94da6be

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/content/docs/durable-objects/api/sql-storage.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export class MyDurableObject extends DurableObject {
3737
SQL API methods accessed with `ctx.storage.sql` are only allowed on [Durable Object classes with SQLite storage backend](/durable-objects/reference/durable-objects-migrations/#enable-sqlite-storage-backend-on-new-durable-object-class-migration) and will return an error if called on Durable Object classes with a key-value storage backend.
3838
:::
3939

40+
:::note
41+
When writing data, every index counts as an additional row. However, indexes may be beneficial for read-heavy use cases. Refer to [Index for SQLite Durable Objects](/durable-objects/best-practices/access-durable-objects-storage/#index-for-sqlite-durable-objects).
42+
:::
43+
4044
Specifically for Durable Object classes with SQLite storage backend, KV operations which were previously asynchronous (for example, [`get`](/durable-objects/api/storage-api/#get), [`put`](/durable-objects/api/storage-api/#put), [`delete`](/durable-objects/api/storage-api/#delete), [`deleteAll`](/durable-objects/api/storage-api/#deleteall), [`list`](/durable-objects/api/storage-api/#list)) are synchronous, even though they return promises. These methods will have completed their operations before they return the promise.
4145

4246
## Methods

src/content/docs/durable-objects/best-practices/access-durable-objects-storage.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ new_sqlite_classes = ["MyDurableObject"] # Array of new classes
7878

7979
<Render file="durable-objects-vs-d1" />
8080

81+
## Index for SQLite Durable Objects
82+
83+
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.
84+
8185
## Related resources
8286

8387
* [Zero-latency SQLite storage in every Durable Object blog post](https://blog.cloudflare.com/sqlite-in-durable-objects)

0 commit comments

Comments
 (0)