Skip to the guide
FlareBell

D1 MONITORING GUIDE

Why did your Cloudflare D1 rows read spike?

Start by separating two questions: did your application run more queries, or did each query read more rows? Then check that you are comparing the same database and time window. A usage spike is a signal to investigate; it is not, on its own, proof of a bug or a billing incident.

1. Rows read are different from rows returned

The number of rows returned by a SELECT is not a reliable substitute for the number of rows read while executing it. A query can return a small result after scanning a much larger set of rows. LIMIT alone does not tell you how much work the query performed.

Inspect rows_read in a D1 query result’s metadata where available. For a database-level view, Cloudflare D1 Analytics exposes aggregate rowsRead and rowsWritten. Keep the scope in mind: one query’s metadata and a time-window total answer different questions.

2. Confirm the database and comparison window

Select the affected database, record the start and end timestamps with a timezone, and compare equal-length windows. Check whether your baseline covers a similarly busy period. Comparing a peak hour with an overnight lull can make normal traffic look unusual.

Analytics collection and aggregation can introduce delays. Keep the window fixed and revisit it after more data arrives. Record when you fetched the metrics separately from the time they describe. A failed request or missing data should remain unknown, rather than being treated as zero usage or recovery.

3. Check traffic and query frequency

Compare the spike with application requests, background jobs, and recent deployments. More legitimate traffic may explain the change. Other hypotheses include a job running too often, repeated retries, cache misses, or the same query being issued many times within one request.

Use the request and job logs you already collect to test these hypotheses. Look for a change in query calls per request as well as total requests. A deployment at the same time is a useful lead, but timing alone does not establish the cause.

4. Inspect the expensive query’s plan

If query frequency has stayed steady, inspect the queries that could be reading more rows as your data grows. Check filters, joins, ordering, and whether an appropriate index exists. Use EXPLAIN QUERY PLAN against a representative query to understand how SQLite intends to access the data.

The example below assumes an events table with id, account_id, and created_at columns. Replace the table, columns, and parameter with those from your own query. The statement inspects a plan; it does not create an index or change application data.

EXPLAIN QUERY PLAN
SELECT id, created_at
FROM events
WHERE account_id = ?
ORDER BY created_at DESC
LIMIT 25;

A scan can be reasonable for a small table; an index is not automatically the right fix. Compare the plan and rows read before and after a change using representative data in staging. Index maintenance can also affect writes. Verify the result before applying the change to production.

5. Monitor usage separately from the bill

Track reads and writes independently and compare them with a usual baseline. For low-volume databases, a ratio can be large even when the absolute increase is small, so consider both. Useful alert details include the database, metric, affected window, usual value, and observed increase.

Usage metrics support investigation, but they are not a final invoice. Check your current plan and Cloudflare’s billing information when assessing cost. An alert cannot guarantee a spending cap, and delayed analytics cannot guarantee real-time notification.

Further reading

Use Cloudflare’s documentation to check the available metrics and current API permissions for your account.