fast remove queries with new AceBase version
Ewout Stortenbeker committed
Sep 16, 2022 at 22:50 UTC
883f9ffd6e1dc3aa75f26a5d6700349e3eba305e
1 file changed
+3
-5
db.js
+3
-5
@@ -116,11 +116,9 @@ module.exports.CreateDB = function (parent, func) {
116
sqlDbQuery('DELETE FROM smbios WHERE expire < ?', [new Date()], function (doc, err) { }); // Delete events where expiration date is in the past
117
} else if (obj.databaseType == 7) { // AceBase
118
//console.log('Performing AceBase maintenance');
119
- // Delete older events. AceBase seems to be VERY slow as removing records. Here, we remove 100 records at a time only since so far, it's terribly slow.
120
- // TODO: Fugure out what record removal in AceBase is so slow
121
- obj.file.query('events').take(100).filter('time', '<', new Date(Date.now() - (expireEventsSeconds * 1000))).remove().then(function () {
122
- obj.file.query('stats').take(100).filter('time', '<', new Date(Date.now() - (expireServerStatsSeconds * 1000))).remove().then(function () {
123
- obj.file.query('power').take(100).filter('time', '<', new Date(Date.now() - (expirePowerEventsSeconds * 1000))).remove().then(function () {
119
+ obj.file.query('events').filter('time', '<', new Date(Date.now() - (expireEventsSeconds * 1000))).remove().then(function () {
120
+ obj.file.query('stats').filter('time', '<', new Date(Date.now() - (expireServerStatsSeconds * 1000))).remove().then(function () {
121
+ obj.file.query('power').filter('time', '<', new Date(Date.now() - (expirePowerEventsSeconds * 1000))).remove().then(function () {
122
//console.log('AceBase maintenance done');
123
});
124
});