You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/12/24 06:56:39 UTC
(doris) 02/03: [tmp] [opt](performance) Opt the null column query performance #28809
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch tpch500
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 99ff64802ed41c1fe25bd3c3e7a5cc0fcc07d9e0
Author: morningman <mo...@163.com>
AuthorDate: Fri Dec 22 21:29:41 2023 +0800
[tmp] [opt](performance) Opt the null column query performance #28809
---
be/src/exec/exec_node.cpp | 5 +++--
be/src/vec/aggregate_functions/aggregate_function_null.h | 16 ++++++++++++----
be/src/vec/columns/column_nullable.h | 2 ++
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/be/src/exec/exec_node.cpp b/be/src/exec/exec_node.cpp
index 4681218dcae..b7e891fe29e 100644
--- a/be/src/exec/exec_node.cpp
+++ b/be/src/exec/exec_node.cpp
@@ -557,10 +557,11 @@ Status ExecNode::do_projections(vectorized::Block* origin_block, vectorized::Blo
reinterpret_cast<ColumnNullable*>(mutable_columns[i].get())
->insert_range_from_not_nullable(*column_ptr, 0, rows);
} else {
- mutable_columns[i]->insert_range_from(*column_ptr, 0, rows);
+ std::swap(output_block->get_by_position(i).column,
+ origin_block->get_by_position(result_column_id).column);
}
}
- DCHECK(mutable_block.rows() == rows);
+ DCHECK(output_block->rows() == rows);
}
return Status::OK();
diff --git a/be/src/vec/aggregate_functions/aggregate_function_null.h b/be/src/vec/aggregate_functions/aggregate_function_null.h
index becb06f7cfc..026404b88c7 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_null.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_null.h
@@ -213,15 +213,23 @@ public:
void add_batch(size_t batch_size, AggregateDataPtr* places, size_t place_offset,
const IColumn** columns, Arena* arena, bool agg_many) const override {
const ColumnNullable* column = assert_cast<const ColumnNullable*>(columns[0]);
- // The overhead introduced is negligible here, just an extra memory read from NullMap
- const auto* __restrict null_map_data = column->get_null_map_data().data();
const IColumn* nested_column = &column->get_nested_column();
- for (int i = 0; i < batch_size; ++i) {
- if (!null_map_data[i]) {
+ if (column->can_skip_null_check()) {
+ for (int i = 0; i < batch_size; ++i) {
AggregateDataPtr __restrict place = places[i] + place_offset;
this->set_flag(place);
this->nested_function->add(this->nested_place(place), &nested_column, i, arena);
}
+ } else {
+ // The overhead introduced is negligible here, just an extra memory read from NullMap
+ const auto* __restrict null_map_data = column->get_null_map_data().data();
+ for (int i = 0; i < batch_size; ++i) {
+ if (!null_map_data[i]) {
+ AggregateDataPtr __restrict place = places[i] + place_offset;
+ this->set_flag(place);
+ this->nested_function->add(this->nested_place(place), &nested_column, i, arena);
+ }
+ }
}
}
diff --git a/be/src/vec/columns/column_nullable.h b/be/src/vec/columns/column_nullable.h
index 10b0951ab8b..ff2e1dbfc22 100644
--- a/be/src/vec/columns/column_nullable.h
+++ b/be/src/vec/columns/column_nullable.h
@@ -325,6 +325,8 @@ public:
/// Check that size of null map equals to size of nested column.
void check_consistency() const;
+ bool can_skip_null_check() const { return !_need_update_has_null && !_has_null; }
+
bool has_null() const override {
if (UNLIKELY(_need_update_has_null)) {
const_cast<ColumnNullable*>(this)->_update_has_null();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org