Skip to content

Query Inside Loop (ARCH9064)

Key swift.orm.query-inside-loop · Severity warning · Category orm

Flags raw SQL (sqlite3_prepare, sqlite3_exec, executeQuery) issued inside a loop body - broader than the Core Data / Realm N+1 rule.

for id in ids { sqlite3_exec(db, "select ... \(id)", nil, nil, nil) }
one statement with an IN list, or a prepared statement bound per iteration

Batch the query, or prepare once and bind inside the loop.