diff options
author | Seif Lotfy <seif@lotfy.com> | 2013-01-02 03:21:16 +0100 |
---|---|---|
committer | Seif Lotfy <seif@lotfy.com> | 2013-01-02 03:23:42 +0100 |
commit | 0d160d7c7644660283352245c8f56c45aa9e5f1c (patch) | |
tree | eb4c58dc7c5a0f7736139ab71c2bb83135e4f525 /src | |
parent | 4061a6cdc04664d7fe265b1ba6960e685ac20331 (diff) | |
download | zeitgeist-0d160d7c7644660283352245c8f56c45aa9e5f1c.tar.gz |
remove redundant indexes
Diffstat (limited to 'src')
-rw-r--r-- | src/sql-schema.vala | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/sql-schema.vala b/src/sql-schema.vala index 0bffd2b3..17e6ff7a 100644 --- a/src/sql-schema.vala +++ b/src/sql-schema.vala @@ -36,7 +36,7 @@ namespace Zeitgeist.SQLite { public const string CORE_SCHEMA = "core"; - public const int CORE_SCHEMA_VERSION = 8; + public const int CORE_SCHEMA_VERSION = 9; private const string DATABASE_CREATION = "database_creation"; @@ -51,7 +51,6 @@ namespace Zeitgeist.SQLite // most likely a new DB setup_database (database); create_schema (database); - create_basic_indices (database); create_event_indices (database); // set database creation date @@ -60,7 +59,7 @@ namespace Zeitgeist.SQLite Timestamp.from_now ()); exec_query (database, schema_sql); } - else if (schema_version >= 3 && schema_version <= 7) + else if (schema_version >= 3 && schema_version <= 8) { backup_database (); @@ -112,8 +111,7 @@ namespace Zeitgeist.SQLite // Create any missing tables and indices create_schema (database); drop_event_indices (database); - create_basic_indices (database); - create_event_indices (database); + drop_basic_indices (database); // Migrate data to the new tables and delete the old ones foreach (unowned string table in tables) @@ -172,7 +170,8 @@ namespace Zeitgeist.SQLite """); exec_query (database, "COMMIT"); - + create_event_indices (database); + exec_query (database, "ANALYZE"); message ("Upgraded database to schema version %d.", CORE_SCHEMA_VERSION); } @@ -607,6 +606,22 @@ namespace Zeitgeist.SQLite """); } + /* + * Drop indices for all auxiliary tables. + */ + public static void drop_basic_indices (Sqlite.Database database) + throws EngineError + { + exec_query (database, "DROP INDEX IF EXISTS uri_value"); + exec_query (database, "DROP INDEX IF EXISTS interpretation_value"); + exec_query (database, "DROP INDEX IF EXISTS manifestation_value"); + exec_query (database, "DROP INDEX IF EXISTS mimetype_value"); + exec_query (database, "DROP INDEX IF EXISTS actor_value"); + exec_query (database, "DROP INDEX IF EXISTS text_value"); + exec_query (database, "DROP INDEX IF EXISTS storage_value"); + exec_query (database, "DROP INDEX IF EXISTS extensions_conf_key"); + } + public static void drop_event_indices (Sqlite.Database database) throws EngineError { |