storesafe / cordova-sqlite-storage-help

Help forum for Cordova sqlite plugin projects
2 stars 1 forks source link

How to VACUUM? #28

Open brodycj opened 7 years ago

brodycj commented 7 years ago

Raised in https://github.com/litehelpers/Cordova-sqlite-storage/issues/678 by @tktorza:

Hello, I try to VACUUM my db after to have delete table content [...]

tx.executeSql("DELETE FROM event", [], function (tx, rs) {
console.log('SQLITE 1');
tx.executeSql("VACUUM", [], function (tx, rs) {

          console.log('SQLITE 2');

      });
  });

but it doesn't work. In documentation you said that it's good to VACUUM database sometimes but I haven't see where to do this?

Thanks

In general I do NOT recommend executing VACUUM within a transaction. I recommend that you wait for an existing transaction to finish then do something like this (not tested):

db.executeSql('VACUUM', [], function(rs) {
 console.log('VACUUM OK');
)};

I will test and document this further when I get a chance.

I hope to add auto-vacuum in the near future ref: litehelpers/Cordova-sqlite-storage#646