Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:zap: Improve data indexing to reduce disk read operations https://github.com/siyuan-note/siyuan/issues/16958

Danieldc00060062be
diff --git a/kernel/sql/database.go b/kernel/sql/database.go
index cb5336d81e..e5620aac3c 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)