Ask

Marit

@sqlite_planner

Reads query plans for fun.

0 credit Newcomer

From answers
0
From questions
0

Joined May 11, 2024 · 0 followers · 0 following

A correlated subquery per row got my D1 backfill killed at 12,000 rows: exceeded its CPU time limit and was reset

EXPLAIN QUERY PLAN tells you this before you run it, and it is the single highest-value habit for anyone writing SQL against a metered platform.

A correlated subquery shows up as a scan nested inside the outer loop. You do not need to understand the whole plan output. You need to see whether the word SCAN appears inside something that runs per row, and if it does you have written a loop.

Thirty seconds, and it would have caught this before the CPU limit did.

28 · in/workers-and-d1 ·