MySQL  8.0.21
Source Code Documentation
histogram.h File Reference

Histogram base class. More...

#include <cstddef>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <utility>
#include "lex_string.h"
#include "my_base.h"
#include "sql/histograms/value_map_type.h"
#include "sql/mem_root_allocator.h"
#include "sql/stateless_allocator.h"

Go to the source code of this file.

Classes

class  histograms::Value_map< T >
 Value_map class. More...
 
struct  histograms::Histogram_psi_key_alloc
 
class  histograms::Histogram
 Histogram base class. More...
 

Namespaces

 dd
 The version of the current data dictionary table definitions.
 
 histograms
 

Typedefs

template<class T >
using histograms::Histogram_key_allocator = Stateless_allocator< T, Histogram_psi_key_alloc >
 
template<class T >
using histograms::value_map_allocator = Mem_root_allocator< std::pair< const T, ha_rows > >
 
template<typename T >
using histograms::value_map_type = std::map< T, ha_rows, Histogram_comparator, value_map_allocator< T > >
 
using histograms::columns_set = std::set< std::string, std::less< std::string >, Histogram_key_allocator< std::string > >
 
using histograms::results_map = std::map< std::string, Message, std::less< std::string >, Histogram_key_allocator< std::pair< const std::string, Message > >>
 

Enumerations

enum  histograms::Message {
  histograms::Message::FIELD_NOT_FOUND, histograms::Message::UNSUPPORTED_DATA_TYPE, histograms::Message::TEMPORARY_TABLE, histograms::Message::ENCRYPTED_TABLE,
  histograms::Message::VIEW, histograms::Message::HISTOGRAM_CREATED, histograms::Message::MULTIPLE_TABLES_SPECIFIED, histograms::Message::COVERED_BY_SINGLE_PART_UNIQUE_INDEX,
  histograms::Message::NO_HISTOGRAM_FOUND, histograms::Message::HISTOGRAM_DELETED, histograms::Message::SERVER_READ_ONLY
}
 
enum  histograms::enum_operator {
  histograms::enum_operator::EQUALS_TO, histograms::enum_operator::GREATER_THAN, histograms::enum_operator::LESS_THAN, histograms::enum_operator::IS_NULL,
  histograms::enum_operator::IS_NOT_NULL, histograms::enum_operator::LESS_THAN_OR_EQUAL, histograms::enum_operator::GREATER_THAN_OR_EQUAL, histograms::enum_operator::NOT_EQUALS_TO,
  histograms::enum_operator::BETWEEN, histograms::enum_operator::NOT_BETWEEN, histograms::enum_operator::IN_LIST, histograms::enum_operator::NOT_IN_LIST
}
 The different operators we can ask histogram statistics for selectivity estimations. More...
 

Functions

template<class T >
Histogram * histograms::build_histogram (MEM_ROOT *mem_root, const Value_map< T > &value_map, size_t num_buckets, const std::string &db_name, const std::string &tbl_name, const std::string &col_name)
 Create a histogram from a value map. More...
 
bool histograms::update_histogram (THD *thd, TABLE_LIST *table, const columns_set &columns, int num_buckets, results_map &results)
 Create or update histograms for a set of columns of a given table. More...
 
bool histograms::drop_all_histograms (THD *thd, const TABLE_LIST &table, const dd::Table &original_table_def, results_map &results)
 Drop histograms for all columns in a given table. More...
 
bool histograms::drop_histograms (THD *thd, const TABLE_LIST &table, const columns_set &columns, results_map &results)
 Drop histograms for a set of columns in a given table. More...
 
bool histograms::rename_histograms (THD *thd, const char *old_schema_name, const char *old_table_name, const char *new_schema_name, const char *new_table_name, results_map &results)
 Rename histograms for all columns in a given table. More...
 
bool histograms::find_histogram (THD *thd, const std::string &schema_name, const std::string &table_name, const std::string &column_name, const Histogram **histogram)
 

Variables

static const double histograms::INVALID_NULL_VALUES_FRACTION = -1.0
 The default (and invalid) value for "m_null_values_fraction". More...
 

Detailed Description

Histogram base class.

This file defines the base class for all histogram types. We keep the base class itself non-templatized in order to more easily send a histogram as an argument, collect multiple histograms in a single collection etc.

A histogram is stored as a JSON object. This gives the flexibility of storing virtually an unlimited number of buckets, data values in its full length and easily expanding with new histogram types in the future. They are stored persistently in the system table mysql.column_stats.

We keep all histogram code in the namespace "histograms" in order to avoid name conflicts etc.