mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Code cleanups part #3
This commit is contained in:
@@ -1967,7 +1967,7 @@ public:
|
|||||||
|
|
||||||
class Histogram_builder
|
class Histogram_builder
|
||||||
{
|
{
|
||||||
public:
|
protected:
|
||||||
Field *column; /* table field for which the histogram is built */
|
Field *column; /* table field for which the histogram is built */
|
||||||
uint col_length; /* size of this field */
|
uint col_length; /* size of this field */
|
||||||
ha_rows records; /* number of records the histogram is built for */
|
ha_rows records; /* number of records the histogram is built for */
|
||||||
@@ -1982,6 +1982,7 @@ public:
|
|||||||
/* number of distinct values that occured only once */
|
/* number of distinct values that occured only once */
|
||||||
ulonglong count_distinct_single_occurence;
|
ulonglong count_distinct_single_occurence;
|
||||||
|
|
||||||
|
public:
|
||||||
Histogram_builder(Field *col, uint col_len, ha_rows rows)
|
Histogram_builder(Field *col, uint col_len, ha_rows rows)
|
||||||
: column(col), col_length(col_len), records(rows)
|
: column(col), col_length(col_len), records(rows)
|
||||||
{
|
{
|
||||||
@@ -2934,7 +2935,8 @@ bool Column_statistics_collected::add()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows, double sample_fraction)
|
void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows,
|
||||||
|
double sample_fraction)
|
||||||
{
|
{
|
||||||
double val;
|
double val;
|
||||||
|
|
||||||
@@ -3486,7 +3488,7 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
|
|||||||
if (table_field->read_stats->histogram_type_on_disk != INVALID_HISTOGRAM)
|
if (table_field->read_stats->histogram_type_on_disk != INVALID_HISTOGRAM)
|
||||||
have_histograms= true;
|
have_histograms= true;
|
||||||
}
|
}
|
||||||
table_share->stats_cb.total_hist_size= have_histograms? 1:0; // total_hist_size
|
table_share->stats_cb.have_histograms= have_histograms;
|
||||||
|
|
||||||
/* Read statistics from the statistical table index_stats */
|
/* Read statistics from the statistical table index_stats */
|
||||||
stat_table= stat_tables[INDEX_STAT].table;
|
stat_table= stat_tables[INDEX_STAT].table;
|
||||||
@@ -3626,7 +3628,7 @@ int read_histograms_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
|
|||||||
{
|
{
|
||||||
TABLE_STATISTICS_CB *stats_cb= &table->s->stats_cb;
|
TABLE_STATISTICS_CB *stats_cb= &table->s->stats_cb;
|
||||||
DBUG_ENTER("read_histograms_for_table");
|
DBUG_ENTER("read_histograms_for_table");
|
||||||
|
|
||||||
if (stats_cb->start_histograms_load())
|
if (stats_cb->start_histograms_load())
|
||||||
{
|
{
|
||||||
Column_stat column_stat(stat_tables[COLUMN_STAT].table, table);
|
Column_stat column_stat(stat_tables[COLUMN_STAT].table, table);
|
||||||
@@ -4547,7 +4549,7 @@ double Histogram_binary::range_selectivity(Field *field,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check whether the table is one of the persistent statistical tables.
|
Check whether the table is one of the persistent statistical tables.
|
||||||
*/
|
*/
|
||||||
bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table)
|
bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table)
|
||||||
{
|
{
|
||||||
|
13
sql/table.h
13
sql/table.h
@@ -681,22 +681,19 @@ public:
|
|||||||
Table_statistics *table_stats; /* Structure to access the statistical data */
|
Table_statistics *table_stats; /* Structure to access the statistical data */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Total size of all histograms. A value of 0 means historams are not present,
|
Whether the table has histograms.
|
||||||
and histograms_are_ready() can finish sooner.
|
(If the table has none, histograms_are_ready() can finish sooner)
|
||||||
|
|
||||||
Currently we just set it to 1 when we expect to load histograms.
|
|
||||||
histogram-todo: rename this or even remove?
|
|
||||||
*/
|
*/
|
||||||
ulong total_hist_size;
|
bool have_histograms;
|
||||||
|
|
||||||
bool histograms_are_ready() const
|
bool histograms_are_ready() const
|
||||||
{
|
{
|
||||||
return !total_hist_size || hist_state.is_ready();
|
return !have_histograms || hist_state.is_ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool start_histograms_load()
|
bool start_histograms_load()
|
||||||
{
|
{
|
||||||
return total_hist_size && hist_state.start_load();
|
return have_histograms && hist_state.start_load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void end_histograms_load() { hist_state.end_load(); }
|
void end_histograms_load() { hist_state.end_load(); }
|
||||||
|
Reference in New Issue
Block a user