From dc00060062be7a420ec4c0d08f8645508100270d Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 6 Feb 2026 12:08:49 +0800 Subject: [PATCH] :zap: Improve data indexing to reduce disk read operations https://github.com/siyuan-note/siyuan/issues/16958 Signed-off-by: Daniel <845765@qq.com> --- kernel/sql/database.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/sql/database.go b/kernel/sql/database.go index cb5336d81..e5620aac3 100644 --- a/kernel/sql/database.go +++ b/kernel/sql/database.go @@ -147,6 +147,11 @@ func initDBTables() { logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "create index [idx_blocks_root_id] failed: %s", err) } + _, err = db.Exec("CREATE INDEX idx_blocks_root_id_id_hash ON blocks(root_id, id, hash)") + if err != nil { + logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "create index [idx_blocks_root_id_id_hash] failed: %s", err) + } + _, err = db.Exec("DROP TABLE IF EXISTS blocks_fts") if err != nil { logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "drop table [blocks_fts] failed: %s", err)