diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-18 17:05:26 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-18 17:05:26 +0000 |
commit | 265cdfde91800ef2963084f02dfde521c4f1b9ac (patch) | |
tree | 413efc50da1b8e5f241641c1d25660e8234de4d3 /src/libutil/sqlite_utils.c | |
parent | aef1cac108507fcefba54694f46c4f2e8069c31d (diff) | |
download | rspamd-265cdfde91800ef2963084f02dfde521c4f1b9ac.tar.gz rspamd-265cdfde91800ef2963084f02dfde521c4f1b9ac.zip |
Add more tunes to sqlite
Diffstat (limited to 'src/libutil/sqlite_utils.c')
-rw-r--r-- | src/libutil/sqlite_utils.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c index 0458a0a02..bf8210c71 100644 --- a/src/libutil/sqlite_utils.c +++ b/src/libutil/sqlite_utils.c @@ -248,11 +248,20 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const sqlite3 *sqlite; gint rc, flags, lock_fd; gchar lock_path[PATH_MAX], dbdir[PATH_MAX], *pdir; - static const char sqlite_wal[] = "PRAGMA journal_mode=\"wal\";", - exclusive_lock_sql[] = "PRAGMA locking_mode=\"exclusive\";", - fsync_sql[] = "PRAGMA synchronous=1;", - foreign_keys[] = "PRAGMA foreign_keys=\"ON\";", - enable_mmap[] = "PRAGMA mmap_size=268435456;"; + static const char sqlite_wal[] = + "PRAGMA journal_mode=\"wal\";" + "PRAGMA wal_autocheckpoint = 16;" + "PRAGMA journal_size_limit = 1536;", + exclusive_lock_sql[] = "PRAGMA locking_mode=\"exclusive\";", + + fsync_sql[] = "PRAGMA synchronous=\"NORMAL\";", + + foreign_keys[] = "PRAGMA foreign_keys=\"ON\";", + + enable_mmap[] = "PRAGMA mmap_size=268435456;", + + other_pragmas[] = "PRAGMA read_uncommitted=\"ON\";" + "PRAGMA cache_size=262144"; gboolean create = FALSE, has_lock = FALSE; flags = SQLITE_OPEN_READWRITE; @@ -307,6 +316,8 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const has_lock = TRUE; } + sqlite3_enable_shared_cache (1); + if ((rc = sqlite3_open_v2 (path, &sqlite, flags, NULL)) != SQLITE_OK) { #if SQLITE_VERSION_NUMBER >= 3008000 @@ -393,6 +404,12 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const sqlite3_errmsg (sqlite)); } + if ((rc = sqlite3_exec (sqlite, other_pragmas, NULL, NULL, NULL)) != + SQLITE_OK) { + msg_warn_pool ("cannot execute tuning pragmas: %s", + sqlite3_errmsg (sqlite)); + } + if (has_lock) { msg_debug_pool ("removing lock from %s", lock_path); rspamd_file_unlock (lock_fd, FALSE); |