From db9e7240386b7fdee5d796138f7118d01e3168e0 Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 20 May 2016 12:03:35 +0200 Subject: [PATCH] extremely speedup of all database operations: - (synchronous = OFF) write data through OS without syncing - (journal_mode = MEMORY) use memory for the transaction logging --- fail2ban/server/database.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fail2ban/server/database.py b/fail2ban/server/database.py index 7de87554..c0e9bf46 100644 --- a/fail2ban/server/database.py +++ b/fail2ban/server/database.py @@ -182,8 +182,11 @@ class Fail2BanDb(object): raise cur = self._db.cursor() - cur.execute("PRAGMA foreign_keys = ON;") - + cur.execute("PRAGMA foreign_keys = ON") + # speedup: write data through OS without syncing (no wait): + cur.execute("PRAGMA synchronous = OFF") + # speedup: transaction log in memory, alternate using OFF (disable, rollback will be impossible): + cur.execute("PRAGMA journal_mode = MEMORY") try: cur.execute("SELECT version FROM fail2banDb LIMIT 1") except sqlite3.OperationalError: