From: Oleg Broytman Date: Fri, 25 Dec 2015 21:32:21 +0000 (+0300) Subject: VACUUM all tables after mass-insert X-Git-Tag: 0.0.4~65 X-Git-Url: https://git.phdru.name/?p=m_librarian.git;a=commitdiff_plain;h=1129afc4d0d93b43886522af59bacea93ec3d54d VACUUM all tables after mass-insert --- 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)