MySQL 9.1.0
Source Code Documentation
sql_planner.cc File Reference

Create plan for a single select. More...

#include "sql/sql_planner.h"
#include "my_config.h"
#include <float.h>
#include <limits.h>
#include <string.h>
#include <algorithm>
#include <atomic>
#include <bit>
#include "my_base.h"
#include "my_bitmap.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_double2ulonglong.h"
#include "my_macros.h"
#include "sql/enum_query_type.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/item.h"
#include "sql/item_cmpfunc.h"
#include "sql/join_optimizer/access_path.h"
#include "sql/key.h"
#include "sql/merge_sort.h"
#include "sql/nested_join.h"
#include "sql/opt_costmodel.h"
#include "sql/opt_hints.h"
#include "sql/opt_trace.h"
#include "sql/opt_trace_context.h"
#include "sql/query_options.h"
#include "sql/query_result.h"
#include "sql/range_optimizer/path_helpers.h"
#include "sql/range_optimizer/range_optimizer.h"
#include "sql/sql_bitmap.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_opt_exec_shared.h"
#include "sql/sql_optimizer.h"
#include "sql/sql_select.h"
#include "sql/sql_test.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/window.h"
#include "sql_string.h"

Classes

class  anonymous_namespace{sql_planner.cc}::Join_tab_compare_straight
 "Less than" comparison function object used to compare two JOIN_TAB objects that are joined using STRAIGHT JOIN. More...
 
class  anonymous_namespace{sql_planner.cc}::Join_tab_compare_embedded_first
 

Namespaces

namespace  anonymous_namespace{sql_planner.cc}
 

Functions

static double prev_record_reads (JOIN *join, uint idx, table_map found_ref)
 
static void trace_plan_prefix (JOIN *join, uint idx, table_map excluded_tables)
 Helper function to write the current plan's prefix to the optimizer trace. More...
 
static uint max_part_bit (key_part_map bits)
 
static uint cache_record_length (JOIN *join, uint idx)
 
double find_cost_for_ref (const THD *thd, TABLE *table, unsigned keyno, double num_rows, double worst_seeks)
 Find the cost for a ref lookup on the given index, assumed to return “num_rows” rows. More...
 
float calculate_condition_filter (const JOIN_TAB *const tab, const Key_use *const keyuse, table_map used_tables, double fanout, bool is_join_buffering, bool write_to_trace, Opt_trace_object &parent_trace)
 Calculate 'Post read filtering' effect of JOIN::conds for table 'tab'. More...
 
static ulonglong get_bound_sj_equalities (const JOIN_TAB *tab, table_map not_available_tables)
 Returns a bitmap of bound semi-join equalities. More...
 
static int semijoin_order_allows_materialization (const JOIN *join, table_map remaining_tables, const JOIN_TAB *tab, uint idx)
 Check whether a semijoin materialization strategy is allowed for the current (semi)join table order. More...
 
void get_partial_join_cost (JOIN *join, uint n_tables, double *cost_arg, double *rowcount_arg)
 Calculate a cost of given partial join order. More...
 
static bool almost_equal (double left, double right)
 Helper function that compares two doubles and accept these as "almost equal" if they are within 10 percent of each other. More...
 

Variables

static constexpr const ha_rows MATCHING_ROWS_IN_OTHER_TABLE {10}
 Number of rows in a reference table when refereed through a not unique key. More...
 

Detailed Description

Create plan for a single select.