From 25bbd18d3be5db705d208b4d5a75def10bd84a75 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 12 May 2021 19:18:10 +0300 Subject: [PATCH] UI: StatManager: Vacuum on bulk deletes. --- src/ui/stat/statmanager.cpp | 4 ++++ src/ui/stat/statsql.cpp | 5 +++-- src/ui/stat/statsql.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ui/stat/statmanager.cpp b/src/ui/stat/statmanager.cpp index 80334e0b..e5afd17f 100644 --- a/src/ui/stat/statmanager.cpp +++ b/src/ui/stat/statmanager.cpp @@ -214,6 +214,8 @@ bool StatManager::clear() if (!sqliteDb()->execute(StatSql::sqlClear)) return false; + sqliteDb()->execute(StatSql::sqlVacuum); + clearAppIdCache(); quotaManager()->clear(); @@ -401,6 +403,8 @@ bool StatManager::deleteConnAll() sqliteDb()->stmt(StatSql::sqlDeleteAllConnBlock) }, sqliteDb()->stmt(StatSql::sqlSelectDeletedAllConnAppList)); + sqliteDb()->execute(StatSql::sqlVacuum); + sqliteDb()->commitTransaction(); m_connBlockIdMin = m_connBlockIdMax = 0; diff --git a/src/ui/stat/statsql.cpp b/src/ui/stat/statsql.cpp index dc6c8c07..02440284 100644 --- a/src/ui/stat/statsql.cpp +++ b/src/ui/stat/statsql.cpp @@ -203,5 +203,6 @@ const char *const StatSql::sqlClear = "DELETE FROM app;" "DELETE FROM conn;" "DELETE FROM conn_block;" "DELETE FROM conn_traffic;" - "DELETE FROM conn_flow;" - "VACUUM;"; + "DELETE FROM conn_flow;"; + +const char *const StatSql::sqlVacuum = "VACUUM;"; diff --git a/src/ui/stat/statsql.h b/src/ui/stat/statsql.h index 68400314..828ad7ee 100644 --- a/src/ui/stat/statsql.h +++ b/src/ui/stat/statsql.h @@ -81,6 +81,7 @@ public: static const char *const sqlSelectDeletedAllConnAppList; static const char *const sqlClear; + static const char *const sqlVacuum; }; #endif // STATSQL_H