MySQL 8.0.30
Source Code Documentation
histogram.h
Go to the documentation of this file.
1#ifndef HISTOGRAMS_HISTOGRAM_INCLUDED
2#define HISTOGRAMS_HISTOGRAM_INCLUDED
3
4/* Copyright (c) 2016, 2022, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is also distributed with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have included with MySQL.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26/**
27 @file sql/histograms/histogram.h
28 Histogram base class.
29
30 This file defines the base class for all histogram types. We keep the base
31 class itself non-templatized in order to more easily send a histogram as an
32 argument, collect multiple histograms in a single collection etc.
33
34 A histogram is stored as a JSON object. This gives the flexibility of storing
35 virtually an unlimited number of buckets, data values in its full length and
36 easily expanding with new histogram types in the future. They are stored
37 persistently in the system table mysql.column_stats.
38
39 We keep all histogram code in the namespace "histograms" in order to avoid
40 name conflicts etc.
41*/
42
43#include <cstddef> // size_t
44#include <functional>
45#include <map> // std::map
46#include <set> // std::set
47#include <string> // std::string
48#include <utility> // std::pair
49
50#include "lex_string.h" // LEX_CSTRING
51#include "my_base.h" // ha_rows
53#include "sql/mem_root_allocator.h" // Mem_root_allocator
54#include "sql/stateless_allocator.h" // Stateless_allocator
55
56class Item;
57class Json_dom;
58class Json_object;
59class THD;
60struct TYPELIB;
61
62namespace dd {
63class Table;
64} // namespace dd
65namespace histograms {
66struct Histogram_comparator;
67template <class T>
68class Value_map;
69} // namespace histograms
70struct CHARSET_INFO;
71struct MEM_ROOT;
72struct TABLE_LIST;
73
74namespace histograms {
75
76/// The default (and invalid) value for "m_null_values_fraction".
77static const double INVALID_NULL_VALUES_FRACTION = -1.0;
78
79enum class Message {
84 VIEW,
91};
92
94 void *operator()(size_t s) const;
95};
96
97template <class T>
99
100template <class T>
102
103template <typename T>
105 std::map<T, ha_rows, Histogram_comparator, value_map_allocator<T>>;
106
107using columns_set = std::set<std::string, std::less<std::string>,
109
111 std::map<std::string, Message, std::less<std::string>,
113
114/**
115 The different operators we can ask histogram statistics for selectivity
116 estimations.
117*/
118enum class enum_operator {
119 EQUALS_TO,
121 LESS_THAN,
122 IS_NULL,
127 BETWEEN,
129 IN_LIST,
131};
132
133/**
134 Histogram base class.
135
136 This is an abstract class containing the interface and shared code for
137 concrete histogram subclasses.
138
139 Histogram subclasses (Singleton, Equi_height) are constructed through factory
140 methods in order to catch memory allocation errors during construction.
141
142 The histogram subclasses have no public copy or move constructors. In order to
143 copy a histogram onto a given MEM_ROOT, use the public clone method. The clone
144 method ensures that members of the histogram, such String type buckets,
145 are also allocated on the given MEM_ROOT. Modifications to these methods need
146 to be careful that histogram buckets are cloned/copied correctly.
147*/
149 public:
150 /// All supported histogram types in MySQL.
152
153 /// String representation of the JSON field "histogram-type".
154 static constexpr const char *histogram_type_str() { return "histogram-type"; }
155
156 /// String representation of the JSON field "data-type".
157 static constexpr const char *data_type_str() { return "data-type"; }
158
159 /// String representation of the JSON field "collation-id".
160 static constexpr const char *collation_id_str() { return "collation-id"; }
161
162 /// String representation of the histogram type SINGLETON.
163 static constexpr const char *singleton_str() { return "singleton"; }
164
165 /// String representation of the histogram type EQUI-HEIGHT.
166 static constexpr const char *equi_height_str() { return "equi-height"; }
167
168 protected:
170
171 /// The fraction of NULL values in the histogram (between 0.0 and 1.0).
173
174 /// The character set for the data stored
176
177 /// The number of buckets originally specified
179
180 /// String representation of the JSON field "buckets".
181 static constexpr const char *buckets_str() { return "buckets"; }
182
183 /// String representation of the JSON field "last-updated".
184 static constexpr const char *last_updated_str() { return "last-updated"; }
185
186 /// String representation of the JSON field "null-values".
187 static constexpr const char *null_values_str() { return "null-values"; }
188
189 static constexpr const char *sampling_rate_str() { return "sampling-rate"; }
190
191 /// String representation of the JSON field "number-of-buckets-specified".
192 static constexpr const char *numer_of_buckets_specified_str() {
193 return "number-of-buckets-specified";
194 }
195
196 /**
197 Constructor.
198
199 @param mem_root the mem_root where the histogram contents will be allocated
200 @param db_name name of the database this histogram represents
201 @param tbl_name name of the table this histogram represents
202 @param col_name name of the column this histogram represents
203 @param type the histogram type (equi-height, singleton)
204 @param data_type the type of data that this histogram contains
205 @param[out] error is set to true if an error occurs
206 */
207 Histogram(MEM_ROOT *mem_root, const std::string &db_name,
208 const std::string &tbl_name, const std::string &col_name,
209 enum_histogram_type type, Value_map_type data_type, bool *error);
210
211 /**
212 Copy constructor
213
214 This will make a copy of the provided histogram onto the provided MEM_ROOT.
215
216 @param mem_root the mem_root where the histogram contents will be allocated
217 @param other the histogram to copy
218 @param[out] error is set to true if an error occurs
219 */
220 Histogram(MEM_ROOT *mem_root, const Histogram &other, bool *error);
221
222 /**
223 Write the data type of this histogram into a JSON object.
224
225 @param json_object the JSON object where we will write the histogram
226 data type
227
228 @return true on error, false otherwise
229 */
230 bool histogram_data_type_to_json(Json_object *json_object) const;
231
232 /**
233 Return the value that is contained in the JSON DOM object.
234
235 For most types, this function simply returns the contained value. For String
236 values, the value is allocated on this histograms MEM_ROOT before it is
237 returned. This allows the String value to survive the entire lifetime of the
238 histogram object.
239
240 @param json_dom the JSON DOM object to extract the value from
241 @param out the value from the JSON DOM object
242
243 @return true on error, false otherwise
244 */
245 template <class T>
246 bool extract_json_dom_value(const Json_dom *json_dom, T *out);
247
248 /**
249 Populate the histogram with data from the provided JSON object. The base
250 class also provides an implementation that subclasses must call in order
251 to populate fields that are shared among all histogram types (character set,
252 null values fraction).
253
254 @param json_object the JSON object to read the histogram data from
255
256 @return true on error, false otherwise
257 */
258 virtual bool json_to_histogram(const Json_object &json_object) = 0;
259
260 private:
261 /// The MEM_ROOT where the histogram contents will be allocated.
263
264 /// The type of this histogram.
266
267 /// The type of the data this histogram contains.
269
270 /// Name of the database this histogram represents.
272
273 /// Name of the table this histogram represents.
275
276 /// Name of the column this histogram represents.
278
279 /**
280 An internal function for getting a selectivity estimate prior to adustment.
281 @see get_selectivity() for details.
282 */
283 bool get_raw_selectivity(Item **items, size_t item_count, enum_operator op,
284 double *selectivity) const;
285
286 /**
287 An internal function for getting the selecitvity estimation.
288
289 This function will read/evaluate the value from the given Item, and pass
290 this value on to the correct selectivity estimation function based on the
291 data type of the histogram. For instance, if the data type of the histogram
292 is INT, we will call "val_int" on the Item to evaluate the value as an
293 integer and pass this value on to the next function.
294
295 @param item The Item to read/evaluate the value from.
296 @param op The operator we are estimating the selectivity for.
297 @param typelib In the case of ENUM or SET data type, this parameter holds
298 the type information. This is needed in order to map a
299 string representation of an ENUM/SET value into its correct
300 integer representation (ENUM/SET values are stored as
301 integer values in the histogram).
302 @param[out] selectivity The estimated selectivity, between 0.0 and 1.0
303 inclusive.
304
305 @return true on error (i.e the provided item was NULL), false on success.
306 */
307 bool get_selectivity_dispatcher(Item *item, const enum_operator op,
308 const TYPELIB *typelib,
309 double *selectivity) const;
310
311 /**
312 An internal function for getting the selecitvity estimation.
313
314 This function will cast the histogram to the correct class (using down_cast)
315 and pass the given value on to the correct selectivity estimation function
316 for that class.
317
318 @param value The value to estimate the selectivity for.
319
320 @return The estimated selectivity, between 0.0 and 1.0 inclusive.
321 */
322 template <class T>
323 double get_less_than_selectivity_dispatcher(const T &value) const;
324
325 /// @see get_less_than_selectivity_dispatcher
326 template <class T>
327 double get_greater_than_selectivity_dispatcher(const T &value) const;
328
329 /// @see get_less_than_selectivity_dispatcher
330 template <class T>
331 double get_equal_to_selectivity_dispatcher(const T &value) const;
332
333 /**
334 An internal function for applying the correct function for the given
335 operator.
336
337 @param op The operator to apply
338 @param value The value to find the selectivity for.
339
340 @return The estimated selectivity, between 0.0 and 1.0 inclusive.
341 */
342 template <class T>
343 double apply_operator(const enum_operator op, const T &value) const;
344
345 public:
346 Histogram() = delete;
347 Histogram(const Histogram &other) = delete;
348
349 /// Destructor.
350 virtual ~Histogram() = default;
351
352 /// @return the MEM_ROOT that this histogram uses for allocations
353 MEM_ROOT *get_mem_root() const { return m_mem_root; }
354
355 /**
356 @return name of the database this histogram represents
357 */
359
360 /**
361 @return name of the table this histogram represents
362 */
363 const LEX_CSTRING get_table_name() const { return m_table_name; }
364
365 /**
366 @return name of the column this histogram represents
367 */
368 const LEX_CSTRING get_column_name() const { return m_column_name; }
369
370 /**
371 @return type of this histogram
372 */
374
375 /**
376 @return the fraction of NULL values, in the range [0.0, 1.0]
377 */
378 double get_null_values_fraction() const;
379
380 /// @return the character set for the data this histogram contains
381 const CHARSET_INFO *get_character_set() const { return m_charset; }
382
383 /// @return the sampling rate used to generate this histogram
384 double get_sampling_rate() const { return m_sampling_rate; }
385
386 /**
387 Returns the histogram type as a readable string.
388
389 @return a readable string representation of the histogram type
390 */
391 virtual std::string histogram_type_to_str() const = 0;
392
393 /**
394 @return number of buckets in this histogram
395 */
396 virtual size_t get_num_buckets() const = 0;
397
398 /**
399 Get the estimated number of distinct non-NULL values.
400 @return number of distinct non-NULL values
401 */
402 virtual size_t get_num_distinct_values() const = 0;
403
404 /**
405 @return the data type that this histogram contains
406 */
408
409 /**
410 @return number of buckets originally specified by the user. This may be
411 higher than the actual number of buckets in the histogram.
412 */
414
415 /**
416 Converts the histogram to a JSON object.
417
418 @param[in,out] json_object output where the histogram is to be stored. The
419 caller is responsible for allocating/deallocating the JSON
420 object
421
422 @return true on error, false otherwise
423 */
424 virtual bool histogram_to_json(Json_object *json_object) const = 0;
425
426 /**
427 Converts JSON object to a histogram.
428
429 @param mem_root MEM_ROOT where the histogram will be allocated
430 @param schema_name the schema name
431 @param table_name the table name
432 @param column_name the column name
433 @param json_object output where the histogram is stored
434
435 @return nullptr on error. Otherwise a histogram allocated on the provided
436 MEM_ROOT.
437 */
439 const std::string &schema_name,
440 const std::string &table_name,
441 const std::string &column_name,
442 const Json_object &json_object);
443
444 /**
445 Make a clone of the current histogram
446
447 @param mem_root the MEM_ROOT on which the new histogram will be allocated.
448
449 @return a histogram allocated on the provided MEM_ROOT. Returns nullptr
450 on error.
451 */
452 virtual Histogram *clone(MEM_ROOT *mem_root) const = 0;
453
454 /**
455 Store this histogram to persistent storage (data dictionary).
456
457 @param thd Thread handler.
458
459 @return false on success, true on error.
460 */
461 bool store_histogram(THD *thd) const;
462
463 /**
464 Get selectivity estimation.
465
466 This function will try and get the selectivity estimation for a predicate
467 on the form "COLUMN OPERATOR CONSTANT", for instance "SELECT * FROM t1
468 WHERE col1 > 23;".
469
470 This function will take care of several of things, for instance checking
471 that the value we are estimating the selectivity for is a constant value.
472
473 The order of the Items provided does not matter. For instance, of the
474 operator argument given is "EQUALS_TO", it does not matter if the constant
475 value is provided as the first or the second argument; this function will
476 take care of this.
477
478 @param items an array of items that contains both the field we
479 are estimating the selectivity for, as well as the
480 user-provided constant values.
481 @param item_count the number of Items in the Item array.
482 @param op the predicate operator
483 @param[out] selectivity the calculated selectivity if a usable histogram was
484 found
485
486 @retval true if an error occurred (the Item provided was not a constant
487 value or similar).
488 @return false if success
489 */
490 bool get_selectivity(Item **items, size_t item_count, enum_operator op,
491 double *selectivity) const;
492
493 /**
494 @return the fraction of non-null values in the histogram.
495 */
497 return 1.0 - get_null_values_fraction();
498 }
499};
500
501/**
502 Create a histogram from a value map.
503
504 This function will build a histogram from a value map. The histogram type
505 depends on both the size of the input data, as well as the number of buckets
506 specified. If the number of distinct values is less than or equal to the
507 number of buckets, a Singleton histogram will be created. Otherwise, an
508 equi-height histogram will be created.
509
510 The histogram will be allocated on the supplied mem_root, and it is the
511 callers responsibility to properly clean up when the histogram isn't needed
512 anymore.
513
514 @param mem_root the MEM_ROOT where the histogram contents will be
515 allocated
516 @param value_map a value map containing [value, frequency]
517 @param num_buckets the maximum number of buckets to create
518 @param db_name name of the database this histogram represents
519 @param tbl_name name of the table this histogram represents
520 @param col_name name of the column this histogram represents
521
522 @return a histogram, using at most "num_buckets" buckets. The histogram
523 type depends on the size of the input data, and the number of
524 buckets
525*/
526template <class T>
527Histogram *build_histogram(MEM_ROOT *mem_root, const Value_map<T> &value_map,
528 size_t num_buckets, const std::string &db_name,
529 const std::string &tbl_name,
530 const std::string &col_name);
531
532/**
533 Create or update histograms for a set of columns of a given table.
534
535 This function will try to create histogram statistics for all the columns
536 specified. If one of the columns fail, it will continue to the next one and
537 try.
538
539 @param thd Thread handler.
540 @param table The table where we should look for the columns/data.
541 @param columns Columns specified by the user.
542 @param num_buckets The maximum number of buckets to create in each
543 histogram.
544 @param results A map where the result of each operation is stored.
545
546 @return false on success, true on error.
547*/
548bool update_histogram(THD *thd, TABLE_LIST *table, const columns_set &columns,
549 int num_buckets, results_map &results);
550
551/**
552 Drop histograms for all columns in a given table.
553
554 @param thd Thread handler.
555 @param table The table where we should look for the columns.
556 @param original_table_def Original table definition.
557 @param results A map where the result of each operation is stored.
558
559 @note Assumes that caller owns exclusive metadata lock on the table,
560 so there is no need to lock individual statistics.
561
562 @return false on success, true on error.
563*/
564bool drop_all_histograms(THD *thd, TABLE_LIST &table,
565 const dd::Table &original_table_def,
566 results_map &results);
567
568/**
569 Drop histograms for a set of columns in a given table.
570
571 This function will try to drop the histogram statistics for all specified
572 columns. If one of the columns fail, it will continue to the next one and try.
573
574 @param thd Thread handler.
575 @param table The table where we should look for the columns.
576 @param columns Columns specified by the user.
577 @param needs_lock Whether we need to acquire metadata locks on
578 the table and column statistics to be dropped.
579 @param results A map where the result of each operation is stored.
580
581 @note In case when needs_lock parameter is false assumes that caller
582 owns exclusive metadata lock on the table, so there is no need
583 to lock individual statistics.
584
585 @return false on success, true on error.
586*/
587bool drop_histograms(THD *thd, TABLE_LIST &table, const columns_set &columns,
588 bool needs_lock, results_map &results);
589
590/**
591 Rename histograms for all columns in a given table.
592
593 @param thd Thread handler.
594 @param old_schema_name The old schema name
595 @param old_table_name The old table name
596 @param new_schema_name The new schema name
597 @param new_table_name The new table name
598 @param results A map where the result of each operation is stored.
599
600 @return false on success, true on error.
601*/
602bool rename_histograms(THD *thd, const char *old_schema_name,
603 const char *old_table_name, const char *new_schema_name,
604 const char *new_table_name, results_map &results);
605
606bool find_histogram(THD *thd, const std::string &schema_name,
607 const std::string &table_name,
608 const std::string &column_name,
609 const Histogram **histogram);
610} // namespace histograms
611
612#endif
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
JSON DOM abstract base class.
Definition: json_dom.h:172
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:372
Mem_root_allocator is a C++ STL memory allocator based on MEM_ROOT.
Definition: mem_root_allocator.h:67
Stateless_allocator is a C++ STL memory allocator skeleton based on Malloc_allocator,...
Definition: stateless_allocator.h:91
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:922
Definition: table.h:46
Histogram base class.
Definition: histogram.h:148
virtual std::string histogram_type_to_str() const =0
Returns the histogram type as a readable string.
size_t m_num_buckets_specified
The number of buckets originally specified.
Definition: histogram.h:178
Value_map_type get_data_type() const
Definition: histogram.h:407
double get_equal_to_selectivity_dispatcher(const T &value) const
Definition: histogram.cc:1387
virtual size_t get_num_buckets() const =0
MEM_ROOT * m_mem_root
The MEM_ROOT where the histogram contents will be allocated.
Definition: histogram.h:262
static constexpr const char * data_type_str()
String representation of the JSON field "data-type".
Definition: histogram.h:157
double m_sampling_rate
Definition: histogram.h:169
static constexpr const char * collation_id_str()
String representation of the JSON field "collation-id".
Definition: histogram.h:160
double get_less_than_selectivity_dispatcher(const T &value) const
An internal function for getting the selecitvity estimation.
Definition: histogram.cc:1348
static constexpr const char * buckets_str()
String representation of the JSON field "buckets".
Definition: histogram.h:181
static constexpr const char * numer_of_buckets_specified_str()
String representation of the JSON field "number-of-buckets-specified".
Definition: histogram.h:192
virtual ~Histogram()=default
Destructor.
virtual size_t get_num_distinct_values() const =0
Get the estimated number of distinct non-NULL values.
double get_sampling_rate() const
Definition: histogram.h:384
const enum_histogram_type m_hist_type
The type of this histogram.
Definition: histogram.h:265
virtual bool histogram_to_json(Json_object *json_object) const =0
Converts the histogram to a JSON object.
Definition: histogram.cc:255
const CHARSET_INFO * m_charset
The character set for the data stored.
Definition: histogram.h:175
static constexpr const char * last_updated_str()
String representation of the JSON field "last-updated".
Definition: histogram.h:184
LEX_CSTRING m_table_name
Name of the table this histogram represents.
Definition: histogram.h:274
Histogram(const Histogram &other)=delete
size_t get_num_buckets_specified() const
Definition: histogram.h:413
bool get_raw_selectivity(Item **items, size_t item_count, enum_operator op, double *selectivity) const
An internal function for getting a selectivity estimate prior to adustment.
Definition: histogram.cc:1621
static constexpr const char * equi_height_str()
String representation of the histogram type EQUI-HEIGHT.
Definition: histogram.h:166
double get_non_null_values_fraction() const
Definition: histogram.h:496
virtual Histogram * clone(MEM_ROOT *mem_root) const =0
Make a clone of the current histogram.
bool get_selectivity(Item **items, size_t item_count, enum_operator op, double *selectivity) const
Get selectivity estimation.
Definition: histogram.cc:1575
double m_null_values_fraction
The fraction of NULL values in the histogram (between 0.0 and 1.0).
Definition: histogram.h:172
const Value_map_type m_data_type
The type of the data this histogram contains.
Definition: histogram.h:268
const LEX_CSTRING get_database_name() const
Definition: histogram.h:358
LEX_CSTRING m_column_name
Name of the column this histogram represents.
Definition: histogram.h:277
bool get_selectivity_dispatcher(Item *item, const enum_operator op, const TYPELIB *typelib, double *selectivity) const
An internal function for getting the selecitvity estimation.
Definition: histogram.cc:1450
double apply_operator(const enum_operator op, const T &value) const
An internal function for applying the correct function for the given operator.
Definition: histogram.cc:1434
const CHARSET_INFO * get_character_set() const
Definition: histogram.h:381
const LEX_CSTRING get_table_name() const
Definition: histogram.h:363
double get_null_values_fraction() const
Definition: histogram.cc:300
MEM_ROOT * get_mem_root() const
Definition: histogram.h:353
enum_histogram_type get_histogram_type() const
Definition: histogram.h:373
LEX_CSTRING m_database_name
Name of the database this histogram represents.
Definition: histogram.h:271
bool store_histogram(THD *thd) const
Store this histogram to persistent storage (data dictionary).
Definition: histogram.cc:1155
static constexpr const char * histogram_type_str()
String representation of the JSON field "histogram-type".
Definition: histogram.h:154
bool histogram_data_type_to_json(Json_object *json_object) const
Write the data type of this histogram into a JSON object.
Definition: histogram.cc:532
static constexpr const char * singleton_str()
String representation of the histogram type SINGLETON.
Definition: histogram.h:163
bool extract_json_dom_value(const Json_dom *json_dom, T *out)
Return the value that is contained in the JSON DOM object.
static constexpr const char * sampling_rate_str()
Definition: histogram.h:189
virtual bool json_to_histogram(const Json_object &json_object)=0
Populate the histogram with data from the provided JSON object.
Definition: histogram.cc:479
double get_greater_than_selectivity_dispatcher(const T &value) const
Definition: histogram.cc:1367
const LEX_CSTRING get_column_name() const
Definition: histogram.h:368
enum_histogram_type
All supported histogram types in MySQL.
Definition: histogram.h:151
static constexpr const char * null_values_str()
String representation of the JSON field "null-values".
Definition: histogram.h:187
static MEM_ROOT mem_root
Definition: client_plugin.cc:109
This file includes constants used by all storage engines.
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
Definition: column_statistics.h:33
std::set< std::string, std::less< std::string >, Histogram_key_allocator< std::string > > columns_set
Definition: histogram.h:108
bool 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.
Definition: histogram.cc:1071
std::map< std::string, Message, std::less< std::string >, Histogram_key_allocator< std::pair< const std::string, Message > > > results_map
Definition: histogram.h:112
Message
Definition: histogram.h:79
enum_operator
The different operators we can ask histogram statistics for selectivity estimations.
Definition: histogram.h:118
bool 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.
Definition: histogram.cc:1286
Histogram * 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.
Definition: histogram.cc:310
bool find_histogram(THD *thd, const std::string &schema_name, const std::string &table_name, const std::string &column_name, const Histogram **histogram)
Definition: histogram.cc:1325
bool drop_all_histograms(THD *thd, TABLE_LIST &table, const dd::Table &table_definition, results_map &results)
Drop histograms for all columns in a given table.
Definition: histogram.cc:1061
static const double INVALID_NULL_VALUES_FRACTION
The default (and invalid) value for "m_null_values_fraction".
Definition: histogram.h:77
std::map< T, ha_rows, Histogram_comparator, value_map_allocator< T > > value_map_type
Definition: histogram.h:105
bool 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.
Definition: histogram.cc:874
Value_map_type
Datatypes that a Value_map and histogram can hold (including the invalid type).
Definition: value_map_type.h:32
const char * table_name
Definition: rules_table_service.cc:55
const char * db_name
Definition: rules_table_service.cc:54
required string type
Definition: replication_group_member_actions.proto:33
Definition: m_ctype.h:354
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
Definition: mysql_lex_string.h:39
Definition: table.h:2684
Definition: typelib.h:34
Definition: histogram.h:93
void * operator()(size_t s) const
Definition: histogram.cc:99