From 7e9ffc69ecd1bddf731391b01e6be221efb6f8ef Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 29 Jul 2020 23:26:09 +0300 Subject: MDEV-21472: ALTER TABLE ... ANALYZE PARTITION ... with EITS reads and locks all rows Do not collect EITS statistics for this statement: ALTER TABLE t ANALYZE PARTITION p EITS stats are currently global, not per-partition. Collecting global stats when we are asked to process just one partition causes issues for DBAs. --- sql/sql_admin.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sql/sql_admin.cc') diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 4afaff58223..beecf3fae64 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -727,8 +727,18 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, { compl_result_code= result_code= HA_ADMIN_INVALID; } + + /* + The check for Alter_info::ALTER_ADMIN_PARTITION implements this logic: + do not collect EITS STATS for this syntax: + ALTER TABLE ... ANALYZE PARTITION p + EITS statistics is global (not per-partition). Collecting global stats + is much more expensive processing just one partition, so the most + appropriate action is to just not collect EITS stats for this command. + */ collect_eis= (table->table->s->table_category == TABLE_CATEGORY_USER && + !(lex->alter_info.flags &= Alter_info::ALTER_ADMIN_PARTITION) && (get_use_stat_tables_mode(thd) > NEVER || lex->with_persistent_for_clause)); -- cgit v1.2.1 From 8bca92c8845212ea96be404e664f4cbb45f93e2d Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 3 Aug 2020 13:03:37 +0300 Subject: Fix the typo in fix for MDEV-21472 --- sql/sql_admin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_admin.cc') diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index beecf3fae64..3f518312526 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -738,7 +738,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, */ collect_eis= (table->table->s->table_category == TABLE_CATEGORY_USER && - !(lex->alter_info.flags &= Alter_info::ALTER_ADMIN_PARTITION) && + !(lex->alter_info.flags & Alter_info::ALTER_ADMIN_PARTITION) && (get_use_stat_tables_mode(thd) > NEVER || lex->with_persistent_for_clause)); -- cgit v1.2.1