Commit a9e40960 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos/collect: use memory based journal for accelerate response

parent df5884a0
...@@ -38,7 +38,9 @@ class Database: ...@@ -38,7 +38,9 @@ class Database:
database_name = "collector.db" database_name = "collector.db"
preserve_table_list = ["heating"] preserve_table_list = ["heating"]
SET_PRAGMA_MODE = "pragma journal_mode=wal" SET_PRAGMA_JOURNAL_MODE = "pragma journal_mode=memory"
SET_PRAGMA_TEMP_STORE = "pragma temp_store=memory"
SET_PRAGMA_CACHE_SIZE = "pragma cache_size=100000"
CREATE_USER_TABLE = "create table if not exists user " \ CREATE_USER_TABLE = "create table if not exists user " \
"(partition text, pid real, process text, " \ "(partition text, pid real, process text, " \
" cpu_percent real, cpu_time real, " \ " cpu_percent real, cpu_time real, " \
...@@ -153,7 +155,9 @@ class Database: ...@@ -153,7 +155,9 @@ class Database:
def _bootstrap(self): def _bootstrap(self):
assert self.CREATE_USER_TABLE is not None assert self.CREATE_USER_TABLE is not None
self.connect() self.connect()
self._execute(self.SET_PRAGMA_MODE) self._execute(self.SET_PRAGMA_JOURNAL_MODE)
self._execute(self.SET_PRAGMA_TEMP_STORE)
self._execute(self.SET_PRAGMA_CACHE_SIZE)
self._execute(self.CREATE_USER_TABLE) self._execute(self.CREATE_USER_TABLE)
self._execute(self.CREATE_USER_PARTITION_DATE_TIME_INDEX) self._execute(self.CREATE_USER_PARTITION_DATE_TIME_INDEX)
self._execute(self.CREATE_FOLDER_TABLE) self._execute(self.CREATE_FOLDER_TABLE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment