Commit f127e212 authored by Rich Prohaska's avatar Rich Prohaska

DB-757 compute cardinality when alter table analyze partition is run

parent 695ce3ad
set default_storage_engine='tokudb';
drop table if exists t;
create table t (id int, x int, y int, primary key (id), key (x), key (y))
partition by range(id)
( partition p0 values less than (10), partition p1 values less than maxvalue);
insert into t values (1,1,1),(2,1,2),(3,1,3),(4,1,4);
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 5 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
t 1 y 1 y A NULL NULL NULL YES BTREE
alter table t analyze partition p0;
Table Op Msg_type Msg_text
test.t analyze status OK
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 5 NULL NULL BTREE
t 1 x 1 x A 1 NULL NULL YES BTREE
t 1 y 1 y A 5 NULL NULL YES BTREE
alter table t analyze partition p1;
Table Op Msg_type Msg_text
test.t analyze status OK
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 5 NULL NULL BTREE
t 1 x 1 x A 1 NULL NULL YES BTREE
t 1 y 1 y A 5 NULL NULL YES BTREE
insert into t values (100,1,1),(200,2,1),(300,3,1),(400,4,1),(500,5,1);
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 9 NULL NULL BTREE
t 1 x 1 x A 2 NULL NULL YES BTREE
t 1 y 1 y A 9 NULL NULL YES BTREE
alter table t analyze partition p0;
Table Op Msg_type Msg_text
test.t analyze status OK
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 9 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
t 1 y 1 y A NULL NULL NULL YES BTREE
alter table t analyze partition p1;
Table Op Msg_type Msg_text
test.t analyze status OK
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 9 NULL NULL BTREE
t 1 x 1 x A 9 NULL NULL YES BTREE
t 1 y 1 y A 1 NULL NULL YES BTREE
drop table t;
source include/have_tokudb.inc;
source include/have_partition.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;
enable_warnings;
create table t (id int, x int, y int, primary key (id), key (x), key (y))
partition by range(id)
( partition p0 values less than (10), partition p1 values less than maxvalue);
insert into t values (1,1,1),(2,1,2),(3,1,3),(4,1,4);
show indexes from t;
alter table t analyze partition p0;
show indexes from t;
alter table t analyze partition p1;
show indexes from t;
insert into t values (100,1,1),(200,2,1),(300,3,1),(400,4,1),(500,5,1);
show indexes from t;
alter table t analyze partition p0;
show indexes from t;
alter table t analyze partition p1;
show indexes from t;
drop table t;
......@@ -133,7 +133,7 @@ int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) {
int result = HA_ADMIN_OK;
// stub out analyze if optimize is remapped to alter recreate + analyze
if (thd_sql_command(thd) != SQLCOM_ANALYZE) {
if (thd_sql_command(thd) != SQLCOM_ANALYZE && thd_sql_command(thd) != SQLCOM_ALTER_TABLE) {
TOKUDB_HANDLER_DBUG_RETURN(result);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment