CUBRID Engine  latest
optimizer.h File Reference
#include <stdarg.h>
#include <assert.h>
#include "error_manager.h"
#include "memory_alloc.h"
#include "parser.h"
#include "release_string.h"
Include dependency graph for optimizer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  qo_summary
 
struct  QO_ATTR_CUM_STATS
 
struct  qo_limit_info
 

Macros

#define UNEXPECTED_CASE   0
 
#define UNREACHABLE   0
 
#define QO_ASSERT(env, cond)
 
#define QO_ABORT(env)   qo_abort((env), __FILE__, __LINE__)
 
#define QO_WARN(code)
 
#define QO_WARN1(code, x)
 
#define QO_ERROR(code)
 
#define QO_ERROR1(code, x)
 
#define QO_ERROR2(code, x, y)
 
#define OPT_LEVEL(level)   ((level) & 0xff)
 
#define OPTIMIZATION_ENABLED(level)   (OPT_LEVEL(level) != 0)
 
#define PLAN_DUMP_ENABLED(level)   ((level) >= 0x100)
 
#define SIMPLE_DUMP(level)   ((level) & 0x100)
 
#define DETAILED_DUMP(level)   ((level) & 0x200)
 

Typedefs

typedef struct qo_env QO_ENV
 
typedef struct qo_node QO_NODE
 
typedef struct qo_segment QO_SEGMENT
 
typedef struct qo_term QO_TERM
 
typedef struct qo_eqclass QO_EQCLASS
 
typedef struct qo_subquery QO_SUBQUERY
 
typedef struct qo_planner QO_PLANNER
 
typedef struct qo_info QO_INFO
 
typedef struct qo_partition QO_PARTITION
 
typedef struct qo_class_info QO_CLASS_INFO
 
typedef struct qo_attr_info QO_ATTR_INFO
 
typedef struct qo_summary QO_SUMMARY
 
typedef struct qo_index QO_INDEX
 
typedef struct qo_index_entry QO_INDEX_ENTRY
 
typedef struct qo_node_index QO_NODE_INDEX
 
typedef struct qo_node_index_entry QO_NODE_INDEX_ENTRY
 
typedef struct qo_index_xasl_info QO_INDEX_XASL_INFO
 
typedef struct qo_using_index QO_USING_INDEX
 
typedef struct qo_using_index_entry QO_USING_INDEX_ENTRY
 
typedef struct bitset BITSET
 
typedef struct qo_plan QO_PLAN
 
typedef struct qo_xasl_index_info QO_XASL_INDEX_INFO
 
typedef struct qo_limit_info QO_LIMIT_INFO
 

Enumerations

enum  QO_PARAM { QO_PARAM_LEVEL, QO_PARAM_COST }
 

Functions

QO_NODElookup_node (PT_NODE *attr, QO_ENV *env, PT_NODE **entity)
 
QO_SEGMENTlookup_seg (QO_NODE *head, PT_NODE *name, QO_ENV *env)
 
void qo_expr_segs (QO_ENV *env, PT_NODE *pt_expr, BITSET *result)
 
void qo_get_optimization_param (void *, QO_PARAM,...)
 
bool qo_need_skip_execution (void)
 
void qo_set_optimization_param (void *, QO_PARAM,...)
 
QO_PLANqo_optimize_query (PARSER_CONTEXT *, PT_NODE *)
 
xasl_nodeqo_to_xasl (QO_PLAN *, xasl_node *)
 
void qo_plan_discard (QO_PLAN *)
 
void qo_plan_dump (QO_PLAN *, FILE *)
 
const char * qo_plan_set_cost_fn (const char *, int)
 
int qo_plan_get_cost_fn (const char *)
 
PT_NODEqo_plan_iscan_sort_list (QO_PLAN *)
 
bool qo_plan_skip_orderby (QO_PLAN *plan)
 
bool qo_plan_skip_groupby (QO_PLAN *plan)
 
bool qo_is_index_covering_scan (QO_PLAN *plan)
 
bool qo_is_index_iss_scan (QO_PLAN *plan)
 
bool qo_is_index_loose_scan (QO_PLAN *plan)
 
