SQLite: efficient way to drop lots of rows

前端 未结 3 2047
说谎
说谎 2020-12-19 16:28

SQlite, Android, true story. I have a table, which I use as a cache:

CREATE TABLE cache(key TEXT, ts TIMESTAMP, size INTEGER, data BLOB);
CREATE UNIQUE INDEX         


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 16:52

    Apparently, what is slow is not finding the records to be deleted, but the actual deletion itself.

    Check if PRAGMA secure_delete is set by default in your Android's SQLite. You should just disable it, just to be sure.

    You do not need to run VACUUM; SQLite automatically resuses freed pages. You need VACUUM only if you actually know that the database will not grow again in size in the future.

提交回复
热议问题