mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Changed the type of all double columns in the system statistical tables
mysql.column_stat, mysql.table_stat for the type DECIMAL(12,4). When cached the values from these columns are multiplied by factor 10^5 and stored as ulong numbers now.
This commit is contained in:
@ -124,14 +124,28 @@ typedef struct st_key {
|
||||
/* Statistical data on an index prefixes */
|
||||
class Index_statistics
|
||||
{
|
||||
public:
|
||||
private:
|
||||
static const uint Scale_factor_avg_frequency= 100000;
|
||||
/*
|
||||
The k-th element of this array contains the ratio N/D,
|
||||
The k-th element of this array contains the ratio N/D
|
||||
multiplied by the scale factor Scale_factor_avg_frequency,
|
||||
where N is the number of index entries without nulls
|
||||
in the first k components, and D is the number of distinct
|
||||
k-component prefixes among them
|
||||
*/
|
||||
double *avg_frequency;
|
||||
ulong *avg_frequency;
|
||||
|
||||
public:
|
||||
void init_avg_frequency(ulong *ptr) { avg_frequency= ptr; }
|
||||
bool avg_frequency_is_set() { return avg_frequency != NULL; }
|
||||
double get_avg_frequency(uint i)
|
||||
{
|
||||
return (double) avg_frequency[i] / Scale_factor_avg_frequency;
|
||||
}
|
||||
void set_avg_frequency(uint i, double val)
|
||||
{
|
||||
avg_frequency[i]= (ulong) (val * Scale_factor_avg_frequency);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
@ -159,8 +173,7 @@ typedef struct st_key {
|
||||
if (rec_per_key == 0)
|
||||
return 0;
|
||||
return (is_statistics_from_stat_tables ?
|
||||
(ulong) (100 * read_stat.avg_frequency[i]) / (double) 100 :
|
||||
(double) rec_per_key[i]);
|
||||
read_stat.get_avg_frequency(i) : (double) rec_per_key[i]);
|
||||
}
|
||||
} KEY;
|
||||
|
||||
|
Reference in New Issue
Block a user