Improve performance for refresh refs

This commit is contained in:
Daniel 2024-10-19 17:46:17 +08:00
parent 4f07f3314a
commit 570a6846b1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -44,20 +44,12 @@ func RefreshBacklink(id string) {
func refreshRefsByDefID(defID string) {
refs := sql.QueryRefsByDefID(defID, false)
trees := map[string]*parse.Tree{}
var rootIDs []string
for _, ref := range refs {
tree := trees[ref.RootID]
if nil != tree {
continue
}
var loadErr error
tree, loadErr = LoadTreeByBlockID(ref.RootID)
if nil != loadErr {
logging.LogErrorf("refresh tree refs failed: %s", loadErr)
continue
}
trees[ref.RootID] = tree
rootIDs = append(rootIDs, ref.RootID)
}
trees := filesys.LoadTrees(rootIDs)
for _, tree := range trees {
sql.UpdateRefsTreeQueue(tree)
}
}