Преглед на файлове

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

Daniel преди 11 месеца
родител
ревизия
5f56e42dee
променени са 1 файла, в които са добавени 6 реда и са изтрити 1 реда
  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()
 		ignoreLines := getRefSearchIgnoreLines()
 		refs := sql.QueryRefsRecent(onlyDoc, ignoreLines)
 		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 {
 		for _, ref := range refs {
 			tree := cachedTrees[ref.DefBlockRootID]
 			tree := cachedTrees[ref.DefBlockRootID]
 			if nil == tree {
 			if nil == tree {
-				tree, _ = LoadTreeByBlockID(ref.DefBlockRootID)
+				tree, _ = loadTreeByBlockTree(bts[ref.DefBlockRootID])
 			}
 			}
 			if nil == tree {
 			if nil == tree {
 				continue
 				continue