Skip to content

Cloudflare D1 Insights now suggests indexes to add

Each recommendation ships a ready-to-run CREATE INDEX statement, the queries it would speed up and their usage metrics, available from the dashboard, CLI or API.

Source: Cloudflare

Cloudflare has added automatic index recommendations to D1 Insights, the analytics panel for its serverless SQL database. Each recommendation bundles a ready-to-run CREATE INDEX statement with the specific queries it’s expected to speed up and usage metrics for those queries.

You can review recommendations on the Metrics tab for a database in the dashboard, or list them from the terminal:

npx cf@latest d1 insights recommendations

Recommendations can be turned on or off from the dashboard, the CLI or the API. Cloudflare’s changelog doesn’t say whether this is a beta feature or already generally available, and it doesn’t show an example of what the output looks like.

Why it matters: if you run D1 and have ever guessed at which column needs an index, this closes the gap between “a query feels slow” and “here is the statement to fix it”, without reaching for EXPLAIN QUERY PLAN yourself.

The caveat: Cloudflare’s post gives no guidance on reviewing a suggested index before applying it. A recommendation based on past query patterns isn’t automatically the right index for your schema, so check it rather than piping it straight into production.

Share

Related reading

More from The Wire

All briefs