fix: Skip load extra indexes for sorted segment pk field (#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 <congqi.xia@zilliz.com>
pull/39462/head
congqixia 2025-01-20 18:13:15 +08:00 committed by GitHub
parent 682b8450e5
commit 45d49df89b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -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");

View File

@ -204,6 +204,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");