Skip to content

Commit

Permalink
fix: [2.5] Skip load extra indexes for sorted segment pk field (#39390)
Browse files Browse the repository at this point in the history
Cherry-pick from master
pr: #39389
Related to #39339

Extra indexes can be ignored for most cases since sorted pk column
already provided indexing features

---------

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Jan 17, 2025
1 parent bb32bda commit 0c00f94
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/core/src/segcore/ChunkedSegmentSealedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ ChunkedSegmentSealedImpl::LoadScalarIndex(const LoadIndexInfo& info) {
auto field_id = FieldId(info.field_id);
auto& field_meta = schema_->operator[](field_id);

// if segment is pk sorted, user created indexes bring no performance gain but extra memory usage
if (is_sorted_by_pk_ && field_id == schema_->get_primary_field_id()) {
LOG_INFO(
"segment pk sorted, skip user index loading for primary key field");
return;
}

auto row_count = info.index->Count();
AssertInfo(row_count > 0, "Index count is 0");

Expand Down
7 changes: 7 additions & 0 deletions internal/core/src/segcore/SegmentSealedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ SegmentSealedImpl::LoadScalarIndex(const LoadIndexInfo& info) {
auto field_id = FieldId(info.field_id);
auto& field_meta = schema_->operator[](field_id);

// if segment is pk sorted, user created indexes bring no performance gain but extra memory usage
if (is_sorted_by_pk_ && field_id == schema_->get_primary_field_id()) {
LOG_INFO(
"segment pk sorted, skip user index loading for primary key field");
return;
}

auto row_count = info.index->Count();
AssertInfo(row_count > 0, "Index count is 0");

Expand Down

0 comments on commit 0c00f94

Please sign in to comment.