OmniSciDB  c07336695a
JoinFilterPushDown.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef QUERYENGINE_JOINFILTERPUSHDOWN_H
18 #define QUERYENGINE_JOINFILTERPUSHDOWN_H
19 
20 #include "Execute.h"
21 #include "RangeTableIndexVisitor.h"
22 
23 #include <cstddef>
24 #include <numeric>
25 
26 extern bool g_enable_filter_push_down;
27 extern float g_filter_push_down_low_frac;
28 extern float g_filter_push_down_high_frac;
30 
40  std::vector<std::shared_ptr<Analyzer::Expr>> filter_expressions;
41  size_t input_prev;
42  size_t input_start;
43  size_t input_next;
44 };
45 
51  const bool is_valid;
52  const float fraction_passing;
53  const size_t total_rows_upper_bound;
54 
55  size_t getRowsPassingUpperBound() const {
56  return fraction_passing * total_rows_upper_bound;
57  }
58  bool isFilterSelectiveEnough() const {
59  auto low_frac_threshold = (g_filter_push_down_low_frac >= 0.0)
60  ? std::min(g_filter_push_down_low_frac, 1.0f)
61  : kFractionPassingLowThreshold;
62  auto high_frac_threshold = (g_filter_push_down_high_frac >= 0.0)
63  ? std::min(g_filter_push_down_high_frac, 1.0f)
64  : kFractionPassingHighThreshold;
65  auto rows_ubound_threshold = (g_filter_push_down_passing_row_ubound > 0)
67  : kRowsPassingUpperBoundThreshold;
68  return (fraction_passing < low_frac_threshold ||
69  (fraction_passing < high_frac_threshold &&
70  getRowsPassingUpperBound() < rows_ubound_threshold));
71  }
72 
73  static constexpr float kFractionPassingLowThreshold = 0.1;
74  static constexpr float kFractionPassingHighThreshold = 0.5;
75  static constexpr size_t kRowsPassingUpperBoundThreshold = 4000000;
76 };
77 
79  const std::vector<InputTableInfo>& table_infos);
80 
81 std::vector<PushedDownFilterInfo> find_push_down_filters(
82  const RelAlgExecutionUnit& ra_exe_unit,
83  const std::vector<size_t>& input_permutation,
84  const std::vector<size_t>& left_deep_join_input_sizes);
85 
86 #endif // QUERYENGINE_JOINFILTERPUSHDOWN_H
float g_filter_push_down_high_frac
Definition: Execute.cpp:82
std::vector< std::shared_ptr< Analyzer::Expr > > filter_expressions
bool to_gather_info_for_filter_selectivity(const std::vector< InputTableInfo > &table_infos)
float g_filter_push_down_low_frac
Definition: Execute.cpp:81
const size_t total_rows_upper_bound
std::vector< PushedDownFilterInfo > find_push_down_filters(const RelAlgExecutionUnit &ra_exe_unit, const std::vector< size_t > &input_permutation, const std::vector< size_t > &left_deep_join_input_sizes)
size_t getRowsPassingUpperBound() const
const float fraction_passing
size_t g_filter_push_down_passing_row_ubound
Definition: Execute.cpp:83
bool isFilterSelectiveEnough() const
bool g_enable_filter_push_down
Definition: Execute.cpp:80