MySQL 8.4.2
Source Code Documentation
opt_explain_json.cc File Reference
#include "sql/opt_explain_json.h"
#include <assert.h>
#include <sys/types.h>
#include <climits>
#include <cstddef>
#include <cstdio>
#include "my_alloc.h"
#include "my_compiler.h"
#include "mysql/strings/m_ctype.h"
#include "sql-common/json_dom.h"
#include "sql/current_thd.h"
#include "sql/enum_query_type.h"
#include "sql/item.h"
#include "sql/item_sum.h"
#include "sql/key_spec.h"
#include "sql/mysqld.h"
#include "sql/opt_trace.h"
#include "sql/opt_trace_context.h"
#include "sql/protocol.h"
#include "sql/query_result.h"
#include "sql/sql_class.h"
#include "sql/sql_list.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/temp_table_param.h"
#include "sql/window.h"
#include "sql_string.h"
#include "string_with_len.h"

Classes

class  opt_explain_json_namespace::context
 Base class for all intermediate tree nodes. More...
 
class  opt_explain_json_namespace::subquery_ctx
 Node class to wrap a subquery node tree. More...
 
class  opt_explain_json_namespace::unit_ctx
 Helper base class to host HAVING, ORDER BY and GROUP BY subquery nodes. More...
 
class  opt_explain_json_namespace::table_base_ctx
 
class  opt_explain_json_namespace::setop_result_ctx
 Node class for the CTX_UNION_RESULT. More...
 
class  opt_explain_json_namespace::table_with_where_and_derived
 Common part of CTX_QEP_TAB and CTX_MESSAGE nodes. More...
 
class  opt_explain_json_namespace::joinable_ctx
 Base for CTX_QEP_TAB, CTX_DUPLICATES_WEEDOUT and CTX_MATERIALIZATION nodes. More...
 
class  opt_explain_json_namespace::message_ctx
 Node class for CTX_MESSAGE. More...
 
class  opt_explain_json_namespace::join_tab_ctx
 Node class for the CTX_QEP_TAB context. More...
 
class  opt_explain_json_namespace::simple_sort_ctx
 Base class for CTX_ORDER_BY, CTX_GROUP_BY and node class for CTX_DISTINCT. More...
 
class  opt_explain_json_namespace::simple_sort_with_subqueries_ctx
 Node class for "simple" CTX_ORDER_BY and CTX_GROUP_BY. More...
 
class  opt_explain_json_namespace::join_ctx
 Node class for the CTX_JOIN context. More...
 
class  opt_explain_json_namespace::sort_ctx
 Node class for CTX_SIMPLE_ORDER_BY, CTX_SIMPLE_GROUP_BY and CTX_SIMPLE_DISTINCT. More...
 
class  opt_explain_json_namespace::sort_with_subqueries_ctx
 
