From d14fb005bb696a4c25a7ce861794ca3170357a01 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Thu, 13 Apr 2023 12:24:47 -0700 Subject: [PATCH] on each successfull exit, do a little db maintainance... --- ui/medashare/cli.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/medashare/cli.py b/ui/medashare/cli.py index 6f40fce..b593e45 100644 --- a/ui/medashare/cli.py +++ b/ui/medashare/cli.py @@ -57,7 +57,7 @@ import re import shutil import socket import sqlalchemy -from sqlalchemy import create_engine, select, insert, func, delete +from sqlalchemy import create_engine, select, insert, func, delete, text from sqlalchemy.orm import sessionmaker, aliased, load_only import string import subprocess @@ -925,7 +925,14 @@ def init_datastructs(f): cache = TagCache.load(cachefname) try: - return f(options, persona, objstr, cache) + r = f(options, persona, objstr, cache) + + # per: https://www.sqlite.org/lang_analyze.html + with engine.connect() as con: + con.execute(text('PRAGMA analysis_limit = 400;')) + con.execute(text('PRAGMA optimize;')) + con.commit() + return r finally: if cache.modified: cache.store(cachefname)