Skip to content
digitalizando.

D1 starts recommending indexes based on database queries

The November 25 announcement shows the affected query and its usage metrics. Reproduce the result with sample orders before changing the database.

Kampus Production / Pexels

What appears in the panel.

Cloudflare announced on November 25, 2026, that D1 Insights is now recommending indexes for D1 databases. The suggestion identifies the query, provides an index creation instruction, and includes usage numbers. The “Metrics” tab can display up to 10 recommendations, ordered by estimated impact. This option can be enabled or disabled in the panel, via the command-line tool, or through the API. If disabled, the list will be empty.

According to Cloudflare, D1 looks for recent queries that read far more rows than they return. Workers AI receives the query, its usage data and the database schema to suggest an index. Usage metrics come from sampled D1 query analytics. A new analysis replaces the previous recommendations. Recommendations that are not refreshed expire after 7 days. A database with little recent activity may show none.

The suggestion does not execute the change.

The service checks if the instruction has a valid index creation format. The documentation advises testing its compatibility with the existing schema. A query that traverses fewer lines can result in a faster response. Indexes also consume space and add overhead to writes. The team gains a hypothesis that needs to be tested in their own environment.

Start with a query whose outcome someone can check. In this fictional example, the dispatch team prepares the oldest paid orders for one branch. The test should preserve order identifiers, the expected sequence and the handling of ties. Measure both the read and a typical order status update. Set your success criteria before changing the test database.

Reproduce a queue before and after.

Prepare a synthetic sample with orders from multiple units, including canceled and paid lines. Run the test query before and after the index, using the same filters and base. Verify a reference list that the shipping area can review. Compare the lines read and duration in both scenarios. Perform a separate test with an update that the team executes daily.

In a hypothetical test, the reading decreases from 32 to 18 milliseconds, and the update goes from 6 to 9. Record these two differences along with the sample. An operation that frequently retrieves and modifies a small number of orders may decide to proceed with a larger test. An operation that continuously writes needs to compare volumes and the limit it commits to maintain. The workshop verifies that the minimal evidence has been recorded.

Make the approval depend on three proofs.

Save the results and the comparison conditions, confirm the effect in the writing routine, and define with the responsible person how to review the change if the real observation deviates from the expected. If the returned orders are different, revert to the original query or reference data before interpreting the time gain.

The writing team verified the announcement and the limits described by the vendor. The orders and times in the example are fabricated. Recommendations, estimated impact, and measurements on your base must appear in separate logs, so the next change can be evaluated with the same reference.

Source developers.cloudflare.com ·