diff options
-rw-r--r-- | libzeitgeist/db-reader.vala | 2 | ||||
-rw-r--r-- | libzeitgeist/sql-schema.vala | 9 | ||||
-rw-r--r-- | libzeitgeist/sql.vala | 5 | ||||
-rw-r--r-- | src/engine.vala | 1 |
4 files changed, 14 insertions, 3 deletions
diff --git a/libzeitgeist/db-reader.vala b/libzeitgeist/db-reader.vala index b90be0b0..b93c278f 100644 --- a/libzeitgeist/db-reader.vala +++ b/libzeitgeist/db-reader.vala @@ -67,6 +67,8 @@ public class DbReader : Object // FIXME: propagate this properly? critical ("TableLookup initialization failed: %s", err.message); } + + database.set_cache_size (128); } protected Event get_event_from_row (Sqlite.Statement stmt, uint32 event_id) diff --git a/libzeitgeist/sql-schema.vala b/libzeitgeist/sql-schema.vala index 17e6ff7a..59bfc721 100644 --- a/libzeitgeist/sql-schema.vala +++ b/libzeitgeist/sql-schema.vala @@ -5,6 +5,7 @@ * Copyright © 2011-2012 Canonical Ltd. * By Michal Hruby <michal.hruby@canonical.com> * By Siegfried-A. Gevatter <siegfried.gevatter@collabora.co.uk> + * Copyright © 2013 Seif Lotfy <seif@lotfy.com> * * Based upon a Python implementation (2009-2011) by: * Markus Korn <thekorn@gmx.net> @@ -36,7 +37,7 @@ namespace Zeitgeist.SQLite { public const string CORE_SCHEMA = "core"; - public const int CORE_SCHEMA_VERSION = 9; + public const int CORE_SCHEMA_VERSION = 10; private const string DATABASE_CREATION = "database_creation"; @@ -59,7 +60,7 @@ namespace Zeitgeist.SQLite Timestamp.from_now ()); exec_query (database, schema_sql); } - else if (schema_version >= 3 && schema_version <= 8) + else if (schema_version >= 3 && schema_version <= 9) { backup_database (); @@ -271,6 +272,8 @@ namespace Zeitgeist.SQLite exec_query (database, "PRAGMA journal_mode = WAL"); exec_query (database, "PRAGMA synchronous = NORMAL"); exec_query (database, "PRAGMA locking_mode = NORMAL"); + exec_query (database, "PRAGMA default_cache_size = 50"); + exec_query (database, "PRAGMA wal_autocheckpoint = 10"); } public static void create_schema (Sqlite.Database database) @@ -649,7 +652,7 @@ namespace Zeitgeist.SQLite * @param database the database on which to run the query * @param sql the SQL query to run */ - private static void exec_query (Sqlite.Database database, + public static void exec_query (Sqlite.Database database, string sql) throws EngineError { int rc = database.exec (sql); diff --git a/libzeitgeist/sql.vala b/libzeitgeist/sql.vala index 6c804006..db5e21a9 100644 --- a/libzeitgeist/sql.vala +++ b/libzeitgeist/sql.vala @@ -452,6 +452,11 @@ namespace Zeitgeist.SQLite return false; } + public void set_cache_size (int size) { + DatabaseSchema.exec_query (database, + "PRAGMA cache_size = %i".printf (size)); + } + protected void update_callback (Sqlite.Action action, string dbname, string table, int64 rowid) { diff --git a/src/engine.vala b/src/engine.vala index e98b4d3d..5190f30a 100644 --- a/src/engine.vala +++ b/src/engine.vala @@ -63,6 +63,7 @@ public class Engine : DbReader construct { extension_store = new ExtensionStore (this); + database.set_cache_size (24); } public string[] get_extension_names () |