[Commits] 46c4df0: MDEV-9118 ANALYZE TABLE for Engine independent status fetchs blob/text columns without use

OleksandrByelkin sanja at mariadb.com
Fri Dec 18 12:15:27 EET 2015


revision-id: 46c4df07a8227cc3ddbf0ce3b3f8ac1d955c4ecc (mariadb-10.1.9-20-g46c4df0)
parent(s): 953d5680a3c050273a8f29253f7386984679f92b
committer: Oleksandr Byelkin
timestamp: 2015-12-18 11:15:27 +0100
message:

MDEV-9118 ANALYZE TABLE for Engine independent status fetchs blob/text columns without use

Do not include BLOB fields by default.

---
 mysql-test/r/statistics.result | 26 +++++++++++++++++++++++--
 mysql-test/t/statistics.test   | 11 +++++++++++
 sql/share/errmsg-utf8.txt      |  3 +++
 sql/sql_admin.cc               | 43 ++++++++++++++++++++++++++++++++++++------
 4 files changed, 75 insertions(+), 8 deletions(-)

diff --git a/mysql-test/r/statistics.result b/mysql-test/r/statistics.result
index bd6a084..fdda572 100644
--- a/mysql-test/r/statistics.result
+++ b/mysql-test/r/statistics.result
@@ -1212,6 +1212,7 @@ test	t2	PRIMARY	1	1.0000
 ANALYZE TABLE t1;
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	Engine-independent statistics collected
+test.t1	analyze	Warning	Engine-independent statistics are not collected for column 'b'
 test.t1	analyze	status	OK
 SELECT * FROM mysql.column_stats;
 db_name	table_name	column_name	min_value	max_value	nulls_ratio	avg_length	avg_frequency	hist_size	hist_type	histogram
@@ -1225,7 +1226,6 @@ test	t1	c	aaaa	dddddddd	0.1250	6.6571	7.0000	0	NULL	NULL
 test	t1	d	1989-03-12	1999-07-23	0.1500	3.0000	8.5000	0	NULL	NULL
 test	t1	e	0.01	0.112	0.2250	8.0000	6.2000	0	NULL	NULL
 test	t1	f	1	5	0.2000	1.0000	6.4000	0	NULL	NULL
-test	t1	b	NULL	NULL	0.2000	17.1250	NULL	NULL	NULL	NULL
 SELECT * FROM mysql.index_stats;
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	idx2	1	7.0000
@@ -1265,6 +1265,7 @@ set use_stat_tables='never';
 ANALYZE TABLE t1 PERSISTENT FOR ALL;
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	Engine-independent statistics collected
+test.t1	analyze	Warning	Engine-independent statistics are not collected for column 'b'
 test.t1	analyze	status	Table is already up to date
 SELECT * FROM mysql.table_stats;
 db_name	table_name	cardinality
@@ -1276,7 +1277,6 @@ test	t1	c	aaaa	dddddddd	0.1250	6.6571	7.0000	0	NULL	NULL
 test	t1	d	1989-03-12	1999-07-23	0.1500	3.0000	8.5000	0	NULL	NULL
 test	t1	e	0.01	0.112	0.2250	8.0000	6.2000	0	NULL	NULL
 test	t1	f	1	5	0.2000	1.0000	6.4000	0	NULL	NULL
-test	t1	b	NULL	NULL	0.2000	17.1250	NULL	NULL	NULL	NULL
 SELECT * FROM mysql.index_stats;
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	PRIMARY	1	1.0000
@@ -1291,6 +1291,28 @@ test	t1	idx4	3	NULL
 DELETE FROM mysql.table_stats;
 DELETE FROM mysql.column_stats;
 DELETE FROM mysql.index_stats;
+ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES();
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	Engine-independent statistics collected
+test.t1	analyze	Warning	Engine-independent statistics are not collected for column 'b'
+test.t1	analyze	status	Table is already up to date
+ANALYZE TABLE t1 PERSISTENT FOR columns(a,b) INDEXES();
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	Engine-independent statistics collected
+test.t1	analyze	Warning	Engine-independent statistics are not collected for column 'b'
+test.t1	analyze	status	Table is already up to date
+ANALYZE TABLE t1 PERSISTENT FOR columns(b) indexes(idx2);
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	Engine-independent statistics collected
+test.t1	analyze	Warning	Engine-independent statistics are not collected for column 'b'
+test.t1	analyze	status	Table is already up to date
+ANALYZE TABLE t1 PERSISTENT FOR columns() indexes(idx2);
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	Engine-independent statistics collected
+test.t1	analyze	status	Table is already up to date
+DELETE FROM mysql.table_stats;
+DELETE FROM mysql.column_stats;
+DELETE FROM mysql.index_stats;
 DROP TABLE t1,t2;
 set names utf8;
 CREATE DATABASE world;
diff --git a/mysql-test/t/statistics.test b/mysql-test/t/statistics.test
index 2c8dec3..3b57b8f 100644
--- a/mysql-test/t/statistics.test
+++ b/mysql-test/t/statistics.test
@@ -494,6 +494,17 @@ DELETE FROM mysql.table_stats;
 DELETE FROM mysql.column_stats;
 DELETE FROM mysql.index_stats;
 
+
+ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES();
+ANALYZE TABLE t1 PERSISTENT FOR columns(a,b) INDEXES();
+ANALYZE TABLE t1 PERSISTENT FOR columns(b) indexes(idx2);
+ANALYZE TABLE t1 PERSISTENT FOR columns() indexes(idx2);
+
+DELETE FROM mysql.table_stats;
+DELETE FROM mysql.column_stats;
+DELETE FROM mysql.index_stats;
+
+
 DROP TABLE t1,t2;
 
 set names utf8;
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 59908dc..178d1dd 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -7136,3 +7136,6 @@ ER_KILL_QUERY_DENIED_ERROR
         eng "You are not owner of query %lu"
         ger "Sie sind nicht Eigentümer von Abfrage %lu"
         rus "Вы не являетесь владельцем запроса %lu"
+ER_NO_EIS_FOR_FIELD
+        eng "Engine-independent statistics are not collected for column '%s'"
+        ukr "Незалежна від типу таблиці статистика не збирається для стовбця '%s'"
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 0787aa9..7d3d96b 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -691,11 +691,26 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
         compl_result_code= result_code= HA_ADMIN_INVALID;
       }
 
+      uint elements= 0;
+
       if (!lex->column_list)
-      { 
-        uint fields= 0;
-        for ( ; *field_ptr; field_ptr++, fields++) ;         
-        bitmap_set_prefix(tab->read_set, fields);
+      {
+        bitmap_clear_all(tab->read_set);
+        for (uint fields= 0; *field_ptr; field_ptr++, fields++)
+        {
+          enum enum_field_types type= (*field_ptr)->type();
+          if (type < MYSQL_TYPE_MEDIUM_BLOB ||
+              type > MYSQL_TYPE_BLOB)
+          {
+            bitmap_set_bit(tab->read_set, fields);
+            elements++;
+          }
+          else
+            push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+                               ER_NO_EIS_FOR_FIELD,
+                               ER_THD(thd, ER_NO_EIS_FOR_FIELD),
+                               (*field_ptr)->field_name);
+        }
       }
       else
       {
@@ -713,14 +728,27 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
             compl_result_code= result_code= HA_ADMIN_INVALID;
             break;
           }
-          bitmap_set_bit(tab->read_set, pos-1);
-        } 
+          pos--;
+          enum enum_field_types type= tab->field[pos]->type();
+          if (type < MYSQL_TYPE_MEDIUM_BLOB ||
+              type > MYSQL_TYPE_BLOB)
+          {
+            bitmap_set_bit(tab->read_set, pos);
+            elements++;
+          }
+          else
+            push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+                               ER_NO_EIS_FOR_FIELD,
+                               ER_THD(thd, ER_NO_EIS_FOR_FIELD),
+                               column_name->str);
+        }
         tab->file->column_bitmaps_signal(); 
       }
       
       if (!lex->index_list)
       {
         tab->keys_in_use_for_query.init(tab->s->keys);
+        elements+= tab->s->keys;
       }
       else
       {
@@ -739,8 +767,11 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
             break;
           }
           tab->keys_in_use_for_query.set_bit(--pos);
+          elements++;
         }  
       }
+      if (unlikely(!elements && result_code == HA_ADMIN_OK))
+        result_code= HA_ADMIN_ALREADY_DONE;
     }
 
     if (result_code == HA_ADMIN_OK)


More information about the commits mailing list