Philipp Hörist pushed to branch master at gajim / gajim
Commits:
ba9137a4 by Philipp Hörist at 2026-07-21T22:47:50+02:00
fix: Database: Add migration to run full ANALYZE
Fixes #12768
- - - - -
3 changed files:
- gajim/common/storage/archive/migration.py
- gajim/common/storage/archive/storage.py
- gajim/common/storage/base.py
Changes:
=====================================
gajim/common/storage/archive/migration.py
=====================================
@@ -135,6 +135,8 @@ def __init__(self, archive: AlchemyStorage, user_version:
int) -> None:
self._v18()
if user_version < 19:
self._v19()
+ if user_version < 20:
+ self._v20()
app.ged.raise_event(DBMigrationFinished())
@@ -409,6 +411,11 @@ def _v19(self) -> None:
for account in app.settings.get_accounts():
app.settings.set_account_setting(account, "roster_version", "")
+ def _v20(self) -> None:
+ app.ged.raise_event(DBMigrationStart(version=20))
+ self._archive.run_analyze()
+ self._archive.set_user_version(20)
+
def _get_account_pks(self, conn: sa.Connection) -> list[int]:
account_pks: list[int] = []
for account in app.settings.get_accounts():
=====================================
gajim/common/storage/archive/storage.py
=====================================
@@ -75,7 +75,7 @@
from gajim.common.util.datetime import utc_now
from gajim.common.util.text import get_random_string
-CURRENT_USER_VERSION = 19
+CURRENT_USER_VERSION = 20
_T = TypeVar("_T")
=====================================
gajim/common/storage/base.py
=====================================
@@ -277,7 +277,7 @@ def _set_synchronous(self, mode: str) -> None:
def _enable_secure_delete(self) -> None:
self._con.execute("PRAGMA secure_delete=1")
- def _run_analyze(self) -> None:
+ def _run_optimize(self) -> None:
self._con.execute("PRAGMA optimize")
@property
@@ -359,7 +359,7 @@ def shutdown(self) -> None:
GLib.source_remove(self._commit_source_id)
self._commit()
- self._run_analyze()
+ self._run_optimize()
self._con.close()
del self._con
@@ -426,7 +426,10 @@ def _on_db_connect(
stmts += [f"PRAGMA {key}={value}" for key, value in
self._pragma.items()]
self._dbapi_execute_multiple(stmts, dbapi_connection=dbapi_connection)
- def _run_analyze(self) -> None:
+ def run_analyze(self) -> None:
+ self._dbapi_execute_multiple(["PRAGMA analysis_limit=0", "ANALYZE"])
+
+ def _run_optimize(self) -> None:
self._dbapi_execute_multiple(["PRAGMA optimize", "VACUUM"])
def get_user_version(self) -> int:
@@ -493,7 +496,7 @@ def refresh(self, session: Session, obj: Any, attrs:
list[str]) -> None:
session.refresh(obj, attribute_names=attrs)
def shutdown(self) -> None:
- self._run_analyze()
+ self._run_optimize()
self._engine.dispose()
del self._engine
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/ba9137a4b653947c913e30a12fb11b6f0fae4aaf
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/ba9137a4b653947c913e30a12fb11b6f0fae4aaf
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]