Try to optimize when closing the sqlite connection

This commit is contained in:
emeric
2023-11-02 14:56:31 +01:00
parent e0ed182784
commit 0801914290
+13
View File
@@ -47,6 +47,12 @@ namespace Database
prepare();
}
~Connection()
{
// make use of per-connection usage stats to optimize
optimize();
}
private:
Connection& operator=(const Connection&) = delete;
@@ -64,6 +70,13 @@ namespace Database
LMS_LOG(DB, DEBUG) << "Setting per-connection settings done!";
}
void optimize()
{
LMS_LOG(DB, DEBUG) << "connection close: Running pragma optimize...";
executeSql("pragma optimize");
LMS_LOG(DB, DEBUG) << "connection close: pragma optimize complete";
}
std::filesystem::path _dbPath;
};
}