class  opt_explain_json_namespace::window_ctx
 When the query has window functions, an outer node named "windowing" is added: query_block: { select_id: 1, windowing: { windows: [ ... list of all windows' details ... ], nested_loop: [ ... ]. More...
 
class  opt_explain_json_namespace::materialize_ctx
 Context class to group materialized JOIN_TABs to "materialized" array. More...
 
class  opt_explain_json_namespace::duplication_weedout_ctx
 Context class to represent JOIN_TABs in duplication weedout sequence. More...
 
class  opt_explain_json_namespace::setop_ctx
 Node class for UNION, EXCEPT, INTERSECT, UNARY (query expression) More...
 

Namespaces

namespace  opt_explain_json_namespace
 

Enumerations

enum  opt_explain_json_namespace::subquery_list_enum {
  opt_explain_json_namespace::SQ_SELECT_LIST , opt_explain_json_namespace::SQ_UPDATE_VALUE , opt_explain_json_namespace::SQ_INSERT_VALUES , opt_explain_json_namespace::SQ_INSERT_UPDATE ,
  opt_explain_json_namespace::SQ_HAVING , opt_explain_json_namespace::SQ_OPTIMIZED_AWAY , opt_explain_json_namespace::SQ_toplevel , opt_explain_json_namespace::SQ_ORDER_BY ,
  opt_explain_json_namespace::SQ_GROUP_BY , opt_explain_json_namespace::SQ_total
}
 

Functions

static bool opt_explain_json_namespace::format_list (Opt_trace_context *json, List< subquery_ctx > &subqueries, const char *name)
 Helper function to pass a subquery list to a JSON formatter. More...
 
static void opt_explain_json_namespace::add_string_array (Opt_trace_context *json, const char *list_name, List< const char > &strings)
 
static void opt_explain_json_namespace::print_cost (char *buf, uint buf_len, double cost)
 
static void opt_explain_json_namespace::print_filtered (char *buf, uint buf_len, double filtered)
 
template<typename T >
static size_t opt_explain_json_namespace::get_id (List< T > &list, bool hide)
 Auxiliary function to walk through the list and propagate "hide" value. More...
 

Variables

static const char * json_extra_tags [ET_total]
 Property names, former parts of traditional "extra" column. More...
 
static const char K_ACCESS_TYPE [] = "access_type"
 
static const char K_ATTACHED_CONDITION [] = "attached_condition"
 
static const char K_ATTACHED_SUBQUERIES [] = "attached_subqueries"
 
static const char K_BUFFER_RESULT [] = "buffer_result"
 
static const char K_CACHEABLE [] = "cacheable"
 
static const char K_DEPENDENT [] = "dependent"
 
static const char K_DUPLICATES_REMOVAL [] = "duplicates_removal"
 
static const char K_FILTERED [] = "filtered"
 
static const char K_FRAME_BUFFER [] = "frame_buffer"
 
static const char K_FUNCTIONS [] = "functions"
 
static const char K_GROUPING_OPERATION [] = "grouping_operation"
 
static const char K_GROUP_BY_SUBQUERIES [] = "group_by_subqueries"
 
static const char K_HAVING_SUBQUERIES [] = "having_subqueries"
 
static const char K_INSERT_VALUES_SUBQUERIES [] = "insert_values_subqueries"
 
static const char K_INSERT_UPDATE_SUBQUERIES [] = "insert_update_subqueries"
 
static const char K_KEY [] = "key"
 
static const char K_KEY_LENGTH [] = "key_length"
 
static const char K_MATERIALIZED_FROM_SUBQUERY [] = "materialized_from_subquery"
 
static const char K_MESSAGE [] = "message"
 
static const char K_NAME [] = "name"
 
static const char K_NESTED_LOOP [] = "nested_loop"
 
static const char K_OPTIMIZED_AWAY_SUBQUERIES [] = "optimized_away_subqueries"
 
static const char K_OPTIMIZED_FRAME_EVALUATION [] = "optimized_frame_evaluation"
 
static const char K_ORDERING_OPERATION [] = "ordering_operation"
 
static const char K_ORDER_BY_SUBQUERIES [] = "order_by_subqueries"
 
static const char K_PARTITIONS [] = "partitions"
 
static const char K_POSSIBLE_KEYS [] = "possible_keys"
 
static const char K_QUERY_BLOCK [] = "query_block"
 
static const char K_QUERY_SPECIFICATIONS [] = "query_specifications"
 
static const char K_REF [] = "ref"
 
static const char K_SELECT_ID [] = "select_id"
 
static const char K_SELECT_LIST_SUBQUERIES [] = "select_list_subqueries"
 
static const char K_SHARING_TMP_TABLE [] = "sharing_temporary_table_with"
 
static const char K_TABLE [] = "table"
 
static const char K_TABLE_NAME [] = "table_name"
 
static const char K_UNION_RESULT [] = "union_result"
 
static const char K_INTERSECT_RESULT [] = "intersect_result"
 
static const char K_EXCEPT_RESULT [] = "except_result"
 
static const char K_UNARY_RESULT [] = "unary_result"
 
static const char K_UPDATE_VALUE_SUBQUERIES [] = "update_value_subqueries"
 
static const char K_USED_KEY_PARTS [] = "used_key_parts"
 
static const char K_USING_FILESORT [] = "using_filesort"
 
static const char K_FILESORT_KEY [] = "filesort_key"
 
static const char K_USING_TMP_TABLE [] = "using_temporary_table"
 
static const char K_WINDOW_DEF_POS [] = "definition_position"
 
static const char K_WINDOW_LAST_EXECUTED [] = "last_executed_window"
 
static const char K_WINDOWS [] = "windows"
 
static const char K_WINDOWING [] = "windowing"
 
static const char K_ROWS [] = "rows_examined_per_scan"
 
static const char K_PREFIX_ROWS [] = "rows_produced_per_join"
 
static const char K_COST_INFO [] = "cost_info"
 
static const char K_READ_TIME [] = "read_cost"
 
static const char K_PREFIX_COST [] = "prefix_cost"
 
static const char K_COND_COST [] = "eval_cost"
 
static const char K_SORT_COST [] = "sort_cost"
 
static const char K_QUERY_COST [] = "query_cost"
 
static const char K_DATA_SIZE_QUERY [] = "data_read_per_join"
 
static const char K_USED_COLUMNS [] = "used_columns"
 
static const char * mod_type_name []
 
static const char * opt_explain_json_namespace::list_names [SQ_total]
 

Variable Documentation

◆ json_extra_tags

const char* json_extra_tags[ET_total]
static

Property names, former parts of traditional "extra" column.

This array must be in sync with Extra_tag enum.

◆ K_ACCESS_TYPE

const char K_ACCESS_TYPE[] = "access_type"
static

◆ K_ATTACHED_CONDITION

const char K_ATTACHED_CONDITION[] = "attached_condition"
static

◆ K_ATTACHED_SUBQUERIES

const char K_ATTACHED_SUBQUERIES[] = "attached_subqueries"
static

◆ K_BUFFER_RESULT

const char K_BUFFER_RESULT[] = "buffer_result"
static

◆ K_CACHEABLE

const char K_CACHEABLE[] = "cacheable"
static

◆ K_COND_COST

const char K_COND_COST[] = "eval_cost"
static

◆ K_COST_INFO

const char K_COST_INFO[] = "cost_info"
static

◆ K_DATA_SIZE_QUERY

const char K_DATA_SIZE_QUERY[] = "data_read_per_join"
static

◆ K_DEPENDENT

const char K_DEPENDENT[] = "dependent"
static

◆ K_DUPLICATES_REMOVAL

const char K_DUPLICATES_REMOVAL[] = "duplicates_removal"
static

◆ K_EXCEPT_RESULT

const char K_EXCEPT_RESULT[] = "except_result"
static

◆ K_FILESORT_KEY

const char K_FILESORT_KEY[] = "filesort_key"
static

◆ K_FILTERED

const char K_FILTERED[] = "filtered"
static

◆ K_FRAME_BUFFER

const char K_FRAME_BUFFER[] = "frame_buffer"
static

◆ K_FUNCTIONS

const char K_FUNCTIONS[] = "functions"
static

◆ K_GROUP_BY_SUBQUERIES

const char K_GROUP_BY_SUBQUERIES[] = "group_by_subqueries"
static

◆ K_GROUPING_OPERATION

const char K_GROUPING_OPERATION[] = "grouping_operation"
static

◆ K_HAVING_SUBQUERIES

const char K_HAVING_SUBQUERIES[] = "having_subqueries"
static

◆ K_INSERT_UPDATE_SUBQUERIES

const char K_INSERT_UPDATE_SUBQUERIES[] = "insert_update_subqueries"
static

◆ K_INSERT_VALUES_SUBQUERIES

const char K_INSERT_VALUES_SUBQUERIES[] = "insert_values_subqueries"
static

◆ K_INTERSECT_RESULT

const char K_INTERSECT_RESULT[] = "intersect_result"
static

◆ K_KEY

const char K_KEY[] = "key"
static

◆ K_KEY_LENGTH

const char K_KEY_LENGTH[] = "key_length"
static

◆ K_MATERIALIZED_FROM_SUBQUERY

const char K_MATERIALIZED_FROM_SUBQUERY[] = "materialized_from_subquery"
static

◆ K_MESSAGE

const char K_MESSAGE[] = "message"
static

◆ K_NAME

const char K_NAME[] = "name"
static

◆ K_NESTED_LOOP

const char K_NESTED_LOOP[] = "nested_loop"
static

◆ K_OPTIMIZED_AWAY_SUBQUERIES

const char K_OPTIMIZED_AWAY_SUBQUERIES[] = "optimized_away_subqueries"
static

◆ K_OPTIMIZED_FRAME_EVALUATION

const char K_OPTIMIZED_FRAME_EVALUATION[] = "optimized_frame_evaluation"
static

◆ K_ORDER_BY_SUBQUERIES

const char K_ORDER_BY_SUBQUERIES[] = "order_by_subqueries"
static

◆ K_ORDERING_OPERATION

const char K_ORDERING_OPERATION[] = "ordering_operation"
static

◆ K_PARTITIONS

const char K_PARTITIONS[] = "partitions"
static

◆ K_POSSIBLE_KEYS

const char K_POSSIBLE_KEYS[] = "possible_keys"
static

◆ K_PREFIX_COST

const char K_PREFIX_COST[] = "prefix_cost"
static

◆ K_PREFIX_ROWS

const char K_PREFIX_ROWS[] = "rows_produced_per_join"
static

◆ K_QUERY_BLOCK

const char K_QUERY_BLOCK[] = "query_block"
static

◆ K_QUERY_COST

const char K_QUERY_COST[] = "query_cost"
static

◆ K_QUERY_SPECIFICATIONS

const char K_QUERY_SPECIFICATIONS[] = "query_specifications"
static

◆ K_READ_TIME

const char K_READ_TIME[] = "read_cost"
static

◆ K_REF

const char K_REF[] = "ref"
static

◆ K_ROWS

const char K_ROWS[] = "rows_examined_per_scan"
static

◆ K_SELECT_ID

const char K_SELECT_ID[] = "select_id"
static

◆ K_SELECT_LIST_SUBQUERIES

const char K_SELECT_LIST_SUBQUERIES[] = "select_list_subqueries"
static

◆ K_SHARING_TMP_TABLE

const char K_SHARING_TMP_TABLE[] = "sharing_temporary_table_with"
static

◆ K_SORT_COST

const char K_SORT_COST[] = "sort_cost"
static

◆ K_TABLE

const char K_TABLE[] = "table"
static

◆ K_TABLE_NAME

const char K_TABLE_NAME[] = "table_name"
static

◆ K_UNARY_RESULT

const char K_UNARY_RESULT[] = "unary_result"
static

◆ K_UNION_RESULT

const char K_UNION_RESULT[] = "union_result"
static

◆ K_UPDATE_VALUE_SUBQUERIES

const char K_UPDATE_VALUE_SUBQUERIES[] = "update_value_subqueries"
static

◆ K_USED_COLUMNS

const char K_USED_COLUMNS[] = "used_columns"
static

◆ K_USED_KEY_PARTS

const char K_USED_KEY_PARTS[] = "used_key_parts"
static

◆ K_USING_FILESORT

const char K_USING_FILESORT[] = "using_filesort"
static

◆ K_USING_TMP_TABLE

const char K_USING_TMP_TABLE[] = "using_temporary_table"
static

◆ K_WINDOW_DEF_POS

const char K_WINDOW_DEF_POS[] = "definition_position"
static

◆ K_WINDOW_LAST_EXECUTED

const char K_WINDOW_LAST_EXECUTED[] = "last_executed_window"
static

◆ K_WINDOWING

const char K_WINDOWING[] = "windowing"
static

◆ K_WINDOWS

const char K_WINDOWS[] = "windows"
static

◆ mod_type_name

const char* mod_type_name[]
static
Initial value:
= {"", "insert", "update", "delete",
"replace"}