Browse Source

:zap: Improve block ref searching performance https://github.com/siyuan-note/siyuan/issues/11951

Daniel 11 months ago
parent
commit
5f56e42dee
1 changed files with 6 additions and 1 deletions
  1. 6 1
      kernel/model/search.go

+ 6 - 1
kernel/model/search.go

@@ -324,10 +324,15 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
 
 		ignoreLines := getRefSearchIgnoreLines()
 		refs := sql.QueryRefsRecent(onlyDoc, ignoreLines)
+		var btsID []string
+		for _, ref := range refs {
+			btsID = append(btsID, ref.DefBlockRootID)
+		}
+		bts := treenode.GetBlockTrees(btsID)
 		for _, ref := range refs {
 			tree := cachedTrees[ref.DefBlockRootID]
 			if nil == tree {
-				tree, _ = LoadTreeByBlockID(ref.DefBlockRootID)
+				tree, _ = loadTreeByBlockTree(bts[ref.DefBlockRootID])
 			}
 			if nil == tree {
 				continue