From 4436001bb361ad4f9e4e05819214ecf0ea77c063 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 23 Oct 2026 16:57:14 +0200 Subject: database: Add indices to improve performance --- libdino/src/qlite/row.vala | 7 ++++--- libdino/src/service/database.vala | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'libdino') diff --git a/libdino/src/qlite/row.vala b/libdino/src/qlite/row.vala index 65c80f02..98fc902a 100644 --- a/libdino/src/qlite/row.vala +++ b/libdino/src/qlite/row.vala @@ -11,8 +11,9 @@ public class Row { internal Row(Statement stmt) { for (int i = 0; i < stmt.column_count(); i++) { string column_name; - if (stmt.column_origin_name(i) != null) { - column_name = @"$(stmt.column_table_name(i)).$(stmt.column_origin_name(i))"; + string origin_name = stmt.column_origin_name(i); + if (origin_name != null) { + column_name = field_name(origin_name, stmt.column_table_name(i)); } else { column_name = stmt.column_name(i); } @@ -34,7 +35,7 @@ public class Row { return field[this]; } - private string field_name(string field, string? table) { + private static string field_name(string field, string? table) { if (table != null) { return @"$table.$field"; } else { diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala index fba6f7a2..30032e2c 100644 --- a/libdino/src/service/database.vala +++ b/libdino/src/service/database.vala @@ -7,7 +7,7 @@ using Dino.Qlite; namespace Dino { public class Database : Qlite.Database { - private const int VERSION = 34; + private const int VERSION = 35; public class AccountTable : Table { public Column id = new Column.Integer("id") { primary_key = true, auto_increment = true }; @@ -49,6 +49,7 @@ public class Database : Qlite.Database { base(db, "entity"); init({id, account_id, jid_id, resource, caps_hash, last_seen}); unique({account_id, jid_id, resource}, "IGNORE"); + index("entity_account_jid_resource_idx", {account_id, jid_id, resource}); } } @@ -376,6 +377,7 @@ public class Database : Qlite.Database { init({entity, feature}); unique({entity, feature}, "IGNORE"); index("entity_feature_idx", {entity}); + index("entity_feature_feature_idx", {entity, feature}); } } -- cgit v1.3