CUBRID Engine  latest
query_planner.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <values.h>
#include "jansson.h"
#include "parser.h"
#include "object_primitive.h"
#include "optimizer.h"
#include "query_planner.h"
#include "query_graph.h"
#include "environment_variable.h"
#include "misc_string.h"
#include "system_parameter.h"
#include "parser_message.h"
#include "intl_support.h"
#include "storage_common.h"
#include "xasl_analytic.hpp"
#include "xasl_generation.h"
#include "schema_manager.h"
#include "network_interface_cl.h"
#include "dbtype.h"
#include "regu_var.hpp"

Go to the source code of this file.

Macros

#define INDENT_INCR   4
 
#define INDENT_FMT   "%*c"
 
#define TITLE_WIDTH   7
 
#define TITLE_FMT   "%-" __STR(TITLE_WIDTH) "s"
 
#define INDENTED_TITLE_FMT   INDENT_FMT TITLE_FMT
 
#define __STR(n)   __VAL(n)
 
#define __VAL(n)   #n
 
#define SORT_SPEC_FMT(spec)
 
#define VALID_INNER(plan)
 
#define FUDGE_FACTOR   0.7
 
#define ISCAN_OVERHEAD_FACTOR   1.2
 
#define TEMP_SETUP_COST   5.0
 
#define NONGROUPED_SCAN_COST   0.1
 
#define qo_scan_walk   qo_generic_walk
 
#define qo_worst_walk   qo_generic_walk
 
#define qo_generic_free   NULL
 
#define qo_sort_free   qo_generic_free
 
#define qo_follow_free   qo_generic_free
 
#define qo_worst_free   qo_generic_free
 
#define QO_INFO_INDEX(_M_offset, _bitset)   (_M_offset + (unsigned int)(BITPATTERN(_bitset) & planner->node_mask))
 
#define QO_IS_LIMIT_NODE(env, node)   (BITSET_MEMBER (QO_ENV_SORT_LIMIT_NODES ((env)), QO_NODE_IDX ((node))))
 
#define DEFAULT_NULL_SELECTIVITY   (double) 0.01
 
#define DEFAULT_EXISTS_SELECTIVITY   (double) 0.1
 
#define DEFAULT_SELECTIVITY   (double) 0.1
 
#define DEFAULT_EQUAL_SELECTIVITY   (double) 0.001
 
#define DEFAULT_EQUIJOIN_SELECTIVITY   (double) 0.001
 
#define DEFAULT_COMP_SELECTIVITY   (double) 0.1
 
#define DEFAULT_BETWEEN_SELECTIVITY   (double) 0.01
 
#define DEFAULT_IN_SELECTIVITY   (double) 0.01
 
#define DEFAULT_RANGE_SELECTIVITY   (double) 0.1
 
#define QO_PLAN_CMP_CHECK_COST(a, b)
 

Typedefs

typedef int(* QO_WALK_FUNCTION) (QO_PLAN *, void *)
 
typedef enum PRED_CLASS PRED_CLASS
 

Enumerations

enum  JOIN_ORDER_TRY { JOIN_RIGHT_ORDER, JOIN_OPPOSITE_ORDER }
 
enum  PRED_CLASS {
  PC_ATTR, PC_CONST, PC_HOST_VAR, PC_SUBQUERY,
  PC_SET, PC_OTHER, PC_MULTI_ATTR
}
 

Functions

static QO_PLANqo_scan_new (QO_INFO *, QO_NODE *, QO_SCANMETHOD)
 
static void qo_scan_free (QO_PLAN *)
 
static void qo_join_free (QO_PLAN *)
 
static void qo_scan_fprint (QO_PLAN *, FILE *, int)
 
static void qo_sort_fprint (QO_PLAN *, FILE *, int)
 
static void qo_join_fprint (QO_PLAN *, FILE *, int)
 
static void qo_follow_fprint (QO_PLAN *, FILE *, int)
 
static void qo_worst_fprint (QO_PLAN *, FILE *, int)
 
static void qo_scan_info (QO_PLAN *, FILE *, int)
 
static void qo_sort_info (QO_PLAN *, FILE *, int)
 
static void qo_join_info (QO_PLAN *, FILE *, int)
 
static void qo_follow_info (QO_PLAN *, FILE *, int)
 
static void qo_worst_info (QO_PLAN *, FILE *, int)
 
void qo_plan_lite_print (QO_PLAN *, FILE *, int)
 
static void qo_plan_del_ref_func (QO_PLAN *plan, void *ignore)
 
static void qo_generic_walk (QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)
 
static void qo_plan_print_sort_spec_helper (PT_NODE *, bool, FILE *, int)
 
static void qo_plan_print_sort_spec (QO_PLAN *, FILE *, int)
 
static void qo_plan_print_costs (QO_PLAN *, FILE *, int)
 
static void qo_plan_print_projected_segs (QO_PLAN *, FILE *, int)
 
static void qo_plan_print_sarged_terms (QO_PLAN *, FILE *, int)
 
static void qo_plan_print_outer_join_terms (QO_PLAN *, FILE *, int)
 
static void qo_plan_print_subqueries (QO_PLAN *, FILE *, int)
 
static void qo_plan_print_analytic_eval (QO_PLAN *, FILE *, int)
 
static void qo_sort_walk (QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)
 
static void qo_join_walk (QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)
 
static void qo_follow_walk (QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)
 
static void qo_plan_compute_cost (QO_PLAN *)
 
static void qo_plan_compute_subquery_cost (PT_NODE *, double *, double *)
 
static void qo_sscan_cost (QO_PLAN *)
 
static void qo_iscan_cost (QO_PLAN *)
 
static void qo_sort_cost (QO_PLAN *)
 
static void qo_mjoin_cost (QO_PLAN *)
 
static void qo_follow_cost (QO_PLAN *)
 
static void qo_worst_cost (QO_PLAN *)
 
static void qo_zero_cost (QO_PLAN *)
 
static QO_PLANqo_top_plan_new (QO_PLAN *)
 
static double log3 (double)
 
static void qo_init_planvec (QO_PLANVEC *)
 
static void qo_uninit_planvec (QO_PLANVEC *)
 
static QO_PLAN_COMPARE_RESULT qo_check_planvec (QO_PLANVEC *, QO_PLAN *)
 
static QO_PLAN_COMPARE_RESULT qo_cmp_planvec (QO_PLANVEC *, QO_PLAN *)
 
static QO_PLANqo_find_best_plan_on_planvec (QO_PLANVEC *, double)
 
static void qo_info_nodes_init (QO_ENV *)
 
static QO_INFOqo_alloc_info (QO_PLANNER *, BITSET *, BITSET *, BITSET *, double)
 
static void qo_free_info (QO_INFO *)
 
static void qo_detach_info (QO_INFO *)
 
static void qo_dump_planvec (QO_PLANVEC *, FILE *, int)
 
static void qo_dump_info (QO_INFO *, FILE *)
 
static void qo_dump_planner_info (QO_PLANNER *, QO_PARTITION *, FILE *)
 
static void planner_visit_node (QO_PLANNER *, QO_PARTITION *, PT_HINT_ENUM, QO_NODE *, QO_NODE *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *, int)
 
static double planner_nodeset_join_cost (QO_PLANNER *, BITSET *)
 
static void planner_permutate (QO_PLANNER *, QO_PARTITION *, PT_HINT_ENUM, QO_NODE *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *, int, int *)
 
static QO_PLANqo_find_best_nljoin_inner_plan_on_info (QO_PLAN *, QO_INFO *, JOIN_TYPE, int)
 
static QO_PLANqo_find_best_plan_on_info (QO_INFO *, QO_EQCLASS *, double)
 
static bool qo_check_new_best_plan_on_info (QO_INFO *, QO_PLAN *)
 
static int qo_check_plan_on_info (QO_INFO *, QO_PLAN *)
 
static int qo_examine_idx_join (QO_INFO *, JOIN_TYPE, QO_INFO *, QO_INFO *, BITSET *, BITSET *, BITSET *)
 
static int qo_examine_nl_join (QO_INFO *, JOIN_TYPE, QO_INFO *, QO_INFO *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *, int, BITSET *)
 