bool qo_is_index_mro_scan (QO_PLAN *plan)
 
bool qo_plan_multi_range_opt (QO_PLAN *plan)
 
void qo_set_cost (DB_OBJECT *target, DB_VALUE *result, DB_VALUE *plan, DB_VALUE *cost)
 
int qo_xasl_get_num_terms (QO_XASL_INDEX_INFO *info)
 
PT_NODE ** qo_xasl_get_terms (QO_XASL_INDEX_INFO *)
 
PT_NODEqo_check_nullable_expr (PARSER_CONTEXT *parser, PT_NODE *node, void *arg, int *continue_walk)
 
PT_NODEmq_optimize (PARSER_CONTEXT *parser, PT_NODE *statement)
 
void qo_abort (QO_ENV *, const char *, int)
 
double qo_expr_selectivity (QO_ENV *env, PT_NODE *pt_expr)
 
xasl_nodeqo_add_hq_iterations_access_spec (QO_PLAN *plan, xasl_node *xasl)
 
QO_LIMIT_INFOqo_get_key_limit_from_instnum (PARSER_CONTEXT *parser, QO_PLAN *plan, xasl_node *xasl)
 
QO_LIMIT_INFOqo_get_key_limit_from_ordbynum (PARSER_CONTEXT *parser, QO_PLAN *plan, xasl_node *xasl, bool ignore_lower)
 
bool qo_check_iscan_for_multi_range_opt (QO_PLAN *plan)
 
bool qo_check_join_for_multi_range_opt (QO_PLAN *plan)
 
int qo_find_subplan_using_multi_range_opt (QO_PLAN *plan, QO_PLAN **result, int *join_idx)
 
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)
 

Macro Definition Documentation

#define DETAILED_DUMP (   level)    ((level) & 0x200)

Definition at line 86 of file optimizer.h.

Referenced by csql_set_plan_dump(), pt_plan_query(), qo_optimize_helper(), and qo_plan_dump().

#define OPT_LEVEL (   level)    ((level) & 0xff)

Definition at line 82 of file optimizer.h.

#define OPTIMIZATION_ENABLED (   level)    (OPT_LEVEL(level) != 0)
#define PLAN_DUMP_ENABLED (   level)    ((level) >= 0x100)

Definition at line 84 of file optimizer.h.

Referenced by csql_set_plan_dump(), qo_optimize_helper(), and qo_to_xasl().

#define QO_ABORT (   env)    qo_abort((env), __FILE__, __LINE__)

Definition at line 59 of file optimizer.h.

Referenced by qo_analyze_term(), and qo_discover_partitions().

#define QO_ERROR (   code)

Definition at line 70 of file optimizer.h.

#define QO_ERROR1 (   code,
 
)

Definition at line 71 of file optimizer.h.

#define QO_ERROR2 (   code,
  x,
 
)

Definition at line 72 of file optimizer.h.

#define QO_WARN (   code)

Definition at line 68 of file optimizer.h.

#define QO_WARN1 (   code,
 
)

Definition at line 69 of file optimizer.h.

#define SIMPLE_DUMP (   level)    ((level) & 0x100)

Definition at line 85 of file optimizer.h.

Referenced by csql_set_plan_dump(), pt_plan_query(), and qo_plan_dump().

#define UNEXPECTED_CASE   0

Definition at line 49 of file optimizer.h.

Referenced by planner_visit_node().

#define UNREACHABLE   0

Definition at line 50 of file optimizer.h.

Typedef Documentation

typedef struct bitset BITSET

Definition at line 107 of file optimizer.h.

typedef struct qo_attr_info QO_ATTR_INFO

Definition at line 98 of file optimizer.h.

typedef struct qo_class_info QO_CLASS_INFO

Definition at line 97 of file optimizer.h.

typedef struct qo_env QO_ENV

Definition at line 88 of file optimizer.h.

typedef struct qo_eqclass QO_EQCLASS

Definition at line 92 of file optimizer.h.

typedef struct qo_index QO_INDEX

Definition at line 100 of file optimizer.h.

Definition at line 101 of file optimizer.h.

