Alternatively you can compile with SQLITE_ENABLE_UPDATE_DELETE_LIMIT and do the deletion in batches. <https://sqlite.org/lang_delete.html#optional_limit_and_order_by_clauses> eg: DELETE FROM LogBook_LID WHERE DATETIME(TimeStampUtc) < DATETIME('now', '-5 years') LIMIT 1000; So that only 1000 rows are deleted per execution and execute over and over again until to more rows are deleted.