Fix estimate delete row in memetable
This commit is contained in:
@ -27,6 +27,7 @@ struct ObPartitionEst
|
||||
{
|
||||
int64_t logical_row_count_;
|
||||
int64_t physical_row_count_;
|
||||
OB_INLINE bool is_invalid_memtable_result() const { return logical_row_count_ <= 0 && physical_row_count_ > 1000; }
|
||||
TO_STRING_KV(K_(logical_row_count), K_(physical_row_count));
|
||||
|
||||
ObPartitionEst();
|
||||
|
||||
@ -120,6 +120,32 @@ int ObTableEstimator::estimate_multi_scan_row_count(
|
||||
if (OB_FAIL(estimate_memtable_scan_row_count(base_input,
|
||||
static_cast<const memtable::ObMemtable*>(current_table), range, tmp_cost))) {
|
||||
LOG_WARN("failed to estimate memtable row count", K(ret), K(*current_table));
|
||||
} else if (tmp_cost.is_invalid_memtable_result()) {
|
||||
const static int64_t sub_range_cnt = 3;
|
||||
ObSEArray<ObStoreRange, sub_range_cnt> store_ranges;
|
||||
if (OB_FAIL((static_cast<memtable::ObMemtable*>(current_table))->get_split_ranges(
|
||||
&range.get_start_key().get_store_rowkey(),
|
||||
&range.get_end_key().get_store_rowkey(),
|
||||
sub_range_cnt,
|
||||
store_ranges))) {
|
||||
LOG_WARN("Failed to split ranges", K(ret));
|
||||
} else if (store_ranges.count() > 1) {
|
||||
LOG_TRACE("estimated logical row count may be not right, split range and do estimating again", K(tmp_cost), K(store_ranges));
|
||||
tmp_cost.reset();
|
||||
common::ObArenaAllocator allocator("OB_STORAGE_EST", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID());
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < store_ranges.count(); ++i) {
|
||||
ObPartitionEst sub_cost;
|
||||
ObDatumRange datum_range;
|
||||
if (OB_FAIL(datum_range.from_range(store_ranges.at(i), allocator))) {
|
||||
LOG_WARN("Failed to convert range", K(ret), K(i));
|
||||
} else if (OB_FAIL(estimate_memtable_scan_row_count(base_input,
|
||||
static_cast<const memtable::ObMemtable*>(current_table), datum_range, sub_cost))) {
|
||||
LOG_WARN("failed to estimate memtable row count", K(ret), K(*current_table));
|
||||
} else {
|
||||
tmp_cost.add(sub_cost);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
|
||||
Reference in New Issue
Block a user