static int qo_examine_merge_join (QO_INFO *, JOIN_TYPE, QO_INFO *, QO_INFO *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *)
 
static int qo_examine_correlated_index (QO_INFO *, JOIN_TYPE, QO_INFO *, QO_INFO *, BITSET *, BITSET *, BITSET *)
 
static int qo_examine_follow (QO_INFO *, QO_TERM *, QO_INFO *, BITSET *, BITSET *)
 
static void qo_compute_projected_segs (QO_PLANNER *, BITSET *, BITSET *, BITSET *)
 
static int qo_compute_projected_size (QO_PLANNER *, BITSET *)
 
static QO_PLANNERqo_alloc_planner (QO_ENV *)
 
static void qo_clean_planner (QO_PLANNER *)
 
static QO_INFOqo_search_partition_join (QO_PLANNER *, QO_PARTITION *, BITSET *)
 
static QO_PLANqo_search_partition (QO_PLANNER *, QO_PARTITION *, QO_EQCLASS *, BITSET *)
 
static QO_PLANqo_search_planner (QO_PLANNER *)
 
static void sort_partitions (QO_PLANNER *)
 
static QO_PLANqo_combine_partitions (QO_PLANNER *, BITSET *)
 
static int qo_generate_join_index_scan (QO_INFO *, JOIN_TYPE, QO_PLAN *, QO_INFO *, QO_NODE *, QO_NODE_INDEX_ENTRY *, BITSET *, BITSET *, BITSET *, BITSET *)
 
static void qo_generate_seq_scan (QO_INFO *, QO_NODE *)
 
static int qo_generate_index_scan (QO_INFO *, QO_NODE *, QO_NODE_INDEX_ENTRY *, int)
 
static int qo_generate_loose_index_scan (QO_INFO *, QO_NODE *, QO_NODE_INDEX_ENTRY *)
 
static int qo_generate_sort_limit_plan (QO_ENV *, QO_INFO *, QO_PLAN *)
 
static void qo_plan_add_to_free_list (QO_PLAN *, void *ignore)
 
static void qo_nljoin_cost (QO_PLAN *)
 
static void qo_plans_teardown (QO_ENV *env)
 
static void qo_plans_init (QO_ENV *env)
 
static void qo_plan_walk (QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)
 
static QO_PLANqo_plan_finalize (QO_PLAN *)
 
static QO_PLANqo_plan_order_by (QO_PLAN *, QO_EQCLASS *)
 
static QO_PLAN_COMPARE_RESULT qo_plan_cmp_prefer_covering_index (QO_PLAN *, QO_PLAN *)
 
static void qo_plan_fprint (QO_PLAN *, FILE *, int, const char *)
 
static QO_PLAN_COMPARE_RESULT qo_plan_cmp (QO_PLAN *, QO_PLAN *)
 
static QO_PLAN_COMPARE_RESULT qo_plan_iscan_terms_cmp (QO_PLAN *a, QO_PLAN *b)
 
static QO_PLAN_COMPARE_RESULT qo_index_covering_plans_cmp (QO_PLAN *, QO_PLAN *)
 
static QO_PLAN_COMPARE_RESULT qo_order_by_skip_plans_cmp (QO_PLAN *, QO_PLAN *)
 
static QO_PLAN_COMPARE_RESULT qo_group_by_skip_plans_cmp (QO_PLAN *, QO_PLAN *)
 
static QO_PLAN_COMPARE_RESULT qo_multi_range_opt_plans_cmp (QO_PLAN *, QO_PLAN *)
 
static void qo_plan_free (QO_PLAN *)
 
static QO_PLANqo_plan_malloc (QO_ENV *)
 
static const char * qo_term_string (QO_TERM *)
 
static QO_PLANqo_worst_new (QO_ENV *)
 
static QO_PLANqo_cp_new (QO_INFO *, QO_PLAN *, QO_PLAN *, BITSET *, BITSET *)
 
static QO_PLANqo_follow_new (QO_INFO *, QO_PLAN *, QO_TERM *, BITSET *, BITSET *)
 
static QO_PLANqo_join_new (QO_INFO *, JOIN_TYPE, QO_JOINMETHOD, QO_PLAN *, QO_PLAN *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *, BITSET *)
 
static QO_PLANqo_sort_new (QO_PLAN *, QO_EQCLASS *, SORT_TYPE)
 
static QO_PLANqo_seq_scan_new (QO_INFO *, QO_NODE *)
 
static QO_PLANqo_index_scan_new (QO_INFO *, QO_NODE *, QO_NODE_INDEX_ENTRY *, QO_SCANMETHOD, BITSET *, BITSET *)
 
static int qo_has_is_not_null_term (QO_NODE *node)
 
static bool qo_validate_index_term_notnull (QO_ENV *env, QO_INDEX_ENTRY *index_entryp)
 
static bool qo_validate_index_attr_notnull (QO_ENV *env, QO_INDEX_ENTRY *index_entryp, PT_NODE *col)
 
static int qo_validate_index_for_orderby (QO_ENV *env, QO_NODE_INDEX_ENTRY *ni_entryp)
 
static int qo_validate_index_for_groupby (QO_ENV *env, QO_NODE_INDEX_ENTRY *ni_entryp)
 
static PT_NODEqo_search_isnull_key_expr (PARSER_CONTEXT *parser, PT_NODE *tree, void *arg, int *continue_walk)
 
static bool qo_check_orderby_skip_descending (QO_PLAN *plan)
 
static bool qo_check_groupby_skip_descending (QO_PLAN *plan, PT_NODE *list)
 
static PT_NODEqo_plan_compute_iscan_sort_list (QO_PLAN *root, PT_NODE *group_by, bool *is_index_w_prefix)
 
static int qo_walk_plan_tree (QO_PLAN *plan, QO_WALK_FUNCTION f, void *arg)
 
static void qo_set_use_desc (QO_PLAN *plan)
 
static int qo_set_orderby_skip (QO_PLAN *plan, void *arg)
 
static int qo_validate_indexes_for_orderby (QO_PLAN *plan, void *arg)
 
static int qo_unset_multi_range_optimization (QO_PLAN *plan, void *arg)
 
static bool qo_plan_is_orderby_skip_candidate (QO_PLAN *plan)
 
static bool qo_is_sort_limit (QO_PLAN *plan)
 
static json_t * qo_plan_scan_print_json (QO_PLAN *plan)
 
static json_t * qo_plan_sort_print_json (QO_PLAN *plan)
 
static json_t * qo_plan_join_print_json (QO_PLAN *plan)
 
static json_t * qo_plan_follow_print_json (QO_PLAN *plan)
 
static json_t * qo_plan_print_json (QO_PLAN *plan)
 
static void qo_plan_scan_print_text (FILE *fp, QO_PLAN *plan, int indent)
 
static void qo_plan_sort_print_text (FILE *fp, QO_PLAN *plan, int indent)
 
static void qo_plan_join_print_text (FILE *fp, QO_PLAN *plan, int indent)
 
static void qo_plan_follow_print_text (FILE *fp, QO_PLAN *plan, int indent)
 
static void qo_plan_print_text (FILE *fp, QO_PLAN *plan, int indent)
 
static bool qo_index_has_bit_attr (QO_INDEX_ENTRY *index_entryp)
 
static double qo_or_selectivity (QO_ENV *env, double lhs_sel, double rhs_sel)
 
static double qo_and_selectivity (QO_ENV *env, double lhs_sel, double rhs_sel)
 
static double qo_not_selectivity (QO_ENV *env, double sel)
 
static double qo_equal_selectivity (QO_ENV *env, PT_NODE *pt_expr)
 
static double qo_comp_selectivity (QO_ENV *env, PT_NODE *pt_expr)
 
static double qo_between_selectivity (QO_ENV *env, PT_NODE *pt_expr)
 
static double qo_range_selectivity (QO_ENV *env, PT_NODE *pt_expr)
 
static double qo_all_some_in_selectivity (QO_ENV *env, PT_NODE *pt_expr)
 
static PRED_CLASS qo_classify (PT_NODE *attr)
 
static int qo_index_cardinality (QO_ENV *env, PT_NODE *attr)
 
void qo_plan_discard (QO_PLAN *plan)
 
void qo_plans_stats (FILE *f)
 
void qo_plan_dump (QO_PLAN *plan, FILE *output)
 
int qo_plan_get_cost_fn (const char *plan_name)
 
const char * qo_plan_set_cost_fn (const char *plan_name, int fn)
 
void qo_set_cost (DB_OBJECT *target, DB_VALUE *result, DB_VALUE *plan, DB_VALUE *cost)
 
void qo_info_stats (FILE *f)
 
void qo_planner_free (QO_PLANNER *planner)
 
QO_PLANqo_planner_search (QO_ENV *env)
 
bool qo_is_seq_scan (QO_PLAN *plan)
 
bool qo_is_iscan (QO_PLAN *plan)
 
double qo_expr_selectivity (QO_ENV *env, PT_NODE *pt_expr)
 
bool qo_is_all_unique_index_columns_are_equi_terms (QO_PLAN *plan)
 
bool qo_is_iscan_from_orderby (QO_PLAN *plan)
 
bool qo_is_iscan_from_groupby (QO_PLAN *plan)
 
bool qo_is_interesting_order_scan (QO_PLAN *plan)
 
bool qo_has_sort_limit_subplan (QO_PLAN *plan)
 
void qo_top_plan_print_json (PARSER_CONTEXT *parser, xasl_node *xasl, PT_NODE *select, QO_PLAN *plan)
 
void qo_top_plan_print_text (PARSER_CONTEXT *parser, xasl_node *xasl, PT_NODE *select, QO_PLAN *plan)
 

Variables

static int infos_allocated = 0
 
static int infos_deallocated = 0
 
static int qo_plans_allocated
 
static int qo_plans_deallocated
 
static int qo_plans_malloced
 
static int qo_plans_demalloced
 
static int qo_accumulating_plans
 
static int qo_next_tmpfile
 
static QO_PLANqo_plan_free_list
 
static QO_PLAN_VTBL qo_seq_scan_plan_vtbl
 
static QO_PLAN_VTBL qo_index_scan_plan_vtbl
 
static QO_PLAN_VTBL qo_sort_plan_vtbl
 
static QO_PLAN_VTBL qo_nl_join_plan_vtbl
 
static QO_PLAN_VTBL qo_idx_join_plan_vtbl
 
static QO_PLAN_VTBL qo_merge_join_plan_vtbl
 
static QO_PLAN_VTBL qo_follow_plan_vtbl
 
static QO_PLAN_VTBL qo_set_follow_plan_vtbl
 
static QO_PLAN_VTBL qo_worst_plan_vtbl
 
QO_PLAN_VTBLall_vtbls []
 

Macro Definition Documentation

#define __STR (   n)    __VAL(n)

Definition at line 60 of file query_planner.c.

#define __VAL (   n)    #n

Definition at line 61 of file query_planner.c.

#define DEFAULT_BETWEEN_SELECTIVITY   (double) 0.01

Definition at line 376 of file query_planner.c.

Referenced by qo_between_selectivity(), and qo_range_selectivity().

#define DEFAULT_COMP_SELECTIVITY   (double) 0.1

Definition at line 375 of file query_planner.c.

Referenced by qo_comp_selectivity(), and qo_range_selectivity().

#define DEFAULT_EQUAL_SELECTIVITY   (double) 0.001
#define DEFAULT_EQUIJOIN_SELECTIVITY   (double) 0.001

Definition at line 374 of file query_planner.c.

Referenced by qo_equal_selectivity(), and qo_range_selectivity().

#define DEFAULT_EXISTS_SELECTIVITY   (double) 0.1

Definition at line 371 of file query_planner.c.

Referenced by qo_expr_selectivity().

#define DEFAULT_IN_SELECTIVITY   (double) 0.01

Definition at line 377 of file query_planner.c.

Referenced by qo_all_some_in_selectivity().

#define DEFAULT_NULL_SELECTIVITY   (double) 0.01

Definition at line 370 of file query_planner.c.

Referenced by qo_expr_selectivity().

#define DEFAULT_RANGE_SELECTIVITY   (double) 0.1

Definition at line 378 of file query_planner.c.

Referenced by qo_range_selectivity().

#define DEFAULT_SELECTIVITY   (double) 0.1

Definition at line 372 of file query_planner.c.

Referenced by qo_expr_selectivity(), and qo_plan_cmp().

#define FUDGE_FACTOR   0.7

Definition at line 70 of file query_planner.c.

Referenced by qo_iscan_cost().

#define INDENT_FMT   "%*c"

Definition at line 56 of file query_planner.c.

Referenced by qo_plan_fprint().

#define INDENT_INCR   4

Definition at line 55 of file query_planner.c.

Referenced by qo_follow_info(), qo_join_info(), qo_plan_fprint(), and qo_sort_info().

#define ISCAN_OVERHEAD_FACTOR   1.2

Definition at line 71 of file query_planner.c.

Referenced by qo_iscan_cost().

#define NONGROUPED_SCAN_COST   0.1

Definition at line 73 of file query_planner.c.

Referenced by qo_nljoin_cost().

#define qo_follow_free   qo_generic_free

Definition at line 80 of file query_planner.c.

#define qo_generic_free   NULL

Definition at line 78 of file query_planner.c.

#define QO_INFO_INDEX (   _M_offset,
  _bitset 
)    (_M_offset + (unsigned int)(BITPATTERN(_bitset) & planner->node_mask))

Definition at line 83 of file query_planner.c.

Referenced by planner_visit_node(), and qo_search_partition_join().

#define QO_IS_LIMIT_NODE (   env,
  node 
)    (BITSET_MEMBER (QO_ENV_SORT_LIMIT_NODES ((env)), QO_NODE_IDX ((node))))

Definition at line 86 of file query_planner.c.

Referenced by qo_search_partition_join().

#define QO_PLAN_CMP_CHECK_COST (   a,
 
)

Referenced by qo_plan_cmp().

#define qo_scan_walk   qo_generic_walk

Definition at line 75 of file query_planner.c.

#define qo_sort_free   qo_generic_free

Definition at line 79 of file query_planner.c.

#define qo_worst_free   qo_generic_free

Definition at line 81 of file query_planner.c.

#define qo_worst_walk   qo_generic_walk

Definition at line 76 of file query_planner.c.

#define SORT_SPEC_FMT (   spec)
Value:
"%d %s %s", (spec)->pos_descr.pos_no + 1, \
((spec)->s_order == S_ASC ? "asc" : "desc"), \
((spec)->s_nulls == S_NULLS_FIRST ? "nulls first" : "nulls last")

Definition at line 62 of file query_planner.c.

Referenced by qo_plan_print_analytic_eval().

#define TEMP_SETUP_COST   5.0

Definition at line 72 of file query_planner.c.

Referenced by qo_sort_cost().

#define TITLE_FMT   "%-" __STR(TITLE_WIDTH) "s"

Definition at line 58 of file query_planner.c.

Referenced by qo_plan_fprint().

#define TITLE_WIDTH   7

Definition at line 57 of file query_planner.c.

#define VALID_INNER (   plan)
Value:
(plan->well_rooted || \
(plan->plan_type == QO_PLANTYPE_SORT))

Definition at line 67 of file query_planner.c.

Referenced by qo_join_new().

Typedef Documentation

typedef enum PRED_CLASS PRED_CLASS
typedef int(* QO_WALK_FUNCTION) (QO_PLAN *, void *)

Definition at line 92 of file query_planner.c.

Enumeration Type Documentation

Enumerator
JOIN_RIGHT_ORDER 
JOIN_OPPOSITE_ORDER 

Definition at line 89 of file query_planner.c.

enum PRED_CLASS
Enumerator
PC_ATTR 
PC_CONST 
PC_HOST_VAR 
PC_SUBQUERY 
PC_SET 
PC_OTHER 
PC_MULTI_ATTR 

Definition at line 382 of file query_planner.c.

Function Documentation

static double log3 ( double  n)
static

Definition at line 419 of file query_planner.c.

Referenced by qo_sort_cost().

Here is the caller graph for this function:

static double planner_nodeset_join_cost ( QO_PLANNER planner,
BITSET nodeset 
)
static
static void planner_permutate ( QO_PLANNER planner,
QO_PARTITION partition,
PT_HINT_ENUM  hint,
QO_NODE prev_head_node,
BITSET visited_nodes,
BITSET visited_rel_nodes,
BITSET visited_terms,
BITSET first_nodes,
BITSET nested_path_nodes,
BITSET remaining_nodes,
BITSET remaining_terms,
BITSET remaining_subqueries,
int  num_path_inner,
int *  node_idxp 
)
static
static void planner_visit_node ( QO_PLANNER planner,
QO_PARTITION partition,
PT_HINT_ENUM  hint,
QO_NODE head_node,
QO_NODE tail_node,
BITSET visited_nodes,
BITSET visited_rel_nodes,
BITSET visited_terms,
BITSET nested_path_nodes,
BITSET remaining_nodes,
BITSET remaining_terms,
BITSET remaining_subqueries,
int  num_path_inner 
)
static
static double qo_and_selectivity ( QO_ENV env,
double  lhs_sel,
double  rhs_sel 
)
static

Definition at line 9207 of file query_planner.c.

References QO_ASSERT.

Referenced by qo_expr_selectivity().

Here is the caller graph for this function:

static double qo_between_selectivity ( QO_ENV env,
PT_NODE pt_expr 
)
static
static void qo_clean_planner ( QO_PLANNER planner)
static

Definition at line 8417 of file query_planner.c.

References qo_planner::all_subqueries, bitset_delset(), qo_planner::cleanup_needed, qo_planner::env, qo_planner::final_segs, and qo_plans_teardown().

Referenced by qo_planner_free(), and qo_planner_search().

Here is the caller graph for this function:

static QO_PLAN_COMPARE_RESULT qo_cmp_planvec ( QO_PLANVEC planvec,
QO_PLAN plan 
)
static

Definition at line 5085 of file query_planner.c.

References cmp, i, qo_planvec::nplans, qo_planvec::plan, PLAN_COMP_UNK, and qo_plan_cmp().

Referenced by qo_check_plan_on_info().

Here is the caller graph for this function:

static double qo_comp_selectivity ( QO_ENV env,
PT_NODE pt_expr 
)
static

Definition at line 9503 of file query_planner.c.

References DEFAULT_COMP_SELECTIVITY.

Referenced by qo_expr_selectivity().

Here is the caller graph for this function:

static void qo_compute_projected_segs ( QO_PLANNER planner,
BITSET nodes,
BITSET terms,
BITSET projected 
)
static
static int qo_compute_projected_size ( QO_PLANNER planner,
BITSET segset 
)
static

Definition at line 6213 of file query_planner.c.

References bitset_iterate(), bitset_next_member(), qo_planner::env, i, QO_ENV_SEG, and qo_seg_width().

Referenced by qo_alloc_info().

Here is the caller graph for this function:

static QO_PLAN * qo_cp_new ( QO_INFO info,
QO_PLAN outer,
QO_PLAN inner,
BITSET sarged_terms,
BITSET pinned_subqueries 
)
static

Definition at line 3381 of file query_planner.c.

References bitset_delset(), bitset_init(), qo_info::env, JOIN_INNER, qo_join_new(), and QO_JOINMETHOD_NL_JOIN.

Referenced by qo_combine_partitions().

Here is the caller graph for this function:

static void qo_detach_info ( QO_INFO info)
static

Definition at line 5282 of file query_planner.c.

References qo_info::best_no_order, qo_info::detached, qo_planner::EQ, free_and_init, i, qo_info::planner, qo_info::planvec, and qo_uninit_planvec().

Referenced by qo_combine_partitions(), qo_free_info(), and qo_search_partition().

Here is the caller graph for this function:

static void qo_dump_info ( QO_INFO info,
FILE *  f 
)
static

Definition at line 6242 of file query_planner.c.

References qo_info::best_no_order, bitset_print(), qo_planner::EQ, i, qo_planvec::nplans, qo_info::planner, qo_info::planvec, qo_info::projected_segs, and qo_dump_planvec().

Referenced by qo_dump_planner_info().

Here is the caller graph for this function:

static void qo_dump_planner_info ( QO_PLANNER planner,
QO_PARTITION partition,
FILE *  f 
)
static
static void qo_dump_planvec ( QO_PLANVEC planvec,
FILE *  f,
int  indent 
)
static

Definition at line 4857 of file query_planner.c.

References i, qo_planvec::nplans, NULL, qo_planvec::overflow, qo_planvec::plan, and qo_plan_fprint().

Referenced by qo_dump_info().

Here is the caller graph for this function:

static int qo_examine_follow ( QO_INFO info,
QO_TERM path_term,
QO_INFO head_info,
BITSET sarged_terms,
BITSET pinned_subqueries 
)
static
static int qo_examine_idx_join ( QO_INFO info,
JOIN_TYPE  join_type,
QO_INFO outer,
QO_INFO inner,
BITSET afj_terms,
BITSET sarged_terms,
BITSET pinned_subqueries 
)
static
static QO_PLAN * qo_find_best_plan_on_planvec ( QO_PLANVEC planvec,
double  n 
)
static
static void qo_follow_fprint ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static
static void qo_follow_info ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static
static void qo_follow_walk ( QO_PLAN plan,
void(*)(QO_PLAN *, void *)  child_fn,
void *  child_data,
void(*)(QO_PLAN *, void *)  parent_fn,
void *  parent_data 
)
static

Definition at line 3277 of file query_planner.c.

References qo_plan::follow, and qo_plan::plan_un.

static void qo_free_info ( QO_INFO info)
static

Definition at line 5257 of file query_planner.c.

References bitset_delset(), qo_info::eqclasses, free_and_init, infos_deallocated, qo_info::nodes, NULL, qo_info::projected_segs, qo_detach_info(), and qo_info::terms.

Referenced by qo_planner_free().

Here is the caller graph for this function:

static void qo_generate_seq_scan ( QO_INFO infop,
QO_NODE nodep 
)
static

Definition at line 7696 of file query_planner.c.

References qo_node_index_entry::n, qo_check_plan_on_info(), and qo_seq_scan_new().

Referenced by qo_search_planner().

Here is the caller graph for this function:

static int qo_generate_sort_limit_plan ( QO_ENV env,
QO_INFO infop,
QO_PLAN subplan 
)
static

Definition at line 7887 of file query_planner.c.

References qo_node_index_entry::n, NULL, qo_plan::order, qo_check_plan_on_info(), qo_sort_new(), QO_UNORDERED, and SORT_LIMIT.

Referenced by qo_search_planner().

Here is the caller graph for this function:

static void qo_generic_walk ( QO_PLAN plan,
void(*)(QO_PLAN *, void *)  child_fn,
void *  child_data,
void(*)(QO_PLAN *, void *)  parent_fn,
void *  parent_data 
)
static

Definition at line 1078 of file query_planner.c.

static QO_PLAN_COMPARE_RESULT qo_group_by_skip_plans_cmp ( QO_PLAN a,
QO_PLAN b 
)
static
static bool qo_index_has_bit_attr ( QO_INDEX_ENTRY index_entryp)
static

Definition at line 1498 of file query_planner.c.

References sm_class_constraint::attributes, qo_index_entry::col_num, qo_index_entry::constraints, DB_TYPE_BIT, DB_TYPE_VARBIT, sm_attribute::domain, and TP_DOMAIN_TYPE.

Referenced by qo_index_scan_new().

Here is the caller graph for this function:

static QO_PLAN * qo_index_scan_new ( QO_INFO info,
QO_NODE node,
QO_NODE_INDEX_ENTRY ni_entry,
QO_SCANMETHOD  scan_method,
BITSET range_terms,
BITSET indexable_terms 
)
static

Definition at line 1527 of file query_planner.c.

