From 1129afc4d0d93b43886522af59bacea93ec3d54d Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 26 Dec 2015 00:32:21 +0300 Subject: [PATCH] VACUUM all tables after mass-insert --- m_librarian/glst.py | 4 +++- m_librarian/inp.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/m_librarian/glst.py b/m_librarian/glst.py index 44ec612..b943813 100755 --- a/m_librarian/glst.py +++ b/m_librarian/glst.py @@ -48,7 +48,9 @@ def _import_glst(): os.path.join(ml_dir, 'glst', 'genres_fb2.glst')) old_nonfb2, new_nonfb2 = import_glst_file( os.path.join(ml_dir, 'glst', 'genres_nonfb2.glst')) - sqlhub.processConnection.query("VACUUM %s" % Genre.sqlmeta.table) + connection = sqlhub.processConnection + if connection.dbName in ('postgres', 'sqlite'): + connection.query("VACUUM %s" % Genre.sqlmeta.table) return old_fb2 + old_nonfb2, new_fb2 + new_nonfb2 diff --git a/m_librarian/inp.py b/m_librarian/inp.py index db0a3d8..e99800a 100644 --- a/m_librarian/inp.py +++ b/m_librarian/inp.py @@ -68,3 +68,7 @@ def import_inpx(path): inp = inpx.open(name) sqlhub.doInTransaction(import_inp, archive + '.zip', inp) inp.close() + connection = sqlhub.processConnection + if connection.dbName in ('postgres', 'sqlite'): + for table in Author, Book, Extension, Genre, Language: + connection.query("VACUUM %s" % table.sqlmeta.table) -- 2.39.2