You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/databases/d1.md
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,3 +166,64 @@ export default {
166
166
In this example, we create an array of `Query` objects using `getQueryAll()` from individual `insert` operations and then execute them all in a single batch using `qb.batchExecute()`. This is more efficient than executing each insert query separately.
167
167
168
168
**Note:** Batch operations in D1 have limitations. Refer to the Cloudflare D1 documentation for details on batch operation constraints.
169
+
170
+
## Execution Metrics
171
+
172
+
When you execute a query with `D1QB`, the returned result object contains metrics about the database operation. This includes `rowsRead` and `rowsWritten`, which provide insight into the impact of your query.
173
+
174
+
-`rowsRead`: The number of rows read from the database to execute the query.
175
+
-`rowsWritten`: The number of rows written (inserted, updated, or deleted) to the database.
176
+
177
+
These metrics can be useful for monitoring and optimizing your database queries.
Copy file name to clipboardExpand all lines: docs/databases/do.md
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -201,3 +201,66 @@ export class MyDurableObject extends DurableObject {
201
201
In this example, `fetchAll` is called with `lazy: true` and the generic type specified as `<Item, true>`. The `execute()` method returns a result object where `results` is an `AsyncIterable<Item>`. You can then use an `for await...of` loop to iterate through the results asynchronously, processing items one by one as they are fetched from the database.
202
202
203
203
**Note:** Lazy queries are particularly useful in Durable Objects to avoid blocking the event loop for extended periods when dealing with large datasets. However, keep in mind that each iteration still involves synchronous storage operations. Optimize your processing logic within the loop to maintain responsiveness.
204
+
205
+
## Execution Metrics
206
+
207
+
When you execute a query with `DOQB`, the returned result object contains metrics about the database operation. This includes `rowsRead` and `rowsWritten`, which provide insight into the impact of your query.
208
+
209
+
-`rowsRead`: The number of rows read from the database to execute the query.
210
+
-`rowsWritten`: The number of rows written (inserted, updated, or deleted) to the database.
211
+
212
+
These metrics can be useful for monitoring and optimizing your database queries within your Durable Object.
0 commit comments