References assert, bitset_add(), bitset_assign(), bitset_delset(), bitset_difference(), bitset_init(), bitset_intersect(), bitset_intersects(), bitset_is_empty(), bitset_iterate(), BITSET_MEMBER, bitset_next_member(), bitset_subset(), bitset_union(), qo_term::can_use_index, qo_index_entry::constraints, qo_index_entry::cover_segments, qo_info::env, qo_index_entry::force, sm_class_constraint::func_index_info, qo_node_index_entry::head, qo_index_entry::ils_prefix_len, qo_index_entry::is_iss_candidate, qo_plan::iscan_sort_list, qo_index_entry::multi_col_range_segs, qo_plan::multi_range_opt_use, qo_index_entry::nsegs, NULL, PLAN_MULTI_RANGE_OPT_USE, qo_plan::plan_un, qo_check_iscan_for_multi_range_opt(), QO_ENV_TERM, qo_index_has_bit_attr(), qo_index_scan_plan_vtbl, qo_is_filter_index(), qo_is_index_covering_scan(), qo_is_index_loose_scan(), qo_is_iscan(), qo_is_iscan_from_groupby(), qo_is_iscan_from_orderby(), qo_is_prefix_index(), QO_NODE_SEGS, qo_plan_compute_cost(), qo_plan_compute_iscan_sort_list(), qo_plan_release, qo_scan_new(), QO_SCANMETHOD_INDEX_GROUPBY_SCAN, QO_SCANMETHOD_INDEX_ORDERBY_SCAN, QO_SCANMETHOD_INDEX_SCAN, QO_SCANMETHOD_INDEX_SCAN_INSPECT, QO_TERM_EQUAL_OP, QO_TERM_IS_FLAGED, QO_TERM_NON_IDX_SARG_COLL, QO_TERM_SEGS, QO_TERM_SUBQUERIES, qo_top_plan_new(), qo_plan::sarged_terms, qo_plan::scan, qo_index_entry::seg_idxs, and qo_plan::vtbl.

Referenced by qo_generate_index_scan(), qo_generate_join_index_scan(), qo_generate_loose_index_scan(), and qo_search_planner().

Here is the caller graph for this function:

static void qo_info_nodes_init ( QO_ENV env)
static

Definition at line 5164 of file query_planner.c.

References infos_allocated, and infos_deallocated.

Referenced by qo_planner_search().

Here is the caller graph for this function:

void qo_info_stats ( FILE *  f)

Definition at line 6286 of file query_planner.c.

References infos_allocated, and infos_deallocated.

Referenced by qo_print_stats().

Here is the caller graph for this function:

static void qo_init_planvec ( QO_PLANVEC planvec)
static

Definition at line 4817 of file query_planner.c.

References i, NPLANS, qo_planvec::nplans, NULL, qo_planvec::overflow, and qo_planvec::plan.

Referenced by qo_alloc_info().

Here is the caller graph for this function:

bool qo_is_all_unique_index_columns_are_equi_terms ( QO_PLAN plan)

Definition at line 9883 of file query_planner.c.

References qo_plan::plan_un, qo_is_iscan(), and qo_plan::scan.

Referenced by qo_plan_cmp().

Here is the caller graph for this function:

bool qo_is_seq_scan ( QO_PLAN plan)

Definition at line 7679 of file query_planner.c.

References qo_plan::plan_type, qo_plan::plan_un, QO_PLANTYPE_SCAN, QO_SCANMETHOD_SEQ_SCAN, and qo_plan::scan.

Referenced by gen_outer(), qo_find_best_nljoin_inner_plan_on_info(), qo_nljoin_cost(), and qo_plan_cmp().

Here is the caller graph for this function:

static bool qo_is_sort_limit ( QO_PLAN plan)
static

Definition at line 11125 of file query_planner.c.

References NULL, qo_plan::plan_type, qo_plan::plan_un, QO_PLANTYPE_SORT, qo_plan::sort, and SORT_LIMIT.

Referenced by qo_plan_cmp().

Here is the caller graph for this function:

static void qo_join_free ( QO_PLAN plan)
static

Definition at line 2836 of file query_planner.c.

References bitset_delset(), qo_plan::join, and qo_plan::plan_un.

static void qo_join_info ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static
static QO_PLAN * qo_join_new ( QO_INFO info,
JOIN_TYPE  join_type,
QO_JOINMETHOD  join_method,
QO_PLAN outer,
QO_PLAN inner,
BITSET join_terms,
BITSET duj_terms,
BITSET afj_terms,
BITSET sarged_terms,
BITSET pinned_subqueries,
BITSET hash_terms 
)
static

Definition at line 2605 of file query_planner.c.

References qo_plan::analytic_eval_list, assert, bitset_assign(), bitset_delset(), bitset_difference(), bitset_first_member(), bitset_init(), bitset_intersects(), bitset_is_equivalent(), bitset_union(), pt_spec_info::derived_table_type, qo_info::env, pt_spec_info::flat_entity_list, qo_plan::has_sort_limit, qo_plan::info, parser_node::info, IS_OUTER_JOIN_TYPE, qo_plan::iscan_sort_list, qo_plan::join, JOIN_CSELECT, qo_plan::multi_range_opt_use, qo_info::nodes, NULL, qo_plan::order, PLAN_MULTI_RANGE_OPT_NO, PLAN_MULTI_RANGE_OPT_USE, qo_plan::plan_type, qo_plan::plan_un, PT_IS_CSELECT, QO_ASSERT, qo_check_join_for_multi_range_opt(), QO_ENV_NODE, QO_ENV_USE_SORT_LIMIT, QO_EQCLASS_SEGS, qo_idx_join_plan_vtbl, QO_JOINMETHOD_IDX_JOIN, QO_JOINMETHOD_MERGE_JOIN, QO_JOINMETHOD_NL_JOIN, qo_merge_join_plan_vtbl, qo_nl_join_plan_vtbl, QO_NODE_ENTITY_SPEC, QO_NODE_IS_CLASS_HIERARCHY, qo_plan_add_ref, qo_plan_compute_cost(), qo_plan_compute_iscan_sort_list(), qo_plan_is_orderby_skip_candidate(), qo_plan_malloc(), QO_PLANTYPE_JOIN, QO_PLANTYPE_SCAN, QO_PLANTYPE_SORT, qo_sort_new(), qo_top_plan_new(), QO_UNORDERED, qo_plan::refcount, qo_plan::sarged_terms, qo_plan::scan, SORT_LIMIT, qo_env::sort_limit_nodes, SORT_TEMP, pt_statement_info::spec, qo_plan::subqueries, qo_plan::top_rooted, VALID_INNER, qo_plan::vtbl, and qo_plan::well_rooted.

Referenced by qo_cp_new(), qo_examine_merge_join(), qo_examine_nl_join(), and qo_generate_join_index_scan().

Here is the caller graph for this function:

static void qo_join_walk ( QO_PLAN plan,
void(*)(QO_PLAN *, void *)  child_fn,
void *  child_data,
void(*)(QO_PLAN *, void *)  parent_fn,
void *  parent_data 
)
static

Definition at line 2853 of file query_planner.c.

References qo_plan::join, and qo_plan::plan_un.

static double qo_not_selectivity ( QO_ENV env,
double  sel 
)
static

Definition at line 9228 of file query_planner.c.

References QO_ASSERT.

Referenced by qo_expr_selectivity().

Here is the caller graph for this function:

static double qo_or_selectivity ( QO_ENV env,
double  lhs_sel,
double  rhs_sel 
)
static

Definition at line 9185 of file query_planner.c.

References QO_ASSERT.

Referenced by qo_expr_selectivity(), and qo_range_selectivity().

Here is the caller graph for this function:

static QO_PLAN_COMPARE_RESULT qo_order_by_skip_plans_cmp ( QO_PLAN a,
QO_PLAN b 
)
static
static void qo_plan_add_to_free_list ( QO_PLAN plan,
void *  ignore 
)
static
static QO_PLAN_COMPARE_RESULT qo_plan_cmp ( QO_PLAN a,
QO_PLAN b 
)
static
static QO_PLAN_COMPARE_RESULT qo_plan_cmp_prefer_covering_index ( QO_PLAN scan_plan_p,
QO_PLAN sort_plan_p 
)
static
static PT_NODE * qo_plan_compute_iscan_sort_list ( QO_PLAN root,
PT_NODE group_by,
bool is_index_w_prefix 
)
static

Definition at line 10751 of file query_planner.c.

References pt_expr_info::arg1, pt_expr_info::arg2, pt_sort_spec_info::asc_or_desc, assert, bitset_cardinality(), bitset_iterate(), bitset_next_member(), qo_index_entry::constraints, DB_TYPE_MIDXKEY, pt_sort_spec_info::expr, pt_statement_info::expr, sm_function_info::fi_domain, parser_node::flag, qo_plan::follow, sm_class_constraint::func_index_info, pt_select_info::group_by, qo_node_index_entry::head, i, qo_index_entry::ils_prefix_len, qo_plan::info, parser_node::info, tp_domain::is_desc, qo_plan::join, qo_index_entry::key_type, pt_select_info::list, MSGCAT_SEMANTIC_OUT_OF_MEMORY, MSGCAT_SET_PARSER_SEMANTIC, tp_domain::next, parser_node::next, parser_node::node_type, qo_index_entry::nsegs, NULL, parser, parser_append_node(), parser_new_node(), qo_plan::plan_type, qo_plan::plan_un, pt_sort_spec_info::pos_descr, qfile_tuple_value_position::pos_no, PT_ASC, PT_DESC, PT_DOT_, PT_EQ, PT_ERRORm, pt_get_end_path_node(), PT_IS_CONST, PT_IS_EXPR_NODE_WITH_OPERATOR, PT_NAME, PT_NAME_INFO_CONSTANT, PT_NAME_INFO_IS_FLAGED, pt_point(), PT_SORT_SPEC, pt_to_pos_descr(), pt_to_pos_descr_groupby(), pt_query_info::q, QO_ENTRY_MULTI_COL, QO_ENV_PARSER, QO_ENV_PT_TREE, QO_ENV_SEG, QO_ENV_TERM, qo_is_index_iss_scan(), qo_is_interesting_order_scan(), qo_is_prefix_index(), QO_JOINMETHOD_IDX_JOIN, QO_JOINMETHOD_NL_JOIN, QO_NODE_INFO, QO_NODE_IS_CLASS_HIERARCHY, QO_PLANTYPE_FOLLOW, QO_PLANTYPE_JOIN, QO_PLANTYPE_SCAN, QO_PLANTYPE_SORT, QO_SEG_FUNC_INDEX, QO_SEG_INDEX_TERMS, QO_SEG_PT_NODE, QO_TERM_PT_EXPR, pt_statement_info::query, qo_index_entry::rangelist_seg_idx, qo_plan::scan, qo_index_entry::seg_idxs, pt_query_info::select, tp_domain::setdomain, SM_IS_CONSTRAINT_REVERSE_INDEX_FAMILY, qo_plan::sort, SORT_LIMIT, pt_statement_info::sort_spec, TP_DOMAIN_TYPE, sm_class_constraint::type, and parser_node::with_rollup.

Referenced by qo_index_scan_new(), qo_join_new(), qo_plan_is_orderby_skip_candidate(), and qo_top_plan_new().

Here is the caller graph for this function:

static void qo_plan_del_ref_func ( QO_PLAN plan,
void *  ignore 
)
static

Definition at line 4503 of file query_planner.c.

References qo_plan_del_ref.

Referenced by qo_plan_free().

Here is the caller graph for this function:

void qo_plan_discard ( QO_PLAN plan)

Definition at line 4456 of file query_planner.c.

References qo_env::dump_enable, qo_plan::info, qo_env_free(), qo_plan_del_ref, and qo_print_stats().

Referenced by pt_plan_query(), pt_plan_single_table_hq_iterations(), and qo_combine_partitions().

Here is the caller graph for this function:

void qo_plan_dump ( QO_PLAN plan,
FILE *  output 
)

Definition at line 4621 of file query_planner.c.

References DETAILED_DUMP, NULL, qo_get_optimization_param(), QO_PARAM_LEVEL, qo_plan_fprint(), qo_plan_lite_print(), and SIMPLE_DUMP.

Referenced by pt_plan_query(), and pt_plan_single_table_hq_iterations().

Here is the caller graph for this function:

static QO_PLAN * qo_plan_finalize ( QO_PLAN plan)
static

Definition at line 4444 of file query_planner.c.

References qo_plan_add_ref.

Referenced by qo_combine_partitions(), and qo_search_partition().

Here is the caller graph for this function:

static json_t * qo_plan_follow_print_json ( QO_PLAN plan)
static

Definition at line 11389 of file query_planner.c.

References qo_plan::follow, qo_node_index_entry::head, qo_plan::plan_un, qo_plan_print_json(), and qo_term_string().

Referenced by qo_plan_print_json().

Here is the caller graph for this function:

static void qo_plan_follow_print_text ( FILE *  fp,
QO_PLAN plan,
int  indent 
)
static

Definition at line 11697 of file query_planner.c.

References qo_plan::follow, qo_plan::plan_un, qo_plan_print_text(), and qo_term_string().

Referenced by qo_plan_print_text().

Here is the caller graph for this function:

static void qo_plan_fprint ( QO_PLAN plan,
FILE *  f,
int  howfar,
const char *  title 
)
static
static void qo_plan_free ( QO_PLAN plan)
static
int qo_plan_get_cost_fn ( const char *  plan_name)

Definition at line 4661 of file query_planner.c.

References i, intl_mbs_ncasecmp(), qo_node_index_entry::n, qo_worst_cost(), qo_zero_cost(), and strlen.

Referenced by csql_get_sys_param(), and qo_get_optimization_param().

Here is the caller graph for this function:

static json_t * qo_plan_join_print_json ( QO_PLAN plan)
static
static void qo_plan_join_print_text ( FILE *  fp,
QO_PLAN plan,
int  indent 
)
static
void qo_plan_lite_print ( QO_PLAN plan,
FILE *  f,
int  howfar 
)

Definition at line 4432 of file query_planner.c.

References qo_plan::vtbl.

Referenced by pt_plan_query(), qo_follow_info(), qo_join_info(), qo_plan_dump(), and qo_sort_info().

Here is the caller graph for this function:

static QO_PLAN * qo_plan_order_by ( QO_PLAN plan,
QO_EQCLASS order 
)
static

Definition at line 3496 of file query_planner.c.

References BITSET_MEMBER, qo_plan::info, NULL, qo_plan::order, QO_EQCLASS_IDX, qo_sort_new(), QO_UNORDERED, and SORT_TEMP.

Referenced by qo_check_new_best_plan_on_info().

Here is the caller graph for this function:

static void qo_plan_print_costs ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static

Definition at line 1198 of file query_planner.c.

References qo_plan::fixed_cpu_cost, qo_plan::fixed_io_cost, INDENTED_TITLE_FMT, qo_plan::info, qo_plan::variable_cpu_cost, and qo_plan::variable_io_cost.

Referenced by qo_plan_fprint().

Here is the caller graph for this function:

static void qo_plan_print_outer_join_terms ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static

Definition at line 1262 of file query_planner.c.

References bitset_is_empty(), INDENTED_TITLE_FMT, qo_plan::info, qo_plan::join, qo_plan::plan_un, and qo_termset_fprint().

Referenced by qo_join_fprint().

Here is the caller graph for this function:

static void qo_plan_print_projected_segs ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static

Definition at line 1216 of file query_planner.c.

References bitset_iterate(), bitset_next_member(), INDENTED_TITLE_FMT, qo_plan::info, and qo_seg_fprint().

Referenced by qo_plan_fprint().

Here is the caller graph for this function:

static void qo_plan_print_sarged_terms ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static

Definition at line 1245 of file query_planner.c.

References bitset_is_empty(), INDENTED_TITLE_FMT, qo_plan::info, qo_termset_fprint(), and qo_plan::sarged_terms.

Referenced by qo_plan_fprint().

Here is the caller graph for this function:

static void qo_plan_print_subqueries ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static

Definition at line 1285 of file query_planner.c.

References bitset_is_empty(), bitset_print(), INDENTED_TITLE_FMT, and qo_plan::subqueries.

Referenced by qo_plan_fprint().

Here is the caller graph for this function:

static void qo_plan_print_text ( FILE *  fp,
QO_PLAN plan,
int  indent 
)
static
const char* qo_plan_set_cost_fn ( const char *  plan_name,
int  fn 
)
static json_t * qo_plan_sort_print_json ( QO_PLAN plan)
static

Definition at line 11264 of file query_planner.c.

