Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance: Skip loading pk index for sorted segment in loader
Browse files Browse the repository at this point in the history
Related to #39339
Previous PR #39389 only skips append index into segment

Also related to #39428

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
congqixia committed Jan 20, 2025
1 parent cb959cd commit 67ca4d9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/querynodev2/segments/segment.go
Original file line number Diff line number Diff line change
@@ -1021,6 +1021,19 @@ func (s *LocalSegment) LoadIndex(ctx context.Context, indexInfo *querypb.FieldIn
return err
}

// // if segment is pk sorted, user created indexes bring no performance gain but extra memory usage
if s.IsSorted() && fieldSchema.GetIsPrimaryKey() {
log.Info("skip loading index for pk field in sorted segment")
// set field index, preventing repeated loading index task
s.fieldIndexes.Insert(indexInfo.GetFieldID(), &IndexedFieldInfo{
FieldBinlog: &datapb.FieldBinlog{
FieldID: indexInfo.GetFieldID(),
},
IndexInfo: indexInfo,
IsLoaded: true,
})
}

Check warning on line 1035 in internal/querynodev2/segments/segment.go

Codecov / codecov/patch

internal/querynodev2/segments/segment.go#L1026-L1035

Added lines #L1026 - L1035 were not covered by tests

return s.innerLoadIndex(ctx, fieldSchema, indexInfo, tr, fieldType)
}

0 comments on commit 67ca4d9

Please sign in to comment.