diff options
author | fiaxh <git@lightrise.org> | 2020-11-05 17:09:15 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2020-11-05 17:11:46 +0100 |
commit | 1999c97bb925d64cfe7cbc230959ce9a18728081 (patch) | |
tree | 44f91f6d2adf4e298e8d0913036cf901d14b180a /libdino/src | |
parent | 6218b759bff5c865cf87d5579822781def1f243a (diff) | |
download | dino-1999c97bb925d64cfe7cbc230959ce9a18728081.tar.gz dino-1999c97bb925d64cfe7cbc230959ce9a18728081.zip |
Improve content_item db table index
fixes #923
Co-authored-by: eta <eta@theta.eu.org>
Diffstat (limited to 'libdino/src')
-rw-r--r-- | libdino/src/service/database.vala | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala index 6384fa78..40967025 100644 --- a/libdino/src/service/database.vala +++ b/libdino/src/service/database.vala @@ -7,7 +7,7 @@ using Dino.Entities; namespace Dino { public class Database : Qlite.Database { - private const int VERSION = 16; + private const int VERSION = 17; public class AccountTable : Table { public Column<int> id = new Column.Integer("id") { primary_key = true, auto_increment = true }; @@ -62,7 +62,7 @@ public class Database : Qlite.Database { internal ContentItemTable(Database db) { base(db, "content_item"); init({id, conversation_id, time, local_time, content_type, foreign_id, hide}); - index("contentitem_localtime_counterpart_idx", {local_time, conversation_id}); + index("contentitem_conversation_hide_localtime_time_idx", {conversation_id, hide, local_time, time}); unique({content_type, foreign_id}, "IGNORE"); } } @@ -390,6 +390,14 @@ public class Database : Qlite.Database { error("Failed to upgrade to database version 16: %s", e.message); } } + if (oldVersion < 17) { + try { + exec("DROP INDEX contentitem_localtime_counterpart_idx"); + exec("CREATE INDEX contentitem_conversation_hide_localtime_time_idx ON content_item (conversation_id, hide, local_time, time)"); + } catch (Error e) { + error("Failed to upgrade to database version 17: %s", e.message); + } + } } public ArrayList<Account> get_accounts() { |