Query time and database optimization
This commit is contained in:
1 parent
2e04450c76
commit
294f0e8b98
2 files changed
+18
No files matched your search
@@ -1,6 +1,7 @@
|
||||
use crate::fs::*;
|
||||
use rusqlite::Connection;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use log::error;
|
||||
|
||||
pub fn create_db() {
|
||||
let db_file = db_path();
|
||||
@@ -108,6 +109,18 @@ impl Default for SqliteConnection {
|
||||
|
||||
impl SqliteConnection {
|
||||
pub fn finish(&mut self) {
|
||||
let connection = self.0.take().unwrap();
|
||||
connection
|
||||
.query_row("PRAGMA wal_checkpoint(TRUNCATE)", [], |_| Ok(()))
|
||||
.unwrap_or_else(|e| {
|
||||
error!("Ошибка при checkpoint WAL: {e}");
|
||||
});
|
||||
connection
|
||||
.query_row("PRAGMA optimize", [], |_| Ok(()))
|
||||
.unwrap_or_else(|e| {
|
||||
error!("Ошибка при оптимизации БД: {e}");
|
||||
});
|
||||
|
||||
self.0 = None;
|
||||
}
|
||||
pub fn restart(&mut self) {
|
||||
|
||||
Reference in new issue
Block a user