OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JoinFilterPushDown.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 OmniSci, 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 #pragma once
18 
19 #include <cstddef>
20 #include <numeric>
21 
24 
25 extern bool g_enable_filter_push_down;
26 extern float g_filter_push_down_low_frac;
27 extern float g_filter_push_down_high_frac;
29 
39  std::vector<std::shared_ptr<Analyzer::Expr>> filter_expressions;
40  size_t input_prev;
41  size_t input_start;
42  size_t input_next;
43 };
44 
50  const bool is_valid;
51  const float fraction_passing;
52  const size_t total_rows_upper_bound;
53 
54  size_t getRowsPassingUpperBound() const {
56  }
57  bool isFilterSelectiveEnough() const {
58  auto low_frac_threshold = (g_filter_push_down_low_frac >= 0.0)
59  ? std::min(g_filter_push_down_low_frac, 1.0f)
61  auto high_frac_threshold = (g_filter_push_down_high_frac >= 0.0)
62  ? std::min(g_filter_push_down_high_frac, 1.0f)
64  auto rows_ubound_threshold = (g_filter_push_down_passing_row_ubound > 0)
67  return (fraction_passing < low_frac_threshold ||
68  (fraction_passing < high_frac_threshold &&
69  getRowsPassingUpperBound() < rows_ubound_threshold));
70  }
71 
72  static constexpr float kFractionPassingLowThreshold = 0.1;
73  static constexpr float kFractionPassingHighThreshold = 0.5;
74  static constexpr size_t kRowsPassingUpperBoundThreshold = 4000000;
75 };
76 
78  const std::vector<InputTableInfo>& table_infos);
79 
80 std::vector<PushedDownFilterInfo> find_push_down_filters(
81  const RelAlgExecutionUnit& ra_exe_unit,
82  const std::vector<size_t>& input_permutation,
83  const std::vector<size_t>& left_deep_join_input_sizes);
static constexpr float kFractionPassingHighThreshold
float g_filter_push_down_low_frac
Definition: Execute.cpp:83
std::vector< std::shared_ptr< Analyzer::Expr > > filter_expressions
size_t g_filter_push_down_passing_row_ubound
Definition: Execute.cpp:85
const size_t total_rows_upper_bound
bool isFilterSelectiveEnough() const
bool to_gather_info_for_filter_selectivity(const std::vector< InputTableInfo > &table_infos)
size_t getRowsPassingUpperBound() const
float g_filter_push_down_high_frac
Definition: Execute.cpp:84
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)
const float fraction_passing
bool g_enable_filter_push_down
Definition: Execute.cpp:82
static constexpr float kFractionPassingLowThreshold
static constexpr size_t kRowsPassingUpperBoundThreshold