Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
limit the scan threads if there are small parts
  • Loading branch information
sundy-li committed Feb 26, 2023
commit fcd7859a7e24e302f95d25843fc3479dded032ce
9 changes: 0 additions & 9 deletions src/query/storages/common/table-meta/src/meta/v2/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,6 @@ impl BlockMeta {
pub fn compression(&self) -> Compression {
self.compression
}

// true read_rows, maybe a range from a block
pub fn read_rows(&self, range: &Option<Range<usize>>) -> u64 {
self.col_metas
.iter()
.next()
.map(|(_, m)| m.read_rows(range))
.unwrap_or(self.row_count)
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Eq, PartialEq, EnumAsInner)]
Expand Down
12 changes: 10 additions & 2 deletions src/query/storages/fuse/src/operations/read/fuse_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,19 @@ pub fn adjust_threads_and_request(
// If the read bytes of a partition is small enough, less than 16k rows
// we will not use an extra heavy thread to process it.
// now only works for native reader
static MIN_ROWS_READ_PER_THREAD: usize = 16 * 1024;
static MIN_ROWS_READ_PER_THREAD: u64 = 16 * 1024;
if is_native {
plan.parts.partitions.iter().for_each(|part| {
if let Some(part) = part.as_any().downcast_ref::<FusePartInfo>() {
if part.nums_rows < MIN_ROWS_READ_PER_THREAD {
let to_read_rows = part
.columns_meta
.iter()
.map(|(_, meta)| meta.read_rows(&part.range))
.filter(|rows| *rows > 0)
.next()
.unwrap_or(part.nums_rows as u64);

if to_read_rows < MIN_ROWS_READ_PER_THREAD {
block_nums -= 1;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/query/storages/fuse/src/operations/read_partitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl FuseTable {
}
}

let rows_count = meta.read_rows(&range);
let rows_count = meta.row_count;
let location = meta.location.0.clone();
let format_version = meta.location.1;

Expand Down Expand Up @@ -420,7 +420,7 @@ impl FuseTable {
}
}

let rows_count = meta.read_rows(&range);
let rows_count = meta.row_count;
let location = meta.location.0.clone();
let format_version = meta.location.1;

Expand Down