typedef struct qo_index_xasl_info QO_INDEX_XASL_INFO

Definition at line 104 of file optimizer.h.

typedef struct qo_info QO_INFO

Definition at line 95 of file optimizer.h.

typedef struct qo_limit_info QO_LIMIT_INFO
typedef struct qo_node QO_NODE

Definition at line 89 of file optimizer.h.

typedef struct qo_node_index QO_NODE_INDEX

Definition at line 102 of file optimizer.h.

Definition at line 103 of file optimizer.h.

typedef struct qo_partition QO_PARTITION

Definition at line 96 of file optimizer.h.

typedef struct qo_plan QO_PLAN

Definition at line 132 of file optimizer.h.

typedef struct qo_planner QO_PLANNER

Definition at line 94 of file optimizer.h.

typedef struct qo_segment QO_SEGMENT

Definition at line 90 of file optimizer.h.

typedef struct qo_subquery QO_SUBQUERY

Definition at line 93 of file optimizer.h.

typedef struct qo_summary QO_SUMMARY

Definition at line 99 of file optimizer.h.

typedef struct qo_term QO_TERM

Definition at line 91 of file optimizer.h.

Definition at line 105 of file optimizer.h.

Definition at line 106 of file optimizer.h.

Definition at line 134 of file optimizer.h.

Enumeration Type Documentation

enum QO_PARAM
Enumerator
QO_PARAM_LEVEL 
QO_PARAM_COST 

Definition at line 136 of file optimizer.h.

Function Documentation

PT_NODE* mq_optimize ( PARSER_CONTEXT parser,
PT_NODE statement 
)

Definition at line 7850 of file query_rewrite.c.

References NULL, parser_walk_tree(), qo_optimize_queries(), and qo_optimize_queries_post().

Referenced by mq_translate_helper().

Here is the caller graph for this function:

void qo_abort ( QO_ENV ,
const char *  ,
int   
)

Definition at line 5796 of file query_graph.c.

References qo_env::catch_, ER_FAILED_ASSERTION, er_set(), and ER_WARNING_SEVERITY.

PT_NODE* qo_check_nullable_expr ( PARSER_CONTEXT parser,
PT_NODE node,
void *  arg,
int *  continue_walk 
)
int qo_find_subplan_using_multi_range_opt ( QO_PLAN plan,
QO_PLAN **  result,
int *  join_idx 
)
bool qo_need_skip_execution ( void  )
void qo_plan_discard ( QO_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 ,
FILE *   
)

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:

int qo_plan_get_cost_fn ( const char *  )

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:

PT_NODE* qo_plan_iscan_sort_list ( QO_PLAN )

Definition at line 2436 of file plan_generation.c.

References qo_plan::iscan_sort_list.

Referenced by pt_to_buildlist_proc().

Here is the caller graph for this function:

const char* qo_plan_set_cost_fn ( const char *  ,
int   
)
bool qo_plan_skip_groupby ( QO_PLAN plan)

Definition at line 2460 of file plan_generation.c.

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

Referenced by pt_to_buildlist_proc().

Here is the caller graph for this function:

bool qo_plan_skip_orderby ( QO_PLAN plan)

Definition at line 2447 of file plan_generation.c.

References qo_plan::plan_type, qo_plan::plan_un, QO_PLANTYPE_SORT, qo_plan::sort, SORT_DISTINCT, and SORT_ORDERBY.

Referenced by pt_to_buildlist_proc().

Here is the caller graph for this function:

void qo_set_optimization_param ( void *  ,
QO_PARAM  ,
  ... 
)
int qo_xasl_get_num_terms ( QO_XASL_INDEX_INFO info)

Definition at line 2893 of file plan_generation.c.

References qo_xasl_index_info::nterms.

Referenced by pt_to_index_attrs(), and pt_to_index_info().

Here is the caller graph for this function:

PT_NODE** qo_xasl_get_terms ( QO_XASL_INDEX_INFO )

Definition at line 2905 of file plan_generation.c.

References qo_xasl_index_info::term_exprs.

Referenced by pt_to_index_attrs(), and pt_to_index_info().

Here is the caller graph for this function: