diff options
author | Igor Babaev <igor@askmonty.org> | 2012-06-25 22:33:07 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2012-06-25 22:33:07 -0700 |
commit | 4ff6fd34dae6315384d8c38ea69092cde09b78ba (patch) | |
tree | e5ec8fd533705ded464d84d40e1595d35b0ad5fc /sql/structs.h | |
parent | f549f495f7f621d2c7e35303ab84392ec519ecb0 (diff) | |
download | mariadb-git-4ff6fd34dae6315384d8c38ea69092cde09b78ba.tar.gz |
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.
Diffstat (limited to 'sql/structs.h')
-rw-r--r-- | sql/structs.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sql/structs.h b/sql/structs.h index 9949a72964b..4a70820586d 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -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; |