Skip to content

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

:zap: Improve database loading performance https://github.com/siyuan-note/siyuan/issues/15115

Daniel2e2f152311a3
diff --git a/kernel/sql/block.go b/kernel/sql/block.go
index 71ba506957..dd3458fa2f 100644
--- a/kernel/sql/block.go
+++ b/kernel/sql/block.go
@@ -278,6 +278,21 @@ func nodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
func BatchGetBlockAttrs(ids []string) (ret map[string]map[string]string) {
ret = map[string]map[string]string{}
+
+ hitCache := true
+ for _, id := range ids {
+ ial := cache.GetBlockIAL(id)
+ if nil != ial {
+ ret[id] = ial
+ continue
+ }
+ hitCache = false
+ break
+ }
+ if hitCache {
+ return
+ }
+
trees := filesys.LoadTrees(ids)
for _, id := range ids {
tree := trees[id]
@@ -308,6 +323,15 @@ func GetBlockAttrs(id string) (ret map[string]string) {
func getBlockAttrsFromTree(id string, tree *parse.Tree) (ret map[string]string) {
ret = map[string]string{}
+
+ ial := cache.GetBlockIAL(id)
+ if nil != ial {
+ for k, v := range ial {
+ ret[k] = v
+ }
+ return
+ }
+
node := treenode.GetNodeInTree(tree, id)
if nil == node {
logging.LogWarnf("block [%s] not found", id)