summaryrefslogtreecommitdiff
path: root/sql/structs.h
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-07-26 17:50:08 -0700
committerIgor Babaev <igor@askmonty.org>2012-07-26 17:50:08 -0700
commit8c499274da21af6226785d51dd24968bf2b1befe (patch)
treebfd5380bc3c0967fde27ec8966054767ef9cbc67 /sql/structs.h
parentcb0a5c84b63a24d143160e38995cb35268f8eef4 (diff)
downloadmariadb-git-8c499274da21af6226785d51dd24968bf2b1befe.tar.gz
Performed re-factoring and re-structuring of the code for mwl#248:
- Moved the definitions of the classes to store data from persistent statistical tables into statistics.h, leaving in other internal data structures only references to the corresponding objects. - Defined class Column_statistics_collected derived from the class Column_statistics. This is a helper class to collect statistics on columns. - Moved references to read statistics to TABLE SHARE, leaving the the reference to the collected statistics in TABLE. - Added a new clone method for the class Field allowing to clone fields attached to table shares. It was was used to create fields for min/max values in the memory of the table share. A lso: - Added procedures to allocate memory for statistical data in the table share memory and in table memory. Also: - Added a test case demonstrating how ANALYZE could work in parallel to collect statistics on different indexes of the same table. - Added a test two demonstrate how two connections working simultaneously could allocate memory for statistical data in the table share memory.
Diffstat (limited to 'sql/structs.h')
-rw-r--r--sql/structs.h41
1 files changed, 5 insertions, 36 deletions
diff --git a/sql/structs.h b/sql/structs.h
index 4a70820586d..13bb0574b24 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -29,6 +29,7 @@
struct TABLE;
class Field;
+class Index_statistics;
class THD;
@@ -121,43 +122,16 @@ typedef struct st_key {
*/
ulong *rec_per_key;
- /* Statistical data on an index prefixes */
- class Index_statistics
- {
- private:
- static const uint Scale_factor_avg_frequency= 100000;
- /*
- 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
- */
- 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);
- }
- };
-
/*
This structure is used for statistical data on the index
that has been read from the statistical table index_stat
*/
- Index_statistics read_stat;
+ Index_statistics *read_stats;
/*
This structure is used for statistical data on the index that
is collected by the function collect_statistics_for_table
*/
- Index_statistics write_stat;
+ Index_statistics *collected_stats;
union {
int bdb_return_if_eq;
@@ -168,13 +142,8 @@ typedef struct st_key {
engine_option_value *option_list;
ha_index_option_struct *option_struct; /* structure with parsed options */
- inline double real_rec_per_key(uint i)
- {
- if (rec_per_key == 0)
- return 0;
- return (is_statistics_from_stat_tables ?
- read_stat.get_avg_frequency(i) : (double) rec_per_key[i]);
- }
+ double real_rec_per_key(uint i);
+
} KEY;