Skip to content

Commit

Permalink
[fix](cluster key) improve cluster key lookup rowkey (#42470)
Browse files Browse the repository at this point in the history
the min max key in mow with cluster key tables is also the min and max
of primay keys, so when lookup rowkey, can use it to filter some
segments.
  • Loading branch information
mymeiyi authored Nov 6, 2024
1 parent 8d3ef9f commit 8c67af6
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions be/src/olap/base_tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,9 @@ Status BaseTablet::lookup_row_key(const Slice& encoded_key, TabletSchema* latest
DCHECK_EQ(segments_key_bounds.size(), num_segments);
std::vector<uint32_t> picked_segments;
for (int i = num_segments - 1; i >= 0; i--) {
// If mow table has cluster keys, the key bounds is short keys, not primary keys
// use PrimaryKeyIndexMetaPB in primary key index?
if (schema->cluster_key_idxes().empty()) {
if (key_without_seq.compare(segments_key_bounds[i].max_key()) > 0 ||
key_without_seq.compare(segments_key_bounds[i].min_key()) < 0) {
continue;
}
if (key_without_seq.compare(segments_key_bounds[i].max_key()) > 0 ||
key_without_seq.compare(segments_key_bounds[i].min_key()) < 0) {
continue;
}
picked_segments.emplace_back(i);
}
Expand Down

0 comments on commit 8c67af6

Please sign in to comment.