From 9728e832b18e8bbfcc0e011b5b1da9afe6021bf3 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 23 Apr 2017 10:23:11 +0200 Subject: qlite/libdino: optimize db access --- libdino/src/entity/conversation.vala | 8 +------- libdino/src/service/database.vala | 3 +++ 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'libdino') diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala index 7e8b1424..e820af4d 100644 --- a/libdino/src/entity/conversation.vala +++ b/libdino/src/entity/conversation.vala @@ -88,13 +88,7 @@ public class Conversation : Object { } private void on_update(Object o, ParamSpec sp) { - var update = db.conversation.update().with(db.conversation.jid_id, "=", db.get_jid_id(counterpart)) - .with(db.conversation.account_id, "=", account.id); - if (counterpart.resourcepart != null) { - update.with(db.conversation.resource, "=", counterpart.resourcepart); - } else { - update.with_null(db.conversation.resource); - } + var update = db.conversation.update().with(db.conversation.id, "=", id); switch (sp.name) { case "type-": update.set(db.conversation.type_, type_); break; diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala index a74ac056..021d1c21 100644 --- a/libdino/src/service/database.vala +++ b/libdino/src/service/database.vala @@ -110,6 +110,8 @@ public class Database : Qlite.Database { internal EntityFeatureTable(Database db) { base(db, "entity_feature"); init({entity, feature}); + unique({entity, feature}, "IGNORE"); + index("entity_feature_idx", {entity}); } } @@ -135,6 +137,7 @@ public class Database : Qlite.Database { avatar = new AvatarTable(this); entity_feature = new EntityFeatureTable(this); init({ account, jid, message, real_jid, conversation, avatar, entity_feature }); + exec("PRAGMA synchronous=0"); } public override void migrate(long oldVersion) { -- cgit v1.2.3-70-g09d2