References assert, NULL, qo_plan::plan_un, qo_plan_print_json(), qo_plan::sort, SORT_DISTINCT, SORT_GROUPBY, SORT_LIMIT, SORT_ORDERBY, and SORT_TEMP.

Referenced by qo_plan_print_json().

Here is the caller graph for this function:

static void qo_plan_sort_print_text ( FILE *  fp,
QO_PLAN plan,
int  indent 
)
static

Definition at line 11579 of file query_planner.c.

References assert, qo_plan::plan_un, qo_plan_print_text(), qo_plan::sort, SORT_DISTINCT, SORT_GROUPBY, SORT_LIMIT, SORT_ORDERBY, and SORT_TEMP.

Referenced by qo_plan_print_text().

Here is the caller graph for this function:

static void qo_plan_walk ( QO_PLAN plan,
void(*)(QO_PLAN *, void *)  child_fn,
void *  child_data,
void(*)(QO_PLAN *, void *)  parent_fn,
void *  parent_data 
)
static

Definition at line 4491 of file query_planner.c.

References qo_plan::vtbl.

Referenced by qo_plan_free().

Here is the caller graph for this function:

void qo_planner_free ( QO_PLANNER planner)
QO_PLAN* qo_planner_search ( QO_ENV env)

Definition at line 7451 of file query_planner.c.

References NULL, qo_alloc_planner(), qo_clean_planner(), qo_info_nodes_init(), qo_plans_init(), and qo_search_planner().

Referenced by qo_optimize_helper().

Here is the caller graph for this function:

static void qo_plans_init ( QO_ENV env)
static

Definition at line 4568 of file query_planner.c.

References NULL, qo_accumulating_plans, qo_next_tmpfile, qo_plans_allocated, qo_plans_deallocated, qo_plans_demalloced, and qo_plans_malloced.

Referenced by qo_planner_search().

Here is the caller graph for this function:

void qo_plans_stats ( FILE *  f)

Definition at line 4607 of file query_planner.c.

References qo_plans_allocated, qo_plans_deallocated, qo_plans_demalloced, and qo_plans_malloced.

Referenced by qo_print_stats().

Here is the caller graph for this function:

static void qo_plans_teardown ( QO_ENV env)
static

Definition at line 4585 of file query_planner.c.

References qo_plan::free, free_and_init, qo_plan::plan_un, qo_accumulating_plans, qo_plan_free_list, and qo_plans_demalloced.

Referenced by qo_clean_planner().

Here is the caller graph for this function:

static void qo_scan_free ( QO_PLAN plan)
static

Definition at line 1423 of file query_planner.c.

References bitset_delset(), qo_plan::plan_un, and qo_plan::scan.

static PT_NODE * qo_search_isnull_key_expr ( PARSER_CONTEXT parser,
PT_NODE tree,
void *  arg,
int *  continue_walk 
)
static
static QO_PLAN * qo_search_planner ( QO_PLANNER planner)
static

Definition at line 7978 of file query_planner.c.

References qo_planner::all_subqueries, ARG_FILE_LINE, pt_sort_spec_info::asc_or_desc, assert, bitset_add(), bitset_assign(), BITSET_CLEAR, bitset_delset(), bitset_init(), bitset_intersect(), bitset_is_empty(), bitset_iterate(), bitset_next_member(), bitset_remove(), bitset_subset(), bitset_union(), pt_select_info::connect_by, qo_index_entry::constraints, qo_planner::cp_info, qo_info::env, qo_planner::env, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), sm_class_constraint::filter_predicate, parser_node::flag, qo_index_entry::force, pt_select_info::group_by, qo_index_entry::groupby_skip, qo_node_index_entry::head, pt_select_info::hint, i, qo_index_entry::ils_prefix_len, qo_plan::info, parser_node::info, qo_index_entry::is_iss_candidate, qo_planner::join_info, qo_planner::M, qo_env::multi_range_opt_candidate, qo_plan::multi_range_opt_use, qo_node_index_entry::n, qo_planner::N, qo_planner::node, qo_planner::node_info, qo_subquery::nodes, qo_index_entry::nsegs, NULL, pt_query_info::order_by, qo_index_entry::orderby_skip, qo_planner::P, qo_planner::partition, qo_partition::plan, PLAN_MULTI_RANGE_OPT_CAN_USE, qo_plan::plan_type, qo_plan::plan_un, PT_ASC, PT_HINT_USE_IDX_DESC, PT_SPEC_SPECIAL_INDEX_SCAN, qo_env::pt_tree, pt_query_info::q, qo_alloc_info(), qo_check_plan_on_info(), qo_combine_partitions(), QO_ENV_PT_TREE, QO_ENV_USE_SORT_LIMIT, qo_find_best_plan_on_info(), qo_generate_index_scan(), qo_generate_loose_index_scan(), qo_generate_seq_scan(), qo_generate_sort_limit_plan(), qo_index_scan_new(), QO_INFINITY, qo_is_index_mro_scan(), qo_is_interesting_order_scan(), qo_is_iscan_from_groupby(), qo_is_iscan_from_orderby(), qo_is_prefix_index(), QO_JOIN_INFO_SIZE, QO_NI_ENTRY, QO_NI_N, QO_NODE_ENTITY_SPEC, QO_NODE_EQCLASSES, QO_NODE_IDX, QO_NODE_INDEXES, QO_NODE_NCARD, QO_NODE_SARGS, QO_NODE_SELECTIVITY, QO_NODE_SORT_LIMIT_CANDIDATE, QO_NODE_SUBQUERIES, QO_PARTITION_M_OFFSET, qo_plan_add_ref, qo_plan_del_ref, qo_plan_multi_range_opt(), QO_PLANTYPE_SCAN, QO_SCANMETHOD_INDEX_GROUPBY_SCAN, QO_SCANMETHOD_INDEX_ORDERBY_SCAN, QO_SCANMETHOD_INDEX_SCAN, QO_SCANMETHOD_INDEX_SCAN_INSPECT, qo_search_partition(), qo_set_use_desc(), QO_UNORDERED, qo_unset_multi_range_optimization(), qo_validate_index_for_groupby(), qo_validate_index_for_orderby(), qo_walk_plan_tree(), qo_worst_new(), pt_statement_info::query, qo_plan::scan, qo_index_entry::seg_equal_terms, qo_index_entry::seg_other_terms, pt_query_info::select, pt_statement_info::sort_spec, qo_planner::subqueries, qo_subquery::terms, qo_plan::use_iscan_descending, parser_node::with_rollup, qo_planner::worst_info, and qo_planner::worst_plan.

Referenced by qo_planner_search().

Here is the caller graph for this function:

static QO_PLAN * qo_seq_scan_new ( QO_INFO info,
QO_NODE node 
)
static
static int qo_set_orderby_skip ( QO_PLAN plan,
void *  arg 
)
static

Definition at line 812 of file query_planner.c.

References NO_ERROR, qo_plan::plan_un, qo_is_iscan(), qo_is_iscan_from_orderby(), and qo_plan::scan.

Referenced by qo_top_plan_new().

Here is the caller graph for this function:

static void qo_set_use_desc ( QO_PLAN plan)
static
static void qo_sort_fprint ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static
static void qo_sort_walk ( QO_PLAN plan,
void(*)(QO_PLAN *, void *)  child_fn,
void *  child_data,
void(*)(QO_PLAN *, void *)  parent_fn,
void *  parent_data 
)
static

Definition at line 2378 of file query_planner.c.

References qo_plan::plan_un, and qo_plan::sort.

static QO_PLAN * qo_top_plan_new ( QO_PLAN plan)
static
static void qo_uninit_planvec ( QO_PLANVEC planvec)
static

Definition at line 4836 of file query_planner.c.

References i, qo_planvec::nplans, qo_planvec::overflow, qo_planvec::plan, and qo_plan_del_ref.

Referenced by qo_detach_info().

Here is the caller graph for this function:

static int qo_validate_index_for_groupby ( QO_ENV env,
QO_NODE_INDEX_ENTRY ni_entryp 
)
static
static int qo_validate_indexes_for_orderby ( QO_PLAN plan,
void *  arg 
)
static

Definition at line 832 of file query_planner.c.

References qo_info::env, ER_FAILED, qo_plan::info, NO_ERROR, qo_plan::plan_un, qo_is_iscan_from_orderby(), qo_validate_index_for_orderby(), and qo_plan::scan.

Referenced by qo_top_plan_new().

Here is the caller graph for this function:

static int qo_walk_plan_tree ( QO_PLAN plan,
QO_WALK_FUNCTION  f,
void *  arg 
)
static
static void qo_worst_fprint ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static

Definition at line 3441 of file query_planner.c.

static void qo_worst_info ( QO_PLAN plan,
FILE *  f,
int  howfar 
)
static

Definition at line 3453 of file query_planner.c.

References qo_plan::vtbl.

static void qo_zero_cost ( QO_PLAN planp)
static

Definition at line 3480 of file query_planner.c.

References qo_plan::fixed_cpu_cost, qo_plan::fixed_io_cost, qo_plan::variable_cpu_cost, and qo_plan::variable_io_cost.

Referenced by qo_iscan_cost(), qo_plan_get_cost_fn(), and qo_plan_set_cost_fn().

Here is the caller graph for this function:

static void sort_partitions ( QO_PLANNER planner)
static

Definition at line 8878 of file query_planner.c.

References bitset_intersects(), i, qo_planner::P, qo_planner::partition, QO_PARTITION_DEPENDENCIES, and QO_PARTITION_NODES.

Referenced by qo_combine_partitions().

Here is the caller graph for this function:

Variable Documentation

QO_PLAN_VTBL* all_vtbls[]
Initial value:
= {
}
static QO_PLAN_VTBL qo_worst_plan_vtbl
static QO_PLAN_VTBL qo_follow_plan_vtbl
static QO_PLAN_VTBL qo_set_follow_plan_vtbl
static QO_PLAN_VTBL qo_index_scan_plan_vtbl
static QO_PLAN_VTBL qo_nl_join_plan_vtbl
static QO_PLAN_VTBL qo_seq_scan_plan_vtbl
static QO_PLAN_VTBL qo_merge_join_plan_vtbl
static QO_PLAN_VTBL qo_sort_plan_vtbl
static QO_PLAN_VTBL qo_idx_join_plan_vtbl

Definition at line 358 of file query_planner.c.

int infos_allocated = 0
static

Definition at line 94 of file query_planner.c.

Referenced by qo_alloc_info(), qo_info_nodes_init(), and qo_info_stats().

int infos_deallocated = 0
static

Definition at line 95 of file query_planner.c.

Referenced by qo_free_info(), qo_info_nodes_init(), and qo_info_stats().

int qo_accumulating_plans
static

Definition at line 101 of file query_planner.c.

Referenced by qo_plan_add_to_free_list(), qo_plans_init(), and qo_plans_teardown().

QO_PLAN_VTBL qo_follow_plan_vtbl
static
Initial value:
= {
"follow",
"Object fetch"
}
static void qo_follow_info(QO_PLAN *, FILE *, int)
static void qo_follow_fprint(QO_PLAN *, FILE *, int)
static void qo_follow_cost(QO_PLAN *)
#define qo_follow_free
Definition: query_planner.c:80
static void qo_follow_walk(QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)

Definition at line 325 of file query_planner.c.

Referenced by qo_follow_new().

QO_PLAN_VTBL qo_idx_join_plan_vtbl
static
Initial value:
= {
"idx-join",
"Correlated-index join"
}
static void qo_join_walk(QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)
static void qo_join_info(QO_PLAN *, FILE *, int)
static void qo_nljoin_cost(QO_PLAN *)
static void qo_join_fprint(QO_PLAN *, FILE *, int)
static void qo_join_free(QO_PLAN *)

Definition at line 303 of file query_planner.c.

Referenced by qo_join_new().

QO_PLAN_VTBL qo_index_scan_plan_vtbl
static
Initial value:
= {
"iscan",
"Index scan"
}
static void qo_scan_info(QO_PLAN *, FILE *, int)
static void qo_iscan_cost(QO_PLAN *)
#define qo_scan_walk
Definition: query_planner.c:75
static void qo_scan_free(QO_PLAN *)
static void qo_scan_fprint(QO_PLAN *, FILE *, int)

Definition at line 270 of file query_planner.c.

Referenced by qo_index_scan_new().

QO_PLAN_VTBL qo_merge_join_plan_vtbl
static
Initial value:
= {
"m-join",
"Merge join"
}
static void qo_join_walk(QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)
static void qo_join_info(QO_PLAN *, FILE *, int)
static void qo_join_fprint(QO_PLAN *, FILE *, int)
static void qo_mjoin_cost(QO_PLAN *)
static void qo_join_free(QO_PLAN *)

Definition at line 314 of file query_planner.c.

Referenced by qo_join_new().

int qo_next_tmpfile
static

Definition at line 102 of file query_planner.c.

Referenced by qo_plans_init().

QO_PLAN_VTBL qo_nl_join_plan_vtbl
static
Initial value:
= {
"nl-join",
"Nested-loop join"
}
static void qo_join_walk(QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)
static void qo_join_info(QO_PLAN *, FILE *, int)
static void qo_nljoin_cost(QO_PLAN *)
static void qo_join_fprint(QO_PLAN *, FILE *, int)
static void qo_join_free(QO_PLAN *)

Definition at line 292 of file query_planner.c.

Referenced by qo_join_new().

QO_PLAN* qo_plan_free_list
static

Definition at line 104 of file query_planner.c.

Referenced by qo_plan_add_to_free_list(), qo_plan_malloc(), and qo_plans_teardown().

int qo_plans_allocated
static

Definition at line 97 of file query_planner.c.

Referenced by qo_plan_malloc(), qo_plans_init(), and qo_plans_stats().

int qo_plans_deallocated
static

Definition at line 98 of file query_planner.c.

Referenced by qo_plan_add_to_free_list(), qo_plans_init(), and qo_plans_stats().

int qo_plans_demalloced
static
int qo_plans_malloced
static

Definition at line 99 of file query_planner.c.

Referenced by qo_plan_malloc(), qo_plans_init(), and qo_plans_stats().

QO_PLAN_VTBL qo_seq_scan_plan_vtbl
static
Initial value:
= {
"sscan",
"Sequential scan"
}
static void qo_scan_info(QO_PLAN *, FILE *, int)
#define qo_scan_walk
Definition: query_planner.c:75
static void qo_scan_free(QO_PLAN *)
static void qo_scan_fprint(QO_PLAN *, FILE *, int)
static void qo_sscan_cost(QO_PLAN *)

Definition at line 259 of file query_planner.c.

Referenced by qo_seq_scan_new().

QO_PLAN_VTBL qo_set_follow_plan_vtbl
static
Initial value:
= {
"set_follow",
"Set fetch"
}
static void qo_follow_info(QO_PLAN *, FILE *, int)
static void qo_follow_fprint(QO_PLAN *, FILE *, int)
static void qo_follow_cost(QO_PLAN *)
#define qo_follow_free
Definition: query_planner.c:80
static void qo_follow_walk(QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)

Definition at line 336 of file query_planner.c.

QO_PLAN_VTBL qo_sort_plan_vtbl
static
Initial value:
= {
"temp",
"Sort"
}
static void qo_sort_walk(QO_PLAN *, void(*)(QO_PLAN *, void *), void *, void(*)(QO_PLAN *, void *), void *)
#define qo_sort_free
Definition: query_planner.c:79
static void qo_sort_fprint(QO_PLAN *, FILE *, int)
static void qo_sort_info(QO_PLAN *, FILE *, int)
static void qo_sort_cost(QO_PLAN *)

Definition at line 281 of file query_planner.c.

Referenced by qo_sort_new().

QO_PLAN_VTBL qo_worst_plan_vtbl
static
Initial value:
= {
"worst",
"Bogus"
}
static void qo_worst_cost(QO_PLAN *)
static void qo_worst_info(QO_PLAN *, FILE *, int)
#define qo_worst_walk
Definition: query_planner.c:76
static void qo_worst_fprint(QO_PLAN *, FILE *, int)
#define qo_worst_free
Definition: query_planner.c:81

Definition at line 347 of file query_planner.c.

Referenced by qo_worst_new().