This repository has been archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bench] Reduce input cols number for fetch
To estimate output size of result query to allocate buffer we are running `count*` before some actual queries. This estimation requires only query body argumnets without `select` arguments, so this commit changes input_cols for `count*` query. Resolves: #574 Signed-off-by: Dmitrii Makarenko <[email protected]>
- Loading branch information
Showing
11 changed files
with
226 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (C) 2023 Intel Corporation | ||
* Copyright 2017 MapD Technologies, Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "RelAlgExecutionUnit.h" | ||
#include "Visitors/UsedInputsCollector.h" | ||
|
||
void RelAlgExecutionUnit::calcInputColDescs(const SchemaProvider* schema_provider) { | ||
// Scan all currently used expressions to determine used columns. | ||
UsedInputsCollector collector; | ||
for (auto& expr : simple_quals) { | ||
collector.visit(expr.get()); | ||
} | ||
for (auto& expr : quals) { | ||
collector.visit(expr.get()); | ||
} | ||
for (auto& expr : groupby_exprs) { | ||
if (expr) { | ||
collector.visit(expr.get()); | ||
} | ||
} | ||
for (auto& join_qual : join_quals) { | ||
for (auto& expr : join_qual.quals) { | ||
collector.visit(expr.get()); | ||
} | ||
} | ||
|
||
for (auto& expr : target_exprs) { | ||
collector.visit(expr); | ||
} | ||
|
||
if (partition_offsets_col) { | ||
collector.visit(partition_offsets_col.get()); | ||
} | ||
|
||
std::vector<std::shared_ptr<const InputColDescriptor>> col_descs; | ||
for (auto& col_var : collector.result()) { | ||
col_descs.push_back(std::make_shared<const InputColDescriptor>(col_var.columnInfo(), | ||
col_var.rteIdx())); | ||
} | ||
|
||
// For UNION we only have column variables for a single table used | ||
// in target expressions but should mark all columns as used. | ||
if (union_all && !col_descs.empty()) { | ||
CHECK_EQ(col_descs.front()->getNestLevel(), 0); | ||
CHECK_EQ(input_descs.size(), (size_t)2); | ||
TableRef processed_table_ref(col_descs.front()->getDatabaseId(), | ||
col_descs.front()->getTableId()); | ||
for (auto tdesc : input_descs) { | ||
if (tdesc.getTableRef() != processed_table_ref) { | ||
auto columns = schema_provider->listColumns(tdesc.getTableRef()); | ||
for (auto& col_info : columns) { | ||
if (!col_info->is_rowid) { | ||
col_descs.push_back(std::make_shared<InputColDescriptor>(col_info, 0)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
std::sort( | ||
col_descs.begin(), | ||
col_descs.end(), | ||
[](std::shared_ptr<const InputColDescriptor> const& lhs, | ||
std::shared_ptr<const InputColDescriptor> const& rhs) { | ||
return std::make_tuple(lhs->getNestLevel(), lhs->getColId(), lhs->getTableId()) < | ||
std::make_tuple(rhs->getNestLevel(), rhs->getColId(), rhs->getTableId()); | ||
}); | ||
|
||
input_col_descs.clear(); | ||
input_col_descs.insert(input_col_descs.end(), col_descs.begin(), col_descs.end()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2023 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "IR/ExprCollector.h" | ||
|
||
#include <unordered_set> | ||
|
||
struct ColumnVarHash { | ||
size_t operator()(const hdk::ir::ColumnVar& col_var) const { return col_var.hash(); } | ||
}; | ||
|
||
using ColumnVarSet = std::unordered_set<hdk::ir::ColumnVar, ColumnVarHash>; | ||
|
||
class UsedInputsCollector | ||
: public hdk::ir::ExprCollector<ColumnVarSet, UsedInputsCollector> { | ||
protected: | ||
void visitColumnRef(const hdk::ir::ColumnRef* col_ref) override { CHECK(false); } | ||
|
||
void visitColumnVar(const hdk::ir::ColumnVar* col_var) override { | ||
result_.insert(*col_var); | ||
} | ||
}; |
Oops, something went wrong.