Excessive Memory Usage During Large DELETE with Correlated Subquery in SQLite
Understanding SQLite’s Two-Pass DELETE Strategy with Correlated Subqueries The core challenge revolves around executing a DELETE operation targeting billions of rows using a correlated subquery (NOT EXISTS). SQLite’s query planner employs a two-pass strategy for such operations: Identification Phase: Compile a list of all rowid values satisfying the WHERE clause into an in-memory structure. Deletion…