An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:zap: Improve database view performance https://github.com/siyuan-note/siyuan/issues/17830
Danielb0110bc38176
diff --git a/kernel/sql/av.go b/kernel/sql/av.goindex ac875b464a..a9ae394d0d 100644--- a/kernel/sql/av.go+++ b/kernel/sql/av.go@@ -434,6 +434,7 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection}// 渲染关联+ blocksCache := map[string]map[string]*av.Value{}for _, item := range collection.GetItems() {for _, value := range item.GetValues() {if av.KeyTypeRelation != value.Type {@@ -451,17 +452,21 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection}}if nil != destAv {- blocks := map[string]*av.Value{}- blockValues := destAv.GetBlockKeyValues()- if nil != blockValues {- for _, blockValue := range blockValues.Values {- blocks[blockValue.BlockID] = blockValue- }- for _, blockID := range value.Relation.BlockIDs {- if val := blocks[blockID]; nil != val {- value.Relation.Contents = append(value.Relation.Contents, val)+ blocks := blocksCache[destAv.ID]+ if nil == blocks {+ blocks = map[string]*av.Value{}+ blockValues := destAv.GetBlockKeyValues()+ if nil != blockValues {+ for _, blockValue := range blockValues.Values {+ blocks[blockValue.BlockID] = blockValue}}+ blocksCache[destAv.ID] = blocks+ }+ for _, blockID := range value.Relation.BlockIDs {+ if val := blocks[blockID]; nil != val {+ value.Relation.Contents = append(value.Relation.Contents, val)+ }}}}@@ -659,15 +664,12 @@ func fillAttributeViewKeyValues(attrView *av.AttributeView, collection av.Collec}for keyID, values := range fieldValues {keyValues, _ := attrView.GetKeyValues(keyID)+ existingIDs := map[string]bool{}+ for _, kv := range keyValues.Values {+ existingIDs[kv.ID] = true+ }for _, val := range values {- exist := false- for _, kv := range keyValues.Values {- if kv.ID == val.ID {- exist = true- break- }- }- if !exist {+ if !existingIDs[val.ID] {val.IsRenderAutoFill = truekeyValues.Values = append(keyValues.Values, val)}