MySQL 8.0.30
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.


struct  histograms::Histogram_psi_key_alloc
class  histograms::Histogram
 Histogram base class. More...


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


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 > > >


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


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, 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, TABLE_LIST &table, const columns_set &columns, bool needs_lock, 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)


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.