From 9d0fbcc4007478a9b54db6402a2dfd9c4c400554 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 17 Sep 2021 14:53:54 +0300 Subject: [PATCH 001/123] Improve comments in the optimizer --- sql/sql_select.cc | 11 +++++++++++ sql/sql_window.cc | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9b9d93d182e..87796d53991 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -26818,6 +26818,17 @@ change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array, for (uint i= 0; (item= it++); i++) { Field *field; + /* + SUM_FUNC_ITEM will be replaced by the calculated value which is + stored in the temporary table. + The first part of the following test is for items that are expressions + with SUM_FUNC_ITEMS, like 'sum(a)+1'. In this case we keep the original + item, which contain an Item_ref that points to the SUM_FUNC_ITEM that + will be replaced with a pointer to the calculated value. + The second test is for window functions. Window functions contains + only pointers to Item_refs, which will be adjusted to point to the + temporary table. + */ enum Item::Type item_type= item->type(); if ((item->with_sum_func() && item_type != Item::SUM_FUNC_ITEM) || item->with_window_func()) diff --git a/sql/sql_window.cc b/sql/sql_window.cc index c0acecd138f..c9f2256ff16 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -423,6 +423,16 @@ ORDER *st_select_lex::find_common_window_func_partition_fields(THD *thd) #define CMP_GT_C 1 // Greater than and compatible #define CMP_GT 2 // Greater then + +/* + This function is used for sorting ORDER/PARTITION BY clauses of window + functions and so must implement an order relation on ORDER BY clauses" + + It is called by a sorting function. + The function return's CMP_EQ (=0) if the values are identical. + If not equal, it returns a stable value < or > than 0. +*/ + static int compare_order_elements(ORDER *ord1, int weight1, ORDER *ord2, int weight2) From 8b977a6c3a2dc7e434606681d94f39884e29866d Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 27 Dec 2021 18:51:00 +0200 Subject: [PATCH 002/123] MDEV-14907 FEDERATEDX doesn't respect DISTINCT This is a minor cleanup of the original commit --- storage/federated/ha_federated.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/storage/federated/ha_federated.h b/storage/federated/ha_federated.h index 0c6285f3ac6..a2c23a330c1 100644 --- a/storage/federated/ha_federated.h +++ b/storage/federated/ha_federated.h @@ -240,16 +240,11 @@ public: void position(const uchar *record); //required /* A ref is a pointer inside a local buffer. It is not comparable to - other ref's. This is never called as HA_NON_COMPARABLE_ROWID is set. + other ref's. */ int cmp_ref(const uchar *ref1, const uchar *ref2) { -#ifdef NOT_YET - DBUG_ASSERT(0); - return 0; -#else - return handler::cmp_ref(ref1,ref2); /* Works if table scan is used */ -#endif + return handler::cmp_ref(ref1,ref2); /* Works if table scan is used */ } int info(uint); //required int extra(ha_extra_function operation); @@ -285,4 +280,3 @@ public: int execute_simple_query(const char *query, int len); int reset(void); }; - From c443dbff0e46ea5b09588625fecd72a3711a697a Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 5 Oct 2021 17:08:16 +0300 Subject: [PATCH 003/123] Ensure that test_quick_select doesn't return more rows than in the table Other changes: - In test_quick_select(), assume that if table->used_stats_records is 0 then the table has 0 rows. - Fixed prepare_simple_select() to populate table->used_stat_records - Enusre that set_statistics_for_tables() doesn't cause used_stats_records to be 0 when using stat_tables. - To get blackhole to work with replication, set stats.records to 2 so that test_quick_select() doesn't assume the table is empty. --- .../main/analyze_stmt_privileges2.result | 8 +++--- mysql-test/main/derived_cond_pushdown.result | 6 ++--- mysql-test/main/mysql_upgrade_noengine.result | 4 +-- mysql-test/main/selectivity_innodb.result | 2 +- mysql-test/main/sql_safe_updates.result | 13 +++++++--- mysql-test/main/sql_safe_updates.test | 7 +++-- mysql-test/main/stat_tables.result | 2 +- mysql-test/main/stat_tables_innodb.result | 2 +- mysql-test/suite/gcol/r/gcol_bugfixes.result | 4 +-- mysql-test/suite/innodb/r/innodb_mysql.result | 12 ++++----- .../r/innodb_stats_fetch_corrupted.result | 4 +-- .../r/innodb_stats_fetch_nonexistent.result | 2 +- sql/opt_range.cc | 26 ++++++++++++------- sql/sql_help.cc | 23 +++++++++------- sql/sql_statistics.cc | 9 +++++-- storage/blackhole/ha_blackhole.cc | 11 ++++++++ 16 files changed, 85 insertions(+), 50 deletions(-) diff --git a/mysql-test/main/analyze_stmt_privileges2.result b/mysql-test/main/analyze_stmt_privileges2.result index 2b75f736a22..4a499e0c7ef 100644 --- a/mysql-test/main/analyze_stmt_privileges2.result +++ b/mysql-test/main/analyze_stmt_privileges2.result @@ -1445,10 +1445,10 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f DELETE FROM t1 WHERE a = 10; EXPLAIN DELETE FROM t1 WHERE a = 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE ANALYZE DELETE FROM t1 WHERE a = 10; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1 0.00 100.00 100.00 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE DELETE FROM t1 USING t1, t2; EXPLAIN DELETE FROM t1 USING t1, t2; id select_type table type possible_keys key key_len ref rows Extra @@ -1790,10 +1790,10 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f DELETE FROM t1 WHERE a = 10; EXPLAIN DELETE FROM t1 WHERE a = 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE ANALYZE DELETE FROM t1 WHERE a = 10; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1 0.00 100.00 100.00 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE DELETE FROM t1 USING t1, t2; EXPLAIN DELETE FROM t1 USING t1, t2; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index e07f2550297..90ef51b005a 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -19281,7 +19281,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table Warnings: -Note 1003 /* select#1 */ select NULL AS `f`,`v2`.`f` AS `f` from `test`.`t1` `a` straight_join `test`.`t1` `b` join `test`.`v2` where 0 +Note 1003 /* select#1 */ select NULL AS `f`,NULL AS `f` from `test`.`t1` `a` straight_join `test`.`t1` `b` join `test`.`v2` where 0 DROP VIEW v1,v2; DROP TABLE t1; # @@ -19749,7 +19749,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 1 PRIMARY ref key0 key0 5 test.t3.id 2 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 -2 DERIVED cp2 range NULL a 5 NULL 8 Using index for group-by +2 DERIVED cp2 range NULL a 5 NULL 7 Using index for group-by explain format=json select * from t1, (select a from t1 cp2 group by a) dt, t3 where dt.a = t1.a and t1.a = t3.id and t1.a in (select a from t2); EXPLAIN @@ -19830,7 +19830,7 @@ EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], - "rows": 8, + "rows": 7, "filtered": 100, "using_index_for_group_by": true } diff --git a/mysql-test/main/mysql_upgrade_noengine.result b/mysql-test/main/mysql_upgrade_noengine.result index 459a1a6ce34..830b574fb9c 100644 --- a/mysql-test/main/mysql_upgrade_noengine.result +++ b/mysql-test/main/mysql_upgrade_noengine.result @@ -11,7 +11,7 @@ table_name t1 table_type BASE TABLE engine BLACKHOLE row_format Fixed -table_rows 0 +table_rows 2 data_length 0 table_comment select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2'; @@ -610,7 +610,7 @@ table_name t1 table_type BASE TABLE engine BLACKHOLE row_format Fixed -table_rows 0 +table_rows 2 data_length 0 table_comment select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2'; diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index 76093f16cd7..5a4281395ed 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -946,7 +946,7 @@ set optimizer_switch='index_condition_pushdown=off'; EXPLAIN EXTENDED SELECT * FROM t1, t2 WHERE a > 9; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range a a 5 NULL 1 0.00 Using where +1 SIMPLE t1 range a a 5 NULL 1 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` > 9 diff --git a/mysql-test/main/sql_safe_updates.result b/mysql-test/main/sql_safe_updates.result index f2944e60489..099aaa9bca6 100644 --- a/mysql-test/main/sql_safe_updates.result +++ b/mysql-test/main/sql_safe_updates.result @@ -9,18 +9,23 @@ select @@sql_safe_updates; # create table t1 (a int, b int, primary key (a), key (b)); update t1 set b=2 where a=1 or b=2; -ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column explain update t1 set b=2 where a=1 or b=2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE delete from t1 where a=1 or b=2; -ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column explain delete from t1 where a=1 or b=2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8); +explain update t1 set b=2 where a=1 or b=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge PRIMARY,b PRIMARY,b 4,5 NULL 2 Using union(PRIMARY,b); Using where; Using buffer update t1 set b=2 where a=1 or b=2; +set @@optimizer_switch="index_merge=off"; +update t1 set b=2 where a=1 or b=2; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column delete from t1 where a=1 or b=2; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column drop table t1; # # End of 10.3 tests diff --git a/mysql-test/main/sql_safe_updates.test b/mysql-test/main/sql_safe_updates.test index 25fe4a15ca2..becabb6881e 100644 --- a/mysql-test/main/sql_safe_updates.test +++ b/mysql-test/main/sql_safe_updates.test @@ -7,14 +7,17 @@ select @@sql_safe_updates; --echo # MDEV-18304 sql_safe_updates does not work with OR clauses --echo # create table t1 (a int, b int, primary key (a), key (b)); ---error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE update t1 set b=2 where a=1 or b=2; explain update t1 set b=2 where a=1 or b=2; ---error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE delete from t1 where a=1 or b=2; explain delete from t1 where a=1 or b=2; insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8); +explain update t1 set b=2 where a=1 or b=2; update t1 set b=2 where a=1 or b=2; +set @@optimizer_switch="index_merge=off"; +--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE +update t1 set b=2 where a=1 or b=2; +--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE delete from t1 where a=1 or b=2; drop table t1; diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result index 379e9737e1c..b58a3270e26 100644 --- a/mysql-test/main/stat_tables.result +++ b/mysql-test/main/stat_tables.result @@ -412,7 +412,7 @@ EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index -1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where ANALYZE TABLE t2; Table Op Msg_type Msg_text test.t2 analyze status Engine-independent statistics collected diff --git a/mysql-test/main/stat_tables_innodb.result b/mysql-test/main/stat_tables_innodb.result index 5b62f228b1f..13f990ed54f 100644 --- a/mysql-test/main/stat_tables_innodb.result +++ b/mysql-test/main/stat_tables_innodb.result @@ -444,7 +444,7 @@ EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index -1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where ANALYZE TABLE t2; Table Op Msg_type Msg_text test.t2 analyze status Engine-independent statistics collected diff --git a/mysql-test/suite/gcol/r/gcol_bugfixes.result b/mysql-test/suite/gcol/r/gcol_bugfixes.result index f124ebe611c..7b70f61df03 100644 --- a/mysql-test/suite/gcol/r/gcol_bugfixes.result +++ b/mysql-test/suite/gcol/r/gcol_bugfixes.result @@ -638,10 +638,10 @@ DEFAULT SUBSTRING_INDEX(USER(),'@',1) ); EXPLAIN UPDATE gafld SET nuigafld = 0 WHERE nuigafld = 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE gafld ALL NULL NULL NULL NULL 1 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE EXPLAIN UPDATE gafld SET nuigafld = 0 WHERE nuigafld = 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE gafld ALL NULL NULL NULL NULL 1 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE DROP TABLE gafld; # (duplicate) MDEV-17653 replace into generated columns is unstable # Some columns are snipped from the MDEV test diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index aa8cc118ce6..3383d4b6826 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -191,8 +191,8 @@ min(7) 7 explain select min(7) from t2i join t1i; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1i ALL NULL NULL NULL NULL 0 -1 SIMPLE t2i ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) +1 SIMPLE t2i ALL NULL NULL NULL NULL 1 +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) select min(7) from t2i join t1i; min(7) NULL @@ -207,8 +207,8 @@ max(7) 7 explain select max(7) from t2i join t1i; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1i ALL NULL NULL NULL NULL 0 -1 SIMPLE t2i ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) +1 SIMPLE t2i ALL NULL NULL NULL NULL 1 +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) select max(7) from t2i join t1i; max(7) NULL @@ -239,7 +239,7 @@ select 1, max(1) from t1i where 1=99; explain select count(*), min(7), max(7) from t1m, t1i; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1m system NULL NULL NULL NULL 0 Const row not found -1 SIMPLE t1i ALL NULL NULL NULL NULL 0 +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 select count(*), min(7), max(7) from t1m, t1i; count(*) min(7) max(7) 0 NULL NULL @@ -253,7 +253,7 @@ count(*) min(7) max(7) explain select count(*), min(7), max(7) from t2m, t1i; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2m system NULL NULL NULL NULL 1 -1 SIMPLE t1i ALL NULL NULL NULL NULL 0 +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 select count(*), min(7), max(7) from t2m, t1i; count(*) min(7) max(7) 0 NULL NULL diff --git a/mysql-test/suite/innodb/r/innodb_stats_fetch_corrupted.result b/mysql-test/suite/innodb/r/innodb_stats_fetch_corrupted.result index 1f8471304d5..b1e6bb7fa72 100644 --- a/mysql-test/suite/innodb/r/innodb_stats_fetch_corrupted.result +++ b/mysql-test/suite/innodb/r/innodb_stats_fetch_corrupted.result @@ -24,7 +24,7 @@ FROM information_schema.statistics WHERE table_name = 'test_ps_fetch_corrupted' ORDER BY index_name, seq_in_index; seq_in_index 1 column_name a -cardinality 0 +cardinality 1 SELECT table_rows, avg_row_length, max_data_length, index_length FROM information_schema.tables WHERE table_name = 'test_ps_fetch_corrupted'; table_rows 0 @@ -38,7 +38,7 @@ FROM information_schema.statistics WHERE table_name = 'test_ps_fetch_corrupted' ORDER BY index_name, seq_in_index; seq_in_index 1 column_name a -cardinality 0 +cardinality 1 SELECT table_rows, avg_row_length, max_data_length, index_length FROM information_schema.tables WHERE table_name = 'test_ps_fetch_corrupted'; table_rows 0 diff --git a/mysql-test/suite/innodb/r/innodb_stats_fetch_nonexistent.result b/mysql-test/suite/innodb/r/innodb_stats_fetch_nonexistent.result index 91bb2bf3ecd..a6627417d1a 100644 --- a/mysql-test/suite/innodb/r/innodb_stats_fetch_nonexistent.result +++ b/mysql-test/suite/innodb/r/innodb_stats_fetch_nonexistent.result @@ -22,7 +22,7 @@ FROM information_schema.statistics WHERE table_name = 'test_ps_fetch_nonexistent ORDER BY index_name, seq_in_index; seq_in_index 1 column_name a -cardinality 0 +cardinality 1 SELECT table_rows, avg_row_length, max_data_length, index_length FROM information_schema.tables WHERE table_name = 'test_ps_fetch_nonexistent'; table_rows 0 diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 05443ea78bf..fa44b03b109 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2683,11 +2683,16 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, Item *notnull_cond= NULL; TABLE_READ_PLAN *best_trp= NULL; SEL_ARG **backup_keys= 0; + ha_rows table_records= head->stat_records(); + /* We trust that if stat_records() is 0 the table is really empty! */ + bool impossible_range= table_records == 0; DBUG_ENTER("SQL_SELECT::test_quick_select"); DBUG_PRINT("enter",("keys_to_use: %lu prev_tables: %lu const_tables: %lu", (ulong) keys_to_use.to_ulonglong(), (ulong) prev_tables, (ulong) const_tables)); - DBUG_PRINT("info", ("records: %lu", (ulong) head->stat_records())); + DBUG_PRINT("info", ("records: %llu", (ulonglong) table_records)); + DBUG_ASSERT(table_records || !head->file->stats.records); + delete quick; quick=0; needed_reg.clear_all(); @@ -2696,10 +2701,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, DBUG_ASSERT(!head->is_filled_at_execution()); if (keys_to_use.is_clear_all() || head->is_filled_at_execution()) DBUG_RETURN(0); - records= head->stat_records(); + records= table_records; notnull_cond= head->notnull_cond; - if (!records) - records++; /* purecov: inspected */ if (head->file->ha_table_flags() & HA_NON_COMPARABLE_ROWID) only_single_index_range_scan= 1; @@ -2726,8 +2729,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, DBUG_PRINT("info",("Time to scan table: %g", read_time)); - Json_writer_object table_records(thd); - table_records.add_table_name(head); + Json_writer_object table_info(thd); + table_info.add_table_name(head); Json_writer_object trace_range(thd, "range_analysis"); { @@ -2893,7 +2896,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, { if (tree->type == SEL_TREE::IMPOSSIBLE) { - records=0L; /* Return -1 from this function. */ + records= 0; + impossible_range= 1; /* Return -1 from this function. */ read_time= (double) HA_POS_ERROR; trace_range.add("impossible_range", true); goto free_mem; @@ -2992,7 +2996,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, } if (optimizer_flag(thd, OPTIMIZER_SWITCH_INDEX_MERGE) && - head->stat_records() != 0 && !only_single_index_range_scan) + table_records != 0 && !only_single_index_range_scan) { /* Try creating index_merge/ROR-union scan. */ SEL_IMERGE *imerge; @@ -3034,7 +3038,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, if ((group_trp= get_best_group_min_max(¶m, tree, read_time))) { param.table->opt_range_condition_rows= MY_MIN(group_trp->records, - head->stat_records()); + table_records); Json_writer_object grp_summary(thd, "best_group_range_summary"); if (unlikely(thd->trace_started())) @@ -3059,6 +3063,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, if (best_trp) { records= best_trp->records; + impossible_range= records == 0; // No matching rows if (!(quick= best_trp->make_quick(¶m, TRUE)) || quick->init()) { delete quick; @@ -3092,7 +3097,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, Assume that if the user is using 'limit' we will only need to scan limit rows if we are using a key */ - DBUG_RETURN(records ? MY_TEST(quick) : -1); + set_if_smaller(records, table_records); + DBUG_RETURN(impossible_range ? -1 : MY_TEST(quick)); } /**************************************************************************** diff --git a/sql/sql_help.cc b/sql/sql_help.cc index f9932f11798..51fdd58b9c4 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -664,16 +664,19 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, /* Assume that no indexes cover all required fields */ table->covering_keys.clear_all(); + table->file->info(HA_STATUS_VARIABLE); + table->used_stat_records= table->file->stats.records; SQL_SELECT *res= make_select(table, 0, 0, cond, 0, 0, error); - if (unlikely(*error) || - (likely(res) && unlikely(res->check_quick(thd, 0, HA_POS_ERROR))) || - (likely(res) && res->quick && unlikely(res->quick->reset()))) - { - delete res; - res=0; - } - return res; + if (unlikely(!res) || unlikely(*error)) + goto error; + (void) res->check_quick(thd, 0, HA_POS_ERROR); + if (!res->quick || res->quick->reset() == 0) + return res; + +error: + delete res; + return 0; } /* @@ -1076,7 +1079,9 @@ error: new_trans.restore_old_transaction(); error2: - DBUG_RETURN(TRUE); + if (!thd->is_error()) + my_eof(thd); + DBUG_RETURN(thd->is_error()); } diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 40760c1e2eb..5930ebd8256 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -3741,10 +3741,15 @@ void set_statistics_for_table(THD *thd, TABLE *table) { TABLE_STATISTICS_CB *stats_cb= &table->s->stats_cb; Table_statistics *read_stats= stats_cb->table_stats; - table->used_stat_records= + + /* + The MAX below is to ensure that we don't return 0 rows for a table if it + not guaranteed to be empty. + */ + table->used_stat_records= (!check_eits_preferred(thd) || !table->stats_is_read || read_stats->cardinality_is_null) ? - table->file->stats.records : read_stats->cardinality; + table->file->stats.records : MY_MAX(read_stats->cardinality, 1); /* For partitioned table, EITS statistics is based on data from all partitions. diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index 0134032351e..343f3c70286 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -182,6 +182,17 @@ int ha_blackhole::info(uint flag) DBUG_ENTER("ha_blackhole::info"); bzero((char*) &stats, sizeof(stats)); + /* + The following is required to get replication to work as otherwise + test_quick_select() will think the table is empty and thus any + update/delete will not have any rows to update. + */ + stats.records= 2; + /* + Block size should not be 0 as this will cause division by zero + in scan_time() + */ + stats.block_size= 8192; if (flag & HA_STATUS_AUTO) stats.auto_increment_value= 1; DBUG_RETURN(0); From 87d4d7232c72b525451972cea28fc50eb7033b29 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 6 Oct 2021 02:39:59 +0300 Subject: [PATCH 004/123] Limit calculated rows to the number of rows in the table The result file changes are mainly that number of rows is one smaller for some queries with DISTINCT or GROUP BY --- mysql-test/main/distinct.result | 6 ++-- mysql-test/main/explain_innodb.result | 2 +- mysql-test/main/group_by.result | 4 +-- mysql-test/main/group_min_max.result | 2 +- mysql-test/main/opt_trace.result | 32 +++++++++---------- mysql-test/main/subselect_mat.result | 6 ++-- mysql-test/main/subselect_sj_mat.result | 6 ++-- .../suite/gcol/r/gcol_select_innodb.result | 2 +- .../suite/gcol/r/gcol_select_myisam.result | 2 +- .../suite/vcol/r/vcol_select_innodb.result | 2 +- .../suite/vcol/r/vcol_select_myisam.result | 2 +- sql/opt_range.cc | 14 +++++--- 12 files changed, 43 insertions(+), 37 deletions(-) diff --git a/mysql-test/main/distinct.result b/mysql-test/main/distinct.result index 888d3143f2c..cad56fdc92a 100644 --- a/mysql-test/main/distinct.result +++ b/mysql-test/main/distinct.result @@ -538,10 +538,10 @@ PRIMARY KEY (a,b)); INSERT INTO t2 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); EXPLAIN SELECT DISTINCT a FROM t2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range NULL PRIMARY 4 NULL 4 Using index for group-by +1 SIMPLE t2 range NULL PRIMARY 4 NULL 3 Using index for group-by EXPLAIN SELECT DISTINCT a,a FROM t2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range NULL PRIMARY 4 NULL 4 Using index for group-by +1 SIMPLE t2 range NULL PRIMARY 4 NULL 3 Using index for group-by EXPLAIN SELECT DISTINCT b,a FROM t2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index @@ -756,7 +756,7 @@ INSERT INTO t1(a, b, c) VALUES (1, 1, 1), (1, 2, 3); EXPLAIN SELECT DISTINCT a, b, d, c FROM t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL PRIMARY 16 NULL 7 Using index for group-by; Using temporary +1 SIMPLE t1 range NULL PRIMARY 16 NULL 6 Using index for group-by; Using temporary SELECT DISTINCT a, b, d, c FROM t1; a b d c 1 1 0 1 diff --git a/mysql-test/main/explain_innodb.result b/mysql-test/main/explain_innodb.result index b46665c279c..0bdd5a44985 100644 --- a/mysql-test/main/explain_innodb.result +++ b/mysql-test/main/explain_innodb.result @@ -15,6 +15,6 @@ explain SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 DERIVED t1 range NULL id 53 NULL 2 Using index for group-by +2 DERIVED t1 range NULL id 53 NULL 1 Using index for group-by SET GLOBAL slow_query_log = @sql_tmp; drop table t1; diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index ba403fa8b73..994805303f2 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -1578,7 +1578,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT a FROM t1 FORCE INDEX FOR JOIN (i2) FORCE INDEX FOR GROUP BY (i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL i2 4 NULL 145 Using index for group-by +1 SIMPLE t1 range NULL i2 4 NULL 144 Using index for group-by EXPLAIN SELECT a FROM t1 USE INDEX () IGNORE INDEX (i2); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 144 @@ -1701,7 +1701,7 @@ NULL 1 1 2 EXPLAIN SELECT a from t2 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range NULL a 5 NULL 7 Using index for group-by +1 SIMPLE t2 range NULL a 5 NULL 6 Using index for group-by SELECT a from t2 GROUP BY a; a NULL diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index 2b8b10b29b9..0b29dbf7329 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -3664,7 +3664,7 @@ f1 COUNT(DISTINCT f2) 3 4 explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL f1 5 NULL 9 Using index for group-by +1 SIMPLE t1 range NULL f1 5 NULL 8 Using index for group-by drop table t1; # End of test#50539. # diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 2d52392dedb..219ec177329 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -1408,7 +1408,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL a 20 NULL 8 Using where; Using index for group-by +1 SIMPLE t1 range NULL a 20 NULL 7 Using where; Using index for group-by select * from information_schema.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { @@ -1495,8 +1495,8 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "index": "a", "covering": true, "ranges": ["(2,3) <= (b,c) <= (2,3)"], - "rows": 8, - "cost": 2.2 + "rows": 7, + "cost": 2.05 } ] }, @@ -1507,8 +1507,8 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "min_aggregate": true, "max_aggregate": false, "distinct_aggregate": false, - "rows": 8, - "cost": 2.2, + "rows": 7, + "cost": 2.05, "key_parts_used_for_access": ["a", "b", "c"], "ranges": ["(2,3) <= (b,c) <= (2,3)"], "chosen": true @@ -1521,13 +1521,13 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "min_aggregate": true, "max_aggregate": false, "distinct_aggregate": false, - "rows": 8, - "cost": 2.2, + "rows": 7, + "cost": 2.05, "key_parts_used_for_access": ["a", "b", "c"], "ranges": ["(2,3) <= (b,c) <= (2,3)"] }, - "rows_for_plan": 8, - "cost_for_plan": 2.2, + "rows_for_plan": 7, + "cost_for_plan": 2.05, "chosen": true } } @@ -1545,16 +1545,16 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "considered_access_paths": [ { "access_type": "index_merge", - "resulting_rows": 8, - "cost": 2.2, + "resulting_rows": 7, + "cost": 2.05, "chosen": true, "use_tmp_table": true } ], "chosen_access_method": { "type": "index_merge", - "records": 8, - "cost": 2.2, + "records": 7, + "cost": 2.05, "uses_join_buffering": false } } @@ -1564,9 +1564,9 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { { "plan_prefix": [], "table": "t1", - "rows_for_plan": 8, - "cost_for_plan": 3.8, - "cost_for_sorting": 8 + "rows_for_plan": 7, + "cost_for_plan": 3.45, + "cost_for_sorting": 7 } ] }, diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result index 25465fe650a..05f36d6fceb 100644 --- a/mysql-test/main/subselect_mat.result +++ b/mysql-test/main/subselect_mat.result @@ -1142,7 +1142,7 @@ a explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by +1 PRIMARY t1 range NULL it1a 4 NULL 7 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`c`)))) @@ -1154,7 +1154,7 @@ create index iab on t1(a, b); explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by +1 PRIMARY t1 range NULL it1a 4 NULL 7 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`c`)))) @@ -1166,7 +1166,7 @@ explain extended select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 range NULL iab 4 NULL 8 100.00 Using index for group-by +1 PRIMARY t1 range NULL iab 4 NULL 7 100.00 Using index for group-by 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result index 61a7ff25569..c68b740b022 100644 --- a/mysql-test/main/subselect_sj_mat.result +++ b/mysql-test/main/subselect_sj_mat.result @@ -1181,7 +1181,7 @@ a explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by +1 PRIMARY t1 range NULL it1a 4 NULL 7 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`c`)))) @@ -1193,7 +1193,7 @@ create index iab on t1(a, b); explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by +1 PRIMARY t1 range NULL it1a 4 NULL 7 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`c`)))) @@ -1205,7 +1205,7 @@ explain extended select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 range NULL iab 4 NULL 8 100.00 Using index for group-by +1 PRIMARY t1 range NULL iab 4 NULL 7 100.00 Using index for group-by 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: diff --git a/mysql-test/suite/gcol/r/gcol_select_innodb.result b/mysql-test/suite/gcol/r/gcol_select_innodb.result index 72d1e9f320c..6fbe4883a51 100644 --- a/mysql-test/suite/gcol/r/gcol_select_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_select_innodb.result @@ -146,7 +146,7 @@ count(distinct c) 3 explain select count(distinct c) from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by +1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by ### ### filesort & range-based utils ### diff --git a/mysql-test/suite/gcol/r/gcol_select_myisam.result b/mysql-test/suite/gcol/r/gcol_select_myisam.result index 0d18976f3bf..d4319d7b555 100644 --- a/mysql-test/suite/gcol/r/gcol_select_myisam.result +++ b/mysql-test/suite/gcol/r/gcol_select_myisam.result @@ -146,7 +146,7 @@ count(distinct c) 3 explain select count(distinct c) from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by +1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by ### ### filesort & range-based utils ### diff --git a/mysql-test/suite/vcol/r/vcol_select_innodb.result b/mysql-test/suite/vcol/r/vcol_select_innodb.result index 40308b6e072..57a17cbe468 100644 --- a/mysql-test/suite/vcol/r/vcol_select_innodb.result +++ b/mysql-test/suite/vcol/r/vcol_select_innodb.result @@ -135,7 +135,7 @@ count(distinct c) 3 explain select count(distinct c) from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by +1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by ### ### filesort & range-based utils ### diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result index 05f86347706..d8271252137 100644 --- a/mysql-test/suite/vcol/r/vcol_select_myisam.result +++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result @@ -133,7 +133,7 @@ count(distinct c) 3 explain select count(distinct c) from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by +1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by ### ### filesort & range-based utils ### diff --git a/sql/opt_range.cc b/sql/opt_range.cc index fa44b03b109..ddeb0e4fdbf 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3235,7 +3235,7 @@ double records_in_column_ranges(PARAM *param, uint idx, SEL_ARG_RANGE_SEQ seq; KEY_MULTI_RANGE range; range_seq_t seq_it; - double rows; + double rows, table_records; Field *field; uint flags= 0; double total_rows= 0; @@ -3290,13 +3290,17 @@ double records_in_column_ranges(PARAM *param, uint idx, total_rows= DBL_MAX; break; } - total_rows += rows; + total_rows+= rows; } if (total_rows == 0) total_rows= MY_MIN(1, rows2double(param->table->stat_records())); - return total_rows; -} + table_records= rows2double(param->table->stat_records()); + if (total_rows > table_records) + DBUG_PRINT("error", ("table_records: %g < total_records: %g", + table_records, total_rows)); + return MY_MIN(total_rows, table_records); +} /* @@ -14813,6 +14817,8 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, num_groups= (ha_rows) rint(num_groups * quick_prefix_selectivity); set_if_bigger(num_groups, 1); } + /* Ensure we don't have more groups than rows in table */ + set_if_smaller(num_groups, table_records); if (used_key_parts > group_key_parts) { /* From 4062fc28bd7c307d7a6b1987df071a3195b8e9b6 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 6 Oct 2021 12:31:19 +0300 Subject: [PATCH 005/123] Optimizer code cleanups, no logic changes - Updated comments - Added some extra DEBUG - Indentation changes and break long lines - Trivial code changes like: - Combining 2 statements in one - Reorder DBUG lines - Use a variable to store a pointer that is used multiple times - Moved declaration of variables to start of loop/function - Removed dead or commented code - Removed wrong DBUG_EXECUTE code in best_extension_by_limited_search() --- sql/filesort.cc | 14 +-- sql/multi_range_read.cc | 17 ++-- sql/opt_range.cc | 117 ++++++++++++--------- sql/opt_subselect.cc | 65 +++++------- sql/opt_subselect.h | 2 +- sql/opt_trace.cc | 47 ++++----- sql/rowid_filter.cc | 8 +- sql/sql_join_cache.cc | 2 +- sql/sql_lex.cc | 11 +- sql/sql_select.cc | 220 +++++++++++++++++++++++----------------- sql/sql_select.h | 4 +- sql/sql_update.cc | 6 +- 12 files changed, 283 insertions(+), 230 deletions(-) diff --git a/sql/filesort.cc b/sql/filesort.cc index bf5520955c9..f5345250987 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1544,7 +1544,7 @@ static bool check_if_pq_applicable(Sort_param *param, DBUG_RETURN(false); } - if (param->max_rows + 2 >= UINT_MAX) + if (param->max_rows >= UINT_MAX - 2) { DBUG_PRINT("info", ("Too large LIMIT")); DBUG_RETURN(false); @@ -2171,8 +2171,8 @@ Type_handler_timestamp_common::sort_length(THD *thd, void Type_handler_int_result::sort_length(THD *thd, - const Type_std_attributes *item, - SORT_FIELD_ATTR *sortorder) const + const Type_std_attributes *item, + SORT_FIELD_ATTR *sortorder) const { sortorder->original_length= sortorder->length= 8; // Sizof intern longlong } @@ -2180,8 +2180,8 @@ Type_handler_int_result::sort_length(THD *thd, void Type_handler_real_result::sort_length(THD *thd, - const Type_std_attributes *item, - SORT_FIELD_ATTR *sortorder) const + const Type_std_attributes *item, + SORT_FIELD_ATTR *sortorder) const { sortorder->original_length= sortorder->length= sizeof(double); } @@ -2205,8 +2205,8 @@ Type_handler_decimal_result::sort_length(THD *thd, @param thd Thread handler @param sortorder Order of items to sort @param s_length Number of items to sort - @param allow_packing_for_sortkeys [out] set to false if packing sort keys is not - allowed + @param allow_packing_for_sortkeys [out] set to false if packing sort keys + is not allowed @note * sortorder->length and other members are updated for each sort item. diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 2701dac56c4..0316caf9fdd 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -37,8 +37,8 @@ @param n_ranges_arg Number of ranges in the sequence, or 0 if the caller can't efficiently determine it @param bufsz INOUT IN: Size of the buffer available for use - OUT: Size of the buffer that is expected to be actually - used, or 0 if buffer is not needed. + OUT: Size of the buffer that is expected to be + actually used, or 0 if buffer is not needed. @param flags INOUT A combination of HA_MRR_* flags @param cost OUT Estimated cost of MRR access @@ -286,11 +286,15 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, (single_point_ranges - assigned_single_point_ranges). We don't add these to io_blocks as we don't want to penalize equal - readss (if we did, a range that would read 5 rows would be + reads (if we did, a range that would read 5 rows would be regarded as better than one equal read). Better to assume we have done a records_in_range() for the equal range and it's also cached. + + One effect of this is that io_blocks for simple ranges are often 0, + as the blocks where already read by records_in_range and we assume + that we don't have to read it again. */ io_blocks= (range_blocks_cnt - edge_blocks_cnt); unassigned_single_point_ranges+= (single_point_ranges - @@ -1991,9 +1995,10 @@ bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, else { cost->reset(); - *buffer_size= (uint)MY_MAX(*buffer_size, - (size_t)(1.2*rows_in_last_step) * elem_size + - primary_file->ref_length + table->key_info[keynr].key_length); + *buffer_size= ((uint) MY_MAX(*buffer_size, + (size_t)(1.2*rows_in_last_step) * elem_size + + primary_file->ref_length + + table->key_info[keynr].key_length)); } Cost_estimate last_step_cost; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ddeb0e4fdbf..5e01b1272cc 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -19,8 +19,8 @@ Fix that MAYBE_KEY are stored in the tree so that we can detect use of full hash keys for queries like: - select s.id, kws.keyword_id from sites as s,kws where s.id=kws.site_id and kws.keyword_id in (204,205); - + select s.id, kws.keyword_id from sites as s,kws where s.id=kws.site_id and + kws.keyword_id in (204,205); */ /* @@ -2626,7 +2626,8 @@ static int fill_used_fields_bitmap(PARAM *param) In the table struct the following information is updated: quick_keys - Which keys can be used quick_rows - How many rows the key matches - opt_range_condition_rows - E(# rows that will satisfy the table condition) + opt_range_condition_rows - E(# rows that will satisfy the table + condition) IMPLEMENTATION opt_range_condition_rows value is obtained as follows: @@ -2774,7 +2775,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, thd->no_errors=1; // Don't warn about NULL init_sql_alloc(key_memory_quick_range_select_root, &alloc, - thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC)); + thd->variables.range_alloc_block_size, 0, + MYF(MY_THREAD_SPECIFIC)); if (!(param.key_parts= (KEY_PART*) alloc_root(&alloc, sizeof(KEY_PART) * @@ -2931,6 +2933,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, TRP_INDEX_INTERSECT *intersect_trp; bool can_build_covering= FALSE; Json_writer_object trace_range(thd, "analyzing_range_alternatives"); + TABLE_READ_PLAN *range_trp; backup_keys= (SEL_ARG**) alloca(sizeof(backup_keys[0])*param.keys); memcpy(&backup_keys[0], &tree->keys[0], @@ -2939,9 +2942,9 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, remove_nonrange_trees(¶m, tree); /* Get best 'range' plan and prepare data for making other plans */ - if (auto range_trp= get_key_scans_params(¶m, tree, - only_single_index_range_scan, - true, best_read_time)) + if ((range_trp= get_key_scans_params(¶m, tree, + only_single_index_range_scan, + true, best_read_time))) { best_trp= range_trp; best_read_time= best_trp->read_cost; @@ -3048,7 +3051,6 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, { grp_summary.add("chosen", true); best_trp= group_trp; - best_read_time= best_trp->read_cost; } else grp_summary.add("chosen", false).add("cause", "cost"); @@ -3112,7 +3114,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, SYNOPSIS create_key_parts_for_pseudo_indexes() param IN/OUT data structure for the descriptors to be built - used_fields bitmap of columns for which the descriptors are to be built + used_fields bitmap of columns for which the descriptors are to be built DESCRIPTION For each column marked in the bitmap used_fields the function builds @@ -3209,9 +3211,10 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param, SYNOPSIS records_in_column_ranges() param the data structure to access descriptors of pseudo indexes - built over columns used in the condition of the processed query + built over columns used in the condition of the processed + query idx the index of the descriptor of interest in param - tree the tree representing ranges built for the interesting column + tree the tree representing ranges built for the interesting column DESCRIPTION This function retrieves the ranges represented by the SEL_ARG 'tree' and @@ -3334,7 +3337,8 @@ int cmp_quick_ranges(TABLE *table, uint *a, uint *b) DESCRIPTION This function calculates the selectivity of range conditions cond imposed on the rows of 'table' in the processed query. - The calculated selectivity is assigned to the field table->cond_selectivity. + The calculated selectivity is assigned to the field + table->cond_selectivity. Selectivity is calculated as a product of selectivities imposed by: @@ -3346,6 +3350,8 @@ int cmp_quick_ranges(TABLE *table, uint *a, uint *b) 3. Reading a few records from the table pages and checking the condition selectivity (this is used for conditions like "column LIKE '%val%'" where approaches #1 and #2 do not provide selectivity data). + 4. If the selectivity calculated by get_best_ror_intersect() is smaller, + use this instead. NOTE Currently the selectivities of range conditions over different columns are @@ -3362,6 +3368,9 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) MY_BITMAP *used_fields= &table->cond_set; double table_records= (double)table->stat_records(); uint optimal_key_order[MAX_KEY]; + MY_BITMAP handled_columns; + my_bitmap_map *buf; + QUICK_SELECT_I *quick; DBUG_ENTER("calculate_cond_selectivity_for_table"); table->cond_selectivity= 1.0; @@ -3369,7 +3378,6 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) if (table_records == 0) DBUG_RETURN(FALSE); - QUICK_SELECT_I *quick; if ((quick=table->reginfo.join_tab->quick) && quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) { @@ -3377,14 +3385,14 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) DBUG_RETURN(FALSE); } - if (!*cond) + if (!*cond || table->pos_in_table_list->schema_table) DBUG_RETURN(FALSE); - if (table->pos_in_table_list->schema_table) - DBUG_RETURN(FALSE); - - MY_BITMAP handled_columns; - my_bitmap_map* buf; + /* + This should be pre-alloced so that we could use the same bitmap for all + tables. Would also avoid extra memory allocations if this function would + be called multiple times per query. + */ if (!(buf= (my_bitmap_map*)thd->alloc(table->s->column_bitmap_size))) DBUG_RETURN(TRUE); my_bitmap_init(&handled_columns, buf, table->s->fields); @@ -3512,7 +3520,8 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) double rows; init_sql_alloc(key_memory_quick_range_select_root, &alloc, - thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC)); + thd->variables.range_alloc_block_size, 0, + MYF(MY_THREAD_SPECIFIC)); param.thd= thd; param.mem_root= &alloc; param.old_root= thd->mem_root; @@ -3531,9 +3540,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) thd->no_errors=1; - tree= cond[0]->get_mm_tree(¶m, cond); - - if (!tree) + if (!(tree= cond[0]->get_mm_tree(¶m, cond))) goto free_alloc; table->reginfo.impossible_range= 0; @@ -3557,7 +3564,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) for (uint idx= 0; idx < param.keys; idx++) { SEL_ARG *key= tree->keys[idx]; - if (key) + if (key) // Quick range found for key { Json_writer_object selectivity_for_column(thd); selectivity_for_column.add("column_name", key->field->field_name); @@ -5671,8 +5678,7 @@ bool create_fields_bitmap(PARAM *param, MY_BITMAP *fields_bitmap) static int cmp_intersect_index_scan(INDEX_SCAN_INFO **a, INDEX_SCAN_INFO **b) { - return (*a)->records < (*b)->records ? - -1 : (*a)->records == (*b)->records ? 0 : 1; + return CMP_NUM((*a)->records, (*b)->records); } @@ -6269,7 +6275,8 @@ bool check_index_intersect_extension(PARTIAL_INDEX_INTERSECT_INFO *curr, size_t max_memory_size= common_info->max_memory_size; records_sent_to_unique+= ext_index_scan_records; - cost= Unique::get_use_cost(buff_elems, (size_t) records_sent_to_unique, key_size, + cost= Unique::get_use_cost(buff_elems, (size_t) records_sent_to_unique, + key_size, max_memory_size, compare_factor, TRUE, &next->in_memory); if (records_filtered_out_by_cpk) @@ -6584,6 +6591,11 @@ ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg) if (bitmap_is_set(¶m->needed_fields, key_part->fieldnr-1)) bitmap_set_bit(&ror_scan->covered_fields, key_part->fieldnr-1); } + + /* + Cost of reading the keys for the rows, which are later stored in the + ror queue. + */ ror_scan->index_read_cost= param->table->file->keyread_time(ror_scan->keynr, 1, ror_scan->records); DBUG_RETURN(ror_scan); @@ -6895,7 +6907,7 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, avoid duplicating the inference code) NOTES - Adding a ROR scan to ROR-intersect "makes sense" iff the cost of ROR- + Adding a ROR scan to ROR-intersect "makes sense" if the cost of ROR- intersection decreases. The cost of ROR-intersection is calculated as follows: @@ -7057,8 +7069,12 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, { uint idx; double min_cost= DBL_MAX; - DBUG_ENTER("get_best_ror_intersect"); THD *thd= param->thd; + DBUG_ENTER("get_best_ror_intersect"); + DBUG_PRINT("enter", ("opt_range_condition_rows: %llu cond_selectivity: %g", + (ulonglong) param->table->opt_range_condition_rows, + param->table->cond_selectivity)); + Json_writer_object trace_ror(thd, "analyzing_roworder_intersect"); if ((tree->n_ror_scans < 2) || !param->table->stat_records() || @@ -7267,6 +7283,8 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, ? "too few indexes to merge" : "cost"); } + DBUG_PRINT("enter", ("opt_range_condition_rows: %llu", + (ulonglong) param->table->opt_range_condition_rows)); DBUG_RETURN(trp); } @@ -11535,7 +11553,8 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only, bool *is_ror_scan) { SEL_ARG_RANGE_SEQ seq; - RANGE_SEQ_IF seq_if = {NULL, sel_arg_range_seq_init, sel_arg_range_seq_next, 0, 0}; + RANGE_SEQ_IF seq_if= + {NULL, sel_arg_range_seq_init, sel_arg_range_seq_next, 0, 0}; handler *file= param->table->file; ha_rows rows= HA_POS_ERROR; uint keynr= param->real_keynr[idx]; @@ -11603,24 +11622,24 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only, This check is needed as sometimes that table statistics or range estimates may be slightly out of sync. */ - rows= table_records; - set_if_bigger(rows, 1); + rows= MY_MAX(table_records, 1); param->quick_rows[keynr]= rows; } param->possible_keys.set_bit(keynr); if (update_tbl_stats) { + TABLE::OPT_RANGE *range= param->table->opt_range + keynr; param->table->opt_range_keys.set_bit(keynr); - param->table->opt_range[keynr].key_parts= param->max_key_parts; - param->table->opt_range[keynr].ranges= param->range_count; + range->key_parts= param->max_key_parts; + range->ranges= param->range_count; param->table->opt_range_condition_rows= MY_MIN(param->table->opt_range_condition_rows, rows); - param->table->opt_range[keynr].rows= rows; - param->table->opt_range[keynr].cost= cost->total_cost(); + range->rows= rows; + range->cost= cost->total_cost(); if (param->table->file->is_clustering_key(keynr)) - param->table->opt_range[keynr].index_only_cost= 0; + range->index_only_cost= 0; else - param->table->opt_range[keynr].index_only_cost= cost->index_only_cost(); + range->index_only_cost= cost->index_only_cost(); } } @@ -14821,11 +14840,13 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, set_if_smaller(num_groups, table_records); if (used_key_parts > group_key_parts) - { /* + { + /* Compute the probability that two ends of a subgroup are inside different blocks. */ - keys_per_subgroup= (ha_rows) index_info->actual_rec_per_key(used_key_parts - 1); + keys_per_subgroup= (ha_rows) index_info->actual_rec_per_key(used_key_parts - + 1); if (keys_per_subgroup >= keys_per_block) /* If a subgroup is bigger than */ p_overlap= 1.0; /* a block, it will overlap at least two blocks. */ else @@ -14849,10 +14870,13 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, reads the next record without having to re-position to it on every group. To make the CPU cost reflect this, we estimate the CPU cost as the sum of: - 1. Cost for evaluating the condition (similarly as for index scan). + 1. Cost for evaluating the condition for each num_group + (1/TIME_FOR_COMPARE) (similarly as for index scan). 2. Cost for navigating the index structure (assuming a b-tree). - Note: We only add the cost for one comparision per block. For a - b-tree the number of comparisons will be larger. + Note: We only add the cost for one index comparision per block. For a + b-tree the number of comparisons will be larger. However the cost + is low as all of the upper level b-tree blocks should be in + memory. TODO: This cost should be provided by the storage engine. */ const double tree_traversal_cost= @@ -14860,8 +14884,8 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, log(static_cast(keys_per_block))) * 1/(2*TIME_FOR_COMPARE); - const double cpu_cost= num_groups * - (tree_traversal_cost + 1/TIME_FOR_COMPARE_IDX); + const double cpu_cost= (num_groups * + (tree_traversal_cost + 1/TIME_FOR_COMPARE_IDX)); *read_cost= io_cost + cpu_cost; *records= num_groups; @@ -14910,7 +14934,8 @@ TRP_GROUP_MIN_MAX::make_quick(PARAM *param, bool retrieve_full_rows, group_prefix_len, group_key_parts, used_key_parts, index_info, index, read_cost, records, key_infix_len, - key_infix, parent_alloc, is_index_scan); + key_infix, parent_alloc, + is_index_scan); if (!quick) DBUG_RETURN(NULL); diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 3e2531b90cd..6ec32ae0e73 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -2507,24 +2507,13 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map) sjm->is_used= FALSE; double subjoin_out_rows, subjoin_read_time; - /* - join->get_partial_cost_and_fanout(n_tables + join->const_tables, - table_map(-1), - &subjoin_read_time, - &subjoin_out_rows); - */ - join->get_prefix_cost_and_fanout(n_tables, + join->get_prefix_cost_and_fanout(n_tables, &subjoin_read_time, &subjoin_out_rows); sjm->materialization_cost.convert_from_cost(subjoin_read_time); sjm->rows_with_duplicates= sjm->rows= subjoin_out_rows; - // Don't use the following list because it has "stale" items. use - // ref_pointer_array instead: - // - //List &right_expr_list= - // sj_nest->sj_subq_pred->unit->first_select()->item_list; /* Adjust output cardinality estimates. If the subquery has form @@ -3432,8 +3421,8 @@ bool Firstmatch_picker::check_qep(JOIN *join, optimizer_flag(join->thd, OPTIMIZER_SWITCH_SEMIJOIN_WITH_CACHE)) { /* - An important special case: only one inner table, and @@optimizer_switch - allows join buffering. + An important special case: only one inner table, and + @@optimizer_switch allows join buffering. - read_time is the same (i.e. FirstMatch doesn't add any cost - remove fanout added by the last table */ @@ -3583,8 +3572,7 @@ bool Duplicate_weedout_picker::check_qep(JOIN *join, Add the cost of temptable use. The table will have sj_outer_fanout records, and we will make - sj_outer_fanout table writes - - sj_inner_fanout*sj_outer_fanout lookups. - + - sj_inner_fanout*sj_outer_fanout lookups. */ double one_lookup_cost= get_tmp_table_lookup_cost(join->thd, sj_outer_fanout, @@ -3657,33 +3645,37 @@ void JOIN::dbug_verify_sj_inner_tables(uint prefix_size) const */ void restore_prev_sj_state(const table_map remaining_tables, - const JOIN_TAB *tab, uint idx) + const JOIN_TAB *tab, uint idx) { TABLE_LIST *emb_sj_nest; - if (tab->emb_sj_nest) + if ((emb_sj_nest= tab->emb_sj_nest)) { - table_map subq_tables= tab->emb_sj_nest->sj_inner_tables; + table_map subq_tables= emb_sj_nest->sj_inner_tables; tab->join->sjm_lookup_tables &= ~subq_tables; - } - if (!tab->join->emb_sjm_nest && (emb_sj_nest= tab->emb_sj_nest)) - { - table_map subq_tables= emb_sj_nest->sj_inner_tables & - ~tab->join->const_table_map; - /* If we're removing the last SJ-inner table, remove the sj-nest */ - if ((remaining_tables & subq_tables) == subq_tables) + if (!tab->join->emb_sjm_nest) { - // All non-const tables of the SJ nest are in the remaining_tables. - // we are not in the nest anymore. - tab->join->cur_sj_inner_tables &= ~emb_sj_nest->sj_inner_tables; - } - else - { - // Semi-join nest has: - // - a table being removed (not in the prefix) - // - some tables in the prefix. - tab->join->cur_sj_inner_tables |= emb_sj_nest->sj_inner_tables; + table_map subq_tables= (emb_sj_nest->sj_inner_tables & + ~tab->join->const_table_map); + /* If we're removing the last SJ-inner table, remove the sj-nest */ + if ((remaining_tables & subq_tables) == subq_tables) + { + /* + All non-const tables of the SJ nest are in the remaining_tables. + we are not in the nest anymore. + */ + tab->join->cur_sj_inner_tables &= ~emb_sj_nest->sj_inner_tables; + } + else + { + /* + Semi-join nest has: + - a table being removed (not in the prefix) + - some tables in the prefix. + */ + tab->join->cur_sj_inner_tables |= emb_sj_nest->sj_inner_tables; + } } } @@ -6634,7 +6626,6 @@ bool JOIN::choose_subquery_plan(table_map join_tables) /* Get the cost of the modified IN-EXISTS plan. */ inner_read_time_2= inner_join->best_read; - } else { diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h index 7b1b810ee81..cc6d2fbbecb 100644 --- a/sql/opt_subselect.h +++ b/sql/opt_subselect.h @@ -320,7 +320,7 @@ void optimize_semi_joins(JOIN *join, table_map remaining_tables, uint idx, void update_sj_state(JOIN *join, const JOIN_TAB *new_tab, uint idx, table_map remaining_tables); void restore_prev_sj_state(const table_map remaining_tables, - const JOIN_TAB *tab, uint idx); + const JOIN_TAB *tab, uint idx); void fix_semijoin_strategies_for_picked_join_order(JOIN *join); diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc index 4bc493940fb..a7e8c3da63b 100644 --- a/sql/opt_trace.cc +++ b/sql/opt_trace.cc @@ -568,35 +568,32 @@ void Opt_trace_stmt::set_allowed_mem_size(size_t mem_size) void Json_writer::add_table_name(const JOIN_TAB *tab) { + char table_name_buffer[SAFE_NAME_LEN]; + DBUG_ASSERT(tab != NULL); DBUG_ASSERT(tab->join->thd->trace_started()); - if (tab != NULL) + + if (tab->table && tab->table->derived_select_number) { - char table_name_buffer[SAFE_NAME_LEN]; - if (tab->table && tab->table->derived_select_number) - { - /* Derived table name generation */ - size_t len= my_snprintf(table_name_buffer, sizeof(table_name_buffer)-1, - "", - tab->table->derived_select_number); - add_str(table_name_buffer, len); - } - else if (tab->bush_children) - { - JOIN_TAB *ctab= tab->bush_children->start; - size_t len= my_snprintf(table_name_buffer, - sizeof(table_name_buffer)-1, - "", - ctab->emb_sj_nest->sj_subq_pred->get_identifier()); - add_str(table_name_buffer, len); - } - else - { - TABLE_LIST *real_table= tab->table->pos_in_table_list; - add_str(real_table->alias.str, real_table->alias.length); - } + /* Derived table name generation */ + size_t len= my_snprintf(table_name_buffer, sizeof(table_name_buffer)-1, + "", + tab->table->derived_select_number); + add_str(table_name_buffer, len); + } + else if (tab->bush_children) + { + JOIN_TAB *ctab= tab->bush_children->start; + size_t len= my_snprintf(table_name_buffer, + sizeof(table_name_buffer)-1, + "", + ctab->emb_sj_nest->sj_subq_pred->get_identifier()); + add_str(table_name_buffer, len); } else - DBUG_ASSERT(0); + { + TABLE_LIST *real_table= tab->table->pos_in_table_list; + add_str(real_table->alias.str, real_table->alias.length); + } } void Json_writer::add_table_name(const TABLE *table) diff --git a/sql/rowid_filter.cc b/sql/rowid_filter.cc index 0589b587ba2..c775bdf35d6 100644 --- a/sql/rowid_filter.cc +++ b/sql/rowid_filter.cc @@ -39,7 +39,8 @@ double Range_rowid_filter_cost_info::lookup_cost( /** @brief - The average gain in cost per row to use the range filter with this cost info + The average gain in cost per row to use the range filter with this cost + info */ inline @@ -58,8 +59,9 @@ double Range_rowid_filter_cost_info::avg_access_and_eval_gain_per_row( @param access_cost_factor the adjusted cost of access a row @details - The current code to estimate the cost of a ref access is quite inconsistent: - in some cases the effect of page buffers is taken into account, for others + The current code to estimate the cost of a ref access is quite + inconsistent: + In some cases the effect of page buffers is taken into account, for others just the engine dependent read_time() is employed. That's why the average cost of one random seek might differ from 1. The parameter access_cost_factor can be considered as the cost of a random diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index c7b6a0bf6e4..45419d7e5b1 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -1080,7 +1080,7 @@ int JOIN_CACHE::init(bool for_explain) /* - Check the possibility to read the access keys directly from the join buffer + Check the possibility to read the access keys directly from the join buffer SYNOPSIS check_emb_key_usage() diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index e3f486486d7..3707b8ef8e4 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -5956,7 +5956,7 @@ unit_common_op st_select_lex_unit::common_op() else { if (operation != op) - operation= OP_MIX; + return OP_MIX; } } } @@ -5966,12 +5966,13 @@ unit_common_op st_select_lex_unit::common_op() Save explain structures of a UNION. The only variable member is whether the union has "Using filesort". - There is also save_union_explain_part2() function, which is called before we read - UNION's output. + There is also save_union_explain_part2() function, which is called before we + read UNION's output. The reason for it is examples like this: - SELECT col1 FROM t1 UNION SELECT col2 FROM t2 ORDER BY (select ... from t3 ...) + SELECT col1 FROM t1 UNION SELECT col2 FROM t2 + ORDER BY (select ... from t3 ...) Here, the (select ... from t3 ...) subquery must be a child of UNION's st_select_lex. However, it is not connected as child until a very late @@ -10191,7 +10192,7 @@ SELECT_LEX_UNIT *LEX::parsed_select_expr_cont(SELECT_LEX_UNIT *unit, /** Add primary expression as the next term in a given query expression body - pruducing a new query expression body + producing a new query expression body */ SELECT_LEX_UNIT * diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 87796d53991..a3175dd0769 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1990,9 +1990,8 @@ bool JOIN::make_range_rowid_filters() bool JOIN::init_range_rowid_filters() { - DBUG_ENTER("init_range_rowid_filters"); - JOIN_TAB *tab; + DBUG_ENTER("init_range_rowid_filters"); for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES); tab; @@ -2248,7 +2247,8 @@ JOIN::optimize_inner() (see build_equal_items() below) because it can be not rebuilt at second invocation. */ - if (!thd->stmt_arena->is_conventional() && thd->mem_root != thd->stmt_arena->mem_root) + if (!thd->stmt_arena->is_conventional() && + thd->mem_root != thd->stmt_arena->mem_root) for (TABLE_LIST *tbl= tables_list; tbl; tbl= tbl->next_local) if (tbl->table && tbl->on_expr && tbl->table->versioned()) { @@ -5318,6 +5318,7 @@ make_join_statistics(JOIN *join, List &tables_list, s->tab_list= tables; table->pos_in_table_list= tables; error= tables->fetch_number_of_rows(); + /* Calculate table->use_stat_records */ set_statistics_for_table(join->thd, table); bitmap_clear_all(&table->cond_set); @@ -5987,7 +5988,6 @@ make_join_statistics(JOIN *join, List &tables_list, DBUG_RETURN(TRUE); /* purecov: inspected */ { - double records= 1; SELECT_LEX_UNIT *unit= join->select_lex->master_unit(); /* Find an optimal join order of the non-constant tables. */ @@ -6018,10 +6018,12 @@ make_join_statistics(JOIN *join, List &tables_list, Calculate estimated number of rows for materialized derived table/view. */ + double records= 1.0; + ha_rows rows; for (i= 0; i < join->table_count ; i++) if (double rr= join->best_positions[i].records_read) records= COST_MULT(records, rr); - ha_rows rows= records > (double) HA_ROWS_MAX ? HA_ROWS_MAX : (ha_rows) records; + rows= records > (double) HA_ROWS_MAX ? HA_ROWS_MAX : (ha_rows) records; set_if_smaller(rows, unit->lim.get_select_limit()); join->select_lex->increase_derived_records(rows); } @@ -6369,8 +6371,8 @@ add_key_field(JOIN *join, Field op formula Field IS NULL Field IS NOT NULL - Field BETWEEN ... - Field IN ... + Field BETWEEN ... + Field IN ... */ if (field->flags & PART_KEY_FLAG) { @@ -6458,10 +6460,10 @@ add_key_field(JOIN *join, @param field_item Field item used for comparison @param eq_func True if we used =, <=> or IS NULL @param value Value used for comparison with field_item - @param num_values Number of values[] that we are comparing against + @param num_values Number of values[] that we are comparing against @param usable_tables Tables which can be used for key optimization @param sargables IN/OUT Array of found sargable candidates - @param row_col_no if = n that > 0 then field is compared only + @param row_col_no if = n that > 0 then field is compared only against the n-th component of row values @note @@ -7690,20 +7692,30 @@ void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key) Estimate how many records we will get if we read just this table and apply a part of WHERE that can be checked for it. - @detail + @param s Current JOIN_TAB + @param with_found_constraint There is a filtering condition on the + current table. See more below + @param use_cond_selectivity Value of optimizer_use_condition_selectivity. + If > 1 then use table->cond_selecitivity. + + @return 0.0 No matching rows + @return >= 1.0 Number of expected matching rows + + @details Estimate how many records we will get if we - read the given table with its "independent" access method (either quick select or full table/index scan), - apply the part of WHERE that refers only to this table. + - The result cannot be bigger than table records - @seealso - table_cond_selectivity() produces selectivity of condition that is checked - after joining rows from this table to rows from preceding tables. + @see also + table_after_join_selectivity() produces selectivity of condition that is + checked after joining rows from this table to rows from preceding tables. */ inline double matching_candidates_in_table(JOIN_TAB *s, bool with_found_constraint, - uint use_cond_selectivity) + uint use_cond_selectivity) { ha_rows records; double dbl_records; @@ -7804,7 +7816,7 @@ double adjust_quick_cost(double quick_cost, ha_rows records) The function finds the best access path to table 's' from the passed partial plan where an access path is the general term for any means to - access the data in 's'. An access path may use either an index or a scan, + cacess the data in 's'. An access path may use either an index or a scan, whichever is cheaper. The input partial plan is passed via the array 'join->positions' of length 'idx'. The chosen access method for 's' and its cost are stored in 'join->positions[idx]'. @@ -7838,14 +7850,16 @@ best_access_path(JOIN *join, POSITION *loose_scan_pos) { THD *thd= join->thd; - uint use_cond_selectivity= thd->variables.optimizer_use_condition_selectivity; + uint use_cond_selectivity= + thd->variables.optimizer_use_condition_selectivity; KEYUSE *best_key= 0; uint best_max_key_part= 0; my_bool found_constraint= 0; double best= DBL_MAX; double best_time= DBL_MAX; double records= DBL_MAX; - ha_rows records_for_key= 0; + ha_rows records_for_key; + double best_filter_cmp_gain; table_map best_ref_depends_map= 0; /* key_dependent is 0 if all key parts could be used or if there was an @@ -7947,7 +7961,7 @@ best_access_path(JOIN *join, do /* For each way to access the keypart */ { /* - if 1. expression doesn't refer to forward tables + If 1. expression does not refer to forward tables 2. we won't get two ref-or-null's */ all_parts|= keyuse->keypart_map; @@ -7970,7 +7984,8 @@ best_access_path(JOIN *join, (found_ref | keyuse->used_tables)); if (tmp2 < best_prev_record_reads) { - best_part_found_ref= keyuse->used_tables & ~join->const_table_map; + best_part_found_ref= (keyuse->used_tables & + ~join->const_table_map); best_prev_record_reads= tmp2; } if (rec > keyuse->ref_table_rows) @@ -8189,7 +8204,7 @@ best_access_path(JOIN *join, We also have a property that "range optimizer produces equal or tighter set of scan intervals than ref(const) optimizer". Each of the intervals in (**) are "tightest possible" intervals when - one limits itself to using keyparts 1..K (which we do in #2). + one limits itself to using keyparts 1..K (which we do in #2). From here it follows that range access used either one, or both of the (I1) and (I2) intervals: @@ -8243,7 +8258,8 @@ best_access_path(JOIN *join, if (!found_ref && // (1) records < rows) // (3) { - trace_access_idx.add("used_range_estimates", "clipped up"); + trace_access_idx.add("used_range_estimates", + "clipped up"); records= rows; } } @@ -8483,7 +8499,8 @@ best_access_path(JOIN *join, join->allowed_outer_join_with_cache)) // (2) { double join_sel= 0.1; - /* Estimate the cost of the hash join access to the table */ + double refills; + /* Estimate the cost of the hash join access to the table */ double rnd_records= matching_candidates_in_table(s, found_constraint, use_cond_selectivity); @@ -8492,10 +8509,9 @@ best_access_path(JOIN *join, tmp= COST_ADD(tmp, cmp_time); /* We read the table as many times as join buffer becomes full. */ - - double refills= (1.0 + floor((double) cache_record_length(join,idx) * - record_count / - (double) thd->variables.join_buff_size)); + refills= (1.0 + floor((double) cache_record_length(join,idx) * + record_count / + (double) thd->variables.join_buff_size)); tmp= COST_MULT(tmp, refills); best_time= COST_ADD(tmp, COST_MULT((record_count*join_sel) / TIME_FOR_COMPARE, @@ -8578,7 +8594,11 @@ best_access_path(JOIN *join, For each record we: - read record range through 'quick' - skip rows which does not satisfy WHERE constraints - TODO: + + Note that s->quick->read_time includes the cost of comparing + the row with the where clause (TIME_FOR_COMPARE) + + TODO: We take into account possible use of join cache for ALL/index access (see first else-branch below), but we don't take it into account here for range/index_merge access. Find out why this is so. @@ -8638,9 +8658,13 @@ best_access_path(JOIN *join, if ((s->table->map & join->outer_join) || disable_jbuf) // Can't use join cache { /* + Simple scan + For each record we have to: - - read the whole table record - - skip rows which does not satisfy join condition + - Read the whole table record + - Compare with the current where clause with only fields for the table + - Compare with the full where and skip rows which does not satisfy + the join condition */ double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE; tmp= COST_MULT(record_count, COST_ADD(tmp,cmp_time)); @@ -8678,9 +8702,9 @@ best_access_path(JOIN *join, tmp give us total cost of using TABLE SCAN */ - const double best_filter_cmp_gain= best_filter - ? best_filter->get_cmp_gain(record_count * records) - : 0; + best_filter_cmp_gain= (best_filter ? + best_filter->get_cmp_gain(record_count * records) : + 0); trace_access_scan.add("resulting_rows", rnd_records); trace_access_scan.add("cost", tmp); @@ -8792,6 +8816,7 @@ static void choose_initial_table_order(JOIN *join) JOIN_TAB **tab= join->best_ref + join->const_tables; JOIN_TAB **tabs_end= tab + join->table_count - join->const_tables; DBUG_ENTER("choose_initial_table_order"); + /* Find where the top-level JOIN_TABs end and subquery JOIN_TABs start */ for (; tab != tabs_end; tab++) { @@ -8908,10 +8933,10 @@ choose_plan(JOIN *join, table_map join_tables) /* if (SELECT_STRAIGHT_JOIN option is set) reorder tables so dependent tables come after tables they depend - on, otherwise keep tables in the order they were specified in the query + on, otherwise keep tables in the order they were specified in the query else - Apply heuristic: pre-sort all access plans with respect to the number of - records accessed. + Apply heuristic: pre-sort all access plans with respect to the number + of records accessed. */ jtab_sort_func= straight_join ? join_tab_cmp_straight : join_tab_cmp; } @@ -9992,7 +10017,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, Selectivity of COND(table) is already accounted for in matching_candidates_in_table(). */ - sel= 1; + sel= 1.0; } /* @@ -10015,7 +10040,8 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, next_field != field; next_field= next_field->next_equal_field) { - if (!(next_field->table->map & rem_tables) && next_field->table != table) + if (!(next_field->table->map & rem_tables) && + next_field->table != table) { if (field->cond_selectivity > 0) { @@ -10329,9 +10355,8 @@ best_extension_by_limited_search(JOIN *join, SORT_POSITION *sort= (SORT_POSITION*) alloca(sizeof(SORT_POSITION)*tables_left); SORT_POSITION *sort_end; DBUG_ENTER("best_extension_by_limited_search"); - DBUG_EXECUTE_IF("show_explain_probe_best_ext_lim_search", - if (dbug_user_var_equals_int(thd, + if (dbug_user_var_equals_int(thd, "show_explain_probe_select_id", join->select_lex->select_number)) dbug_serve_apcs(thd, 1); @@ -10434,6 +10459,8 @@ best_extension_by_limited_search(JOIN *join, double current_record_count, current_read_time; double partial_join_cardinality; POSITION *position= join->positions + idx, *loose_scan_pos; + double filter_cmp_gain; + double pushdown_cond_selectivity; Json_writer_object trace_one_table(thd); if (unlikely(thd->trace_started())) @@ -10448,9 +10475,9 @@ best_extension_by_limited_search(JOIN *join, /* Compute the cost of the new plan extended with 's' */ current_record_count= COST_MULT(record_count, position->records_read); - const double filter_cmp_gain= position->range_rowid_filter_info - ? position->range_rowid_filter_info->get_cmp_gain(current_record_count) - : 0; + filter_cmp_gain= position->range_rowid_filter_info ? + position->range_rowid_filter_info->get_cmp_gain(current_record_count) : + 0; current_read_time= COST_ADD(read_time, COST_ADD(position->read_time - filter_cmp_gain, @@ -10574,7 +10601,7 @@ best_extension_by_limited_search(JOIN *join, } } - double pushdown_cond_selectivity= 1.0; + pushdown_cond_selectivity= 1.0; if (use_cond_selectivity > 1) pushdown_cond_selectivity= table_cond_selectivity(join, idx, s, remaining_tables & @@ -10977,7 +11004,7 @@ prev_record_reads(const POSITION *positions, uint idx, table_map found_ref) found= COST_MULT(found, pos->records_read); found*= pos->cond_selectivity; } - } + } } return found; } @@ -11397,14 +11424,15 @@ bool JOIN::get_best_combination() j->table= NULL; //temporary way to tell SJM tables from others. j->ref.key = -1; j->on_expr_ref= (Item**) &null_ptr; - j->keys= key_map(1); /* The unique index is always in 'possible keys' in EXPLAIN */ + /* The unique index is always in 'possible keys' in EXPLAIN */ + j->keys= key_map(1); /* 2. Proceed with processing SJM nest's join tabs, putting them into the sub-order */ SJ_MATERIALIZATION_INFO *sjm= cur_pos->table->emb_sj_nest->sj_mat_info; - j->records_read= (sjm->is_sj_scan? sjm->rows : 1); + j->records_read= (sjm->is_sj_scan? sjm->rows : 1.0); j->records= (ha_rows) j->records_read; j->cond_selectivity= 1.0; JOIN_TAB *jt; @@ -11430,9 +11458,9 @@ bool JOIN::get_best_combination() form->reginfo.join_tab=j; DBUG_PRINT("info",("type: %d", j->type)); if (j->type == JT_CONST) - goto loop_end; // Handled in make_join_stat.. + goto loop_end; // Handled in make_join_stat.. - j->loosescan_match_tab= NULL; //non-nulls will be set later + j->loosescan_match_tab= NULL; //non-nulls will be set later j->inside_loosescan_range= FALSE; j->ref.key = -1; j->ref.key_parts=0; @@ -11447,18 +11475,12 @@ bool JOIN::get_best_combination() full_join= 1; } - /*if (best_positions[tablenr].sj_strategy == SJ_OPT_LOOSE_SCAN) - { - DBUG_ASSERT(!keyuse || keyuse->key == - best_positions[tablenr].loosescan_picker.loosescan_key); - j->index= best_positions[tablenr].loosescan_picker.loosescan_key; - }*/ - if ((j->type == JT_REF || j->type == JT_EQ_REF) && is_hash_join_key_no(j->ref.key)) hash_join= TRUE; - j->range_rowid_filter_info= best_positions[tablenr].range_rowid_filter_info; + j->range_rowid_filter_info= + best_positions[tablenr].range_rowid_filter_info; loop_end: /* @@ -12583,7 +12605,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) tab->type == JT_EQ_REF || first_inner_tab) { DBUG_EXECUTE("where",print_where(tmp, - tab->table? tab->table->alias.c_ptr() :"sjm-nest", + tab->table ? + tab->table->alias.c_ptr() :"sjm-nest", QT_ORDINARY);); SQL_SELECT *sel= tab->select= ((SQL_SELECT*) thd->memdup((uchar*) select, @@ -14104,10 +14127,12 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) if (tab->bush_root_tab && tab->bush_root_tab->bush_children->start == tab) prev_tab= NULL; - DBUG_ASSERT(tab->bush_children || tab->table == join->best_positions[i].table->table); + DBUG_ASSERT(tab->bush_children || + tab->table == join->best_positions[i].table->table); tab->partial_join_cardinality= join->best_positions[i].records_read * - (prev_tab? prev_tab->partial_join_cardinality : 1); + (prev_tab ? + prev_tab->partial_join_cardinality : 1); if (!tab->bush_children) i++; } @@ -14115,7 +14140,8 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) check_join_cache_usage_for_tables(join, options, no_jbuf_after); JOIN_TAB *first_tab; - for (tab= first_tab= first_linear_tab(join, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES); + for (tab= first_tab= first_linear_tab(join, + WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES); tab; tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS)) { @@ -14530,7 +14556,7 @@ double JOIN_TAB::scan_time() if (table->is_filled_at_execution()) { get_delayed_table_estimates(table, &records, &read_time, - &startup_cost); + &startup_cost); found_records= records; table->opt_range_condition_rows= records; } @@ -17887,17 +17913,18 @@ static bool check_interleaving_with_nj(JOIN_TAB *next_tab) Do update counters for "pairs of brackets" that we've left (marked as X,Y,Z in the above picture) */ - for (;next_emb && next_emb != join->emb_sjm_nest; next_emb= next_emb->embedding) + for (;next_emb && next_emb != join->emb_sjm_nest; + next_emb= next_emb->embedding) { if (!next_emb->sj_on_expr) { next_emb->nested_join->counter++; if (next_emb->nested_join->counter == 1) { - /* + /* next_emb is the first table inside a nested join we've "entered". In - the picture above, we're looking at the 'X' bracket. Don't exit yet as - X bracket might have Y pair bracket. + the picture above, we're looking at the 'X' bracket. Don't exit yet + as X bracket might have Y pair bracket. */ join->cur_embedding_map |= next_emb->nested_join->nj_map; } @@ -19911,7 +19938,7 @@ bool Create_tmp_table::finalize(THD *thd, bool save_abort_on_warning; uchar *pos; uchar *null_flags; - KEY *keyinfo; + KEY *keyinfo= param->keyinfo; TMP_ENGINE_COLUMNDEF *recinfo; TABLE_SHARE *share= table->s; Copy_field *copy= param->copy_field; @@ -20103,12 +20130,10 @@ bool Create_tmp_table::finalize(THD *thd, set_if_smaller(share->max_rows, m_rows_limit); param->end_write_records= m_rows_limit; - keyinfo= param->keyinfo; - if (m_group) { DBUG_PRINT("info",("Creating group key in temporary table")); - table->group= m_group; /* Table is grouped by key */ + table->group= m_group; /* Table is grouped by key */ param->group_buff= m_group_buff; share->keys=1; share->uniques= MY_TEST(m_using_unique_constraint); @@ -20118,7 +20143,8 @@ bool Create_tmp_table::finalize(THD *thd, keyinfo->key_part= m_key_part_info; keyinfo->flags=HA_NOSAME | HA_BINARY_PACK_KEY | HA_PACK_KEY; keyinfo->ext_key_flags= keyinfo->flags; - keyinfo->usable_key_parts=keyinfo->user_defined_key_parts= param->group_parts; + keyinfo->usable_key_parts=keyinfo->user_defined_key_parts= + param->group_parts; keyinfo->ext_key_parts= keyinfo->user_defined_key_parts; keyinfo->key_length=0; keyinfo->rec_per_key=NULL; @@ -23748,10 +23774,10 @@ bool test_if_ref(Item *root_cond, Item_field *left_item,Item *right_item) @param cond Condition to analyze @param tables Tables for which "current field values" are available + Tables for which "current field values" are available (this + includes used_table) + (may also include PSEUDO_TABLE_BITS, and may be zero) @param used_table Table that we're extracting the condition for - tables Tables for which "current field values" are available (this - includes used_table) - (may also include PSEUDO_TABLE_BITS, and may be zero) @param join_tab_idx_arg The index of the JOIN_TAB this Item is being extracted for. MAX_TABLES if there is no corresponding JOIN_TAB. @@ -27788,7 +27814,7 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, table_map prefix_tables, bool distinct_arg, JOIN_TAB *first_top_tab) { - int quick_type; + int quick_type= -1; CHARSET_INFO *cs= system_charset_info; THD *thd= join->thd; TABLE_LIST *table_list= table->pos_in_table_list; @@ -27797,7 +27823,6 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, char table_name_buffer[SAFE_NAME_LEN]; KEY *key_info= 0; uint key_len= 0; - quick_type= -1; explain_plan= eta; eta->key.clear(); @@ -29351,8 +29376,8 @@ void JOIN::restore_query_plan(Join_plan_state *restore_from) @param added_where An extra conjunct to the WHERE clause to reoptimize with @param join_tables The set of tables to reoptimize - @param save_to If != NULL, save here the state of the current query plan, - otherwise reuse the existing query plan structures. + @param save_to If != NULL, save here the state of the current query + plan, otherwise reuse the existing query plan structures. @notes Given a query plan that was already optimized taking into account some WHERE @@ -29369,7 +29394,8 @@ void JOIN::restore_query_plan(Join_plan_state *restore_from) @retval REOPT_NEW_PLAN there is a new plan. @retval REOPT_OLD_PLAN no new improved plan was produced, use the old one. - @retval REOPT_ERROR an irrecovarable error occurred during reoptimization. + @retval REOPT_ERROR an irrecovarable error occurred during + reoptimization. */ JOIN::enum_reopt_result @@ -29381,8 +29407,8 @@ JOIN::reoptimize(Item *added_where, table_map join_tables, size_t org_keyuse_elements; /* Re-run the REF optimizer to take into account the new conditions. */ - if (update_ref_and_keys(thd, &added_keyuse, join_tab, table_count, added_where, - ~outer_join, select_lex, &sargables)) + if (update_ref_and_keys(thd, &added_keyuse, join_tab, table_count, + added_where, ~outer_join, select_lex, &sargables)) { delete_dynamic(&added_keyuse); return REOPT_ERROR; @@ -30062,7 +30088,7 @@ uint get_index_for_order(ORDER *order, TABLE *table, SQL_SELECT *select, if (select && select->quick) return select->quick->index; // index or MAX_KEY, use quick select as is else - return table->file->key_used_on_scan; // MAX_KEY or index for some engines + return table->file->key_used_on_scan; // MAX_KEY or index for some engine } if (!is_simple_order(order)) // just to cut further expensive checks @@ -30110,11 +30136,13 @@ uint get_index_for_order(ORDER *order, TABLE *table, SQL_SELECT *select, DBUG_ASSERT(0); } else if (limit != HA_POS_ERROR) - { // check if some index scan & LIMIT is more efficient than filesort + { + // check if some index scan & LIMIT is more efficient than filesort /* - Update opt_range_condition_rows since single table UPDATE/DELETE procedures - don't call make_join_statistics() and leave this variable uninitialized. + Update opt_range_condition_rows since single table UPDATE/DELETE + procedures don't call make_join_statistics() and leave this + variable uninitialized. */ table->opt_range_condition_rows= table->stat_records(); @@ -30692,20 +30720,22 @@ bool build_notnull_conds_for_range_scans(JOIN *join, Item *cond, @brief Build not null conditions for inner nest tables of an outer join - @param join the join for whose table nest not null conditions are to be built + @param join the join for whose table nest not null conditions are to be + built @param nest_tbl the nest of the inner tables of an outer join @details - The function assumes that nest_tbl is the nest of the inner tables of an - outer join and so an ON expression for this outer join is attached to - nest_tbl. - The function selects the tables of the nest_tbl that are not inner tables of - embedded outer joins and then it calls build_notnull_conds_for_range_scans() - for nest_tbl->on_expr and the bitmap for the selected tables. This call - finds all fields belonging to the selected tables whose null-rejectedness - can be inferred from the null-rejectedness of nest_tbl->on_expr. After this - the function recursively finds all null_rejected fields for the remaining - tables from the nest of nest_tbl. + The function assumes that nest_tbl is the nest of the inner tables + of an outer join and so an ON expression for this outer join is + attached to nest_tbl. + The function selects the tables of the nest_tbl that are not inner + tables of embedded outer joins and then it calls + build_notnull_conds_for_range_scans() for nest_tbl->on_expr and + the bitmap for the selected tables. This call finds all fields + belonging to the selected tables whose null-rejectedness can be + inferred from the null-rejectedness of nest_tbl->on_expr. After + this the function recursively finds all null_rejected fields for + the remaining tables from the nest of nest_tbl. */ static diff --git a/sql/sql_select.h b/sql/sql_select.h index fa4d373d556..819e9d1968f 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1343,7 +1343,9 @@ public: int dbug_join_tab_array_size; #endif - /* We also maintain a stack of join optimization states in * join->positions[] */ + /* + We also maintain a stack of join optimization states in join->positions[] + */ /******* Join optimization state members end *******/ /* diff --git a/sql/sql_update.cc b/sql/sql_update.cc index f56ec5c83c9..2da95904419 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -833,9 +833,9 @@ int mysql_update(THD *thd, table->use_all_columns(); /* - We are doing a search on a key that is updated. In this case - we go trough the matching rows, save a pointer to them and - update these in a separate loop based on the pointer. + We are doing a search on a key that is updated. In this case + we go trough the matching rows, save a pointer to them and + update these in a separate loop based on the pointer. */ explain->buf_tracker.on_scan_init(); IO_CACHE tempfile; From 2cc5750c799b39364a7a2be0b2d18eb8ac6521fd Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 5 Jan 2022 14:52:15 +0200 Subject: [PATCH 006/123] Updated convert-debug-for-diff --- scripts/convert-debug-for-diff.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/convert-debug-for-diff.sh b/scripts/convert-debug-for-diff.sh index 5b3ce05b815..4d266a6d526 100755 --- a/scripts/convert-debug-for-diff.sh +++ b/scripts/convert-debug-for-diff.sh @@ -18,8 +18,25 @@ while (<>) { - s/^T@[0-9]+\s*://g; - s/0x[0-9a-f]+(\s|\n|\))/#$1/g; - s/size: [0-9]+/size: #/g; + s/^T@[0-9]+ *://g; + s/0x[0-9a-f]+(\s|\n|\)|=|,|;)/#$1/g; + s/size: [0-9-]+/size: #/g; + s/memory_used: [0-9]+/memory_used: #/g; + s/Total alloc: [0-9]+/Total alloc: #/g; + s/(proc_info: )(.*:)[\d]+ /$1 /; + s/(select_cond.*) at line.*/$1/; + s/\(id: \d+ -> \d+\)/id: #->#/g; + s/(exit: found key at )\d+/$1#/g; + s/enter_stage: ([^\/]*)(\/.*\/)(.*)(:\d+)/enter_stage: ($1)/g; + s/crc: [0-9]+/crc: #/g; + s/ref_count: [0-9]+/ref_count: #/g; + s/block: # \(\d+\)/block: # (#)/g; + s/delete_mutex: # mutex: # \(id: \d+ \<\- \d+\)/delete_mutex: # mutex: # (id: # <- #)/g; + s/ShortTrID: [0-9]+/ShortTrID: #/g; + s/timestamp:[0-9]+/timestamp:#/g; + s/#sql_.*_(\d+)/#sql_xxx_$1/g; + s/fd: [0-9]+/fd: #/g; + s/query_id: (\d+)/query_id: #/g; + s|: .*/mysql-test/var/tmp/mysqld\.\d|d: var/tmp/mysqld|g; print $_; } From bcd5454beb4e237bce4441eda5e5ec5a0405f8f9 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 19 Oct 2021 18:08:12 +0300 Subject: [PATCH 007/123] Change class variable names in rowid_filter to longer, more clear names No code logic changes was done a -> gain b -> cost_of_building_range_filter a_adj -> gain_adj r -> row_combinations Other things: - Optimized the layout of class Range_rowid_filter_cost_info. One effect was that I moved key_no to the private section to get better alignment and had to introduce a get_key_no() function. - Indentation changes in rowid_filter.cc to avoid long rows. --- sql/opt_trace.cc | 2 +- sql/rowid_filter.cc | 41 ++++++++++++++++++++++------------------- sql/rowid_filter.h | 37 +++++++++++++++++++------------------ sql/sql_select.cc | 8 ++++---- 4 files changed, 46 insertions(+), 42 deletions(-) diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc index a7e8c3da63b..6dd54d259c0 100644 --- a/sql/opt_trace.cc +++ b/sql/opt_trace.cc @@ -692,7 +692,7 @@ void print_best_access_for_table(THD *thd, POSITION *pos, obj.add("uses_join_buffering", pos->use_join_buffer); if (pos->range_rowid_filter_info) { - uint key_no= pos->range_rowid_filter_info->key_no; + uint key_no= pos->range_rowid_filter_info->get_key_no(); obj.add("rowid_filter_key", pos->table->table->key_info[key_no].name); } diff --git a/sql/rowid_filter.cc b/sql/rowid_filter.cc index c775bdf35d6..29e82c5e9cc 100644 --- a/sql/rowid_filter.cc +++ b/sql/rowid_filter.cc @@ -24,8 +24,8 @@ inline -double Range_rowid_filter_cost_info::lookup_cost( - Rowid_filter_container_type cont_type) +double Range_rowid_filter_cost_info:: +lookup_cost(Rowid_filter_container_type cont_type) { switch (cont_type) { case SORTED_ARRAY_CONTAINER: @@ -44,8 +44,8 @@ double Range_rowid_filter_cost_info::lookup_cost( */ inline -double Range_rowid_filter_cost_info::avg_access_and_eval_gain_per_row( - Rowid_filter_container_type cont_type) +double Range_rowid_filter_cost_info:: +avg_access_and_eval_gain_per_row(Rowid_filter_container_type cont_type) { return (1+1.0/TIME_FOR_COMPARE) * (1 - selectivity) - lookup_cost(cont_type); @@ -76,10 +76,11 @@ double Range_rowid_filter_cost_info::avg_access_and_eval_gain_per_row( */ inline -double Range_rowid_filter_cost_info::avg_adjusted_gain_per_row( - double access_cost_factor) +double Range_rowid_filter_cost_info:: +avg_adjusted_gain_per_row(double access_cost_factor) { - return a - (1 - access_cost_factor) * (1 - selectivity); + DBUG_ASSERT(access_cost_factor >= 0.0 && access_cost_factor <= 1.0); + return gain - (1 - access_cost_factor) * (1 - selectivity); } @@ -93,10 +94,11 @@ double Range_rowid_filter_cost_info::avg_adjusted_gain_per_row( */ inline void -Range_rowid_filter_cost_info::set_adjusted_gain_param(double access_cost_factor) +Range_rowid_filter_cost_info:: +set_adjusted_gain_param(double access_cost_factor) { - a_adj= avg_adjusted_gain_per_row(access_cost_factor); - cross_x_adj= b / a_adj; + gain_adj= avg_adjusted_gain_per_row(access_cost_factor); + cross_x_adj= cost_of_building_range_filter / gain_adj; } @@ -118,13 +120,13 @@ void Range_rowid_filter_cost_info::init(Rowid_filter_container_type cont_type, table= tab; key_no= idx; est_elements= (ulonglong) table->opt_range[key_no].rows; - b= build_cost(container_type); + cost_of_building_range_filter= build_cost(container_type); selectivity= est_elements/((double) table->stat_records()); - a= avg_access_and_eval_gain_per_row(container_type); - if (a > 0) - cross_x= b/a; + gain= avg_access_and_eval_gain_per_row(container_type); + if (gain > 0) + cross_x= cost_of_building_range_filter/gain; else - cross_x= b+1; + cross_x= cost_of_building_range_filter+1; abs_independent.clear_all(); } @@ -179,7 +181,7 @@ int compare_range_rowid_filter_cost_info_by_a( Range_rowid_filter_cost_info **filter_ptr_1, Range_rowid_filter_cost_info **filter_ptr_2) { - double diff= (*filter_ptr_2)->get_a() - (*filter_ptr_1)->get_a(); + double diff= (*filter_ptr_2)->get_gain() - (*filter_ptr_1)->get_gain(); return (diff < 0 ? -1 : (diff > 0 ? 1 : 0)); } @@ -206,7 +208,8 @@ void TABLE::prune_range_rowid_filters() the elements if this bit matrix. */ - Range_rowid_filter_cost_info **filter_ptr_1= range_rowid_filter_cost_info_ptr; + Range_rowid_filter_cost_info **filter_ptr_1= + range_rowid_filter_cost_info_ptr; for (uint i= 0; i < range_rowid_filter_cost_info_elems; i++, filter_ptr_1++) @@ -245,7 +248,7 @@ void TABLE::prune_range_rowid_filters() */ Range_rowid_filter_cost_info **cand_filter_ptr= - range_rowid_filter_cost_info_ptr; + range_rowid_filter_cost_info_ptr; for (uint i= 0; i < range_rowid_filter_cost_info_elems; i++, cand_filter_ptr++) @@ -439,7 +442,7 @@ void Range_rowid_filter_cost_info::trace_info(THD *thd) { Json_writer_object js_obj(thd); js_obj.add("key", table->key_info[key_no].name); - js_obj.add("build_cost", b); + js_obj.add("build_cost", cost_of_building_range_filter); js_obj.add("rows", est_elements); } diff --git a/sql/rowid_filter.h b/sql/rowid_filter.h index cb1615c5925..bcafb35d142 100644 --- a/sql/rowid_filter.h +++ b/sql/rowid_filter.h @@ -396,14 +396,16 @@ class Range_rowid_filter_cost_info : public Sql_alloc TABLE *table; /* Estimated number of elements in the filter */ ulonglong est_elements; - /* The cost of building the range filter */ - double b; + /* The index whose range scan would be used to build the range filter */ + uint key_no; + double cost_of_building_range_filter; /* - a*N-b yields the gain of the filter - for N key tuples of the index key_no + (gain*row_combinations)-cost_of_building_range_filter yields the gain of + the filter for 'row_combinations' key tuples of the index key_no + calculated with avg_access_and_eval_gain_per_row(container_type); */ - double a; - /* The value of N where the gain is 0 */ + double gain; + /* The value of row_combinations where the gain is 0 */ double cross_x; /* Used for pruning of the potential range filters */ key_map abs_independent; @@ -412,16 +414,14 @@ class Range_rowid_filter_cost_info : public Sql_alloc These two parameters are used to choose the best range filter in the function TABLE::best_range_rowid_filter_for_partial_join */ - double a_adj; + double gain_adj; double cross_x_adj; public: - /* The type of the container of the range filter */ - Rowid_filter_container_type container_type; - /* The index whose range scan would be used to build the range filter */ - uint key_no; /* The selectivity of the range filter */ double selectivity; + /* The type of the container of the range filter */ + Rowid_filter_container_type container_type; Range_rowid_filter_cost_info() : table(0), key_no(0) {} @@ -440,29 +440,30 @@ public: inline void set_adjusted_gain_param(double access_cost_factor); /* Get the gain that usage of filter promises for r key tuples */ - inline double get_gain(double r) + inline double get_gain(double row_combinations) { - return r * a - b; + return row_combinations * gain - cost_of_building_range_filter; } /* Get the adjusted gain that usage of filter promises for r key tuples */ - inline double get_adjusted_gain(double r) + inline double get_adjusted_gain(double row_combinations) { - return r * a_adj - b; + return row_combinations * gain_adj - cost_of_building_range_filter; } /* The gain promised by usage of the filter for r key tuples due to less condition evaluations */ - inline double get_cmp_gain(double r) + inline double get_cmp_gain(double row_combinations) { - return r * (1 - selectivity) / TIME_FOR_COMPARE; + return row_combinations * (1 - selectivity) / TIME_FOR_COMPARE; } Rowid_filter_container *create_container(); - double get_a() { return a; } + double get_gain() { return gain; } + uint get_key_no() { return key_no; } void trace_info(THD *thd); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a3175dd0769..88a3c1e12de 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1917,9 +1917,9 @@ bool JOIN::make_range_rowid_filters() continue; DBUG_ASSERT(!(tab->ref.key >= 0 && - tab->ref.key == (int) tab->range_rowid_filter_info->key_no)); + tab->ref.key == (int) tab->range_rowid_filter_info->get_key_no())); DBUG_ASSERT(!(tab->ref.key == -1 && tab->quick && - tab->quick->index == tab->range_rowid_filter_info->key_no)); + tab->quick->index == tab->range_rowid_filter_info->get_key_no())); int err; SQL_SELECT *sel= NULL; @@ -1932,7 +1932,7 @@ bool JOIN::make_range_rowid_filters() key_map filter_map; filter_map.clear_all(); - filter_map.set_bit(tab->range_rowid_filter_info->key_no); + filter_map.set_bit(tab->range_rowid_filter_info->get_key_no()); filter_map.merge(tab->table->with_impossible_ranges); bool force_index_save= tab->table->force_index; tab->table->force_index= true; @@ -8429,7 +8429,7 @@ best_access_path(JOIN *join, tmp-= filter->get_adjusted_gain(rows) - filter->get_cmp_gain(rows); DBUG_ASSERT(tmp >= 0); trace_access_idx.add("rowid_filter_key", - table->key_info[filter->key_no].name); + table->key_info[filter->get_key_no()].name); } } } From 987fcf9197f9a5c1c0bfd9363e0954c6308e5bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Sat, 2 Jul 2022 21:47:57 +0300 Subject: [PATCH 008/123] cleanup: Typo fix appliccable -> applicable --- include/my_sys.h | 2 +- mysys/mf_radix.c | 2 +- mysys/mf_sort.c | 2 +- sql/filesort_utils.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 699f13bfcf1..58141fda9a9 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -782,7 +782,7 @@ extern int flush_write_cache(RECORD_CACHE *info); extern void handle_recived_signals(void); extern sig_handler my_set_alarm_variable(int signo); -extern my_bool radixsort_is_appliccable(uint n_items, size_t size_of_element); +extern my_bool radixsort_is_applicable(uint n_items, size_t size_of_element); extern void my_string_ptr_sort(uchar *base,uint items,size_t size); extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, size_t size_of_element,uchar *buffer[]); diff --git a/mysys/mf_radix.c b/mysys/mf_radix.c index 8f044cf9b29..89a3c4ac6ce 100644 --- a/mysys/mf_radix.c +++ b/mysys/mf_radix.c @@ -26,7 +26,7 @@ /* Radixsort */ -my_bool radixsort_is_appliccable(uint n_items, size_t size_of_element) +my_bool radixsort_is_applicable(uint n_items, size_t size_of_element) { return size_of_element <= 20 && n_items >= 1000 && n_items < 100000; } diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c index 24e875b813e..79bdfdd23aa 100644 --- a/mysys/mf_sort.c +++ b/mysys/mf_sort.c @@ -23,7 +23,7 @@ void my_string_ptr_sort(uchar *base, uint items, size_t size) #if INT_MAX > 65536L uchar **ptr=0; - if (radixsort_is_appliccable(items, size) && + if (radixsort_is_applicable(items, size) && (ptr= (uchar**) my_malloc(PSI_NOT_INSTRUMENTED, items * sizeof(char*),MYF(0)))) { diff --git a/sql/filesort_utils.cc b/sql/filesort_utils.cc index 5a51300a0fa..341e43ea6cf 100644 --- a/sql/filesort_utils.cc +++ b/sql/filesort_utils.cc @@ -173,7 +173,7 @@ void Filesort_buffer::sort_buffer(const Sort_param *param, uint count) uchar **buffer= NULL; if (!param->using_packed_sortkeys() && - radixsort_is_appliccable(count, param->sort_length) && + radixsort_is_applicable(count, param->sort_length) && (buffer= (uchar**) my_malloc(PSI_INSTRUMENT_ME, count*sizeof(char*), MYF(MY_THREAD_SPECIFIC)))) { From 07b0d1a35d3afbfb086a1229decb884311bebd28 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 22 Oct 2021 14:17:31 +0300 Subject: [PATCH 009/123] Adjusted Range_rowid_filter_cost_info lookup cost slightly. If the array size would be 1, the cost would be 0 which is wrong. Fixed by adding a small (0.001) base value to the lookup cost. This causes not changes in any result files. --- sql/rowid_filter.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/rowid_filter.cc b/sql/rowid_filter.cc index 29e82c5e9cc..22e46c3f42d 100644 --- a/sql/rowid_filter.cc +++ b/sql/rowid_filter.cc @@ -29,7 +29,8 @@ lookup_cost(Rowid_filter_container_type cont_type) { switch (cont_type) { case SORTED_ARRAY_CONTAINER: - return log(est_elements)*0.01; + /* The addition is here to take care of arrays with 1 element */ + return log(est_elements)*0.01+0.001; default: DBUG_ASSERT(0); return 0; From fc0c157aaa0b1603a321890c6c43b4b6b5e3b2e3 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 5 Nov 2021 13:06:14 +0200 Subject: [PATCH 010/123] Simple optimization to speed up some handler functions when checking killed - Avoid checking for has_transactions if killed flag is not checked - Simplify code (Have checked with gcc -O3 that there is improvements) - Added handler::fast_increment_statstics() to be used when a handler functions wants to increase two statistics for one row access. - Made check_limit_rows_examened() inline (even if it didn't make any difference for gcc 7.5.0), still the right thing to do --- sql/handler.cc | 40 +++++++++++++++++++++++++++------------- sql/handler.h | 10 ++++++++++ sql/sql_class.h | 7 ++++++- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 837a7be7ad6..b10cf19f3e3 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6749,17 +6749,25 @@ extern "C" check_result_t handler_index_cond_check(void* h_arg) check_result_t res; DEBUG_SYNC(thd, "handler_index_cond_check"); - enum thd_kill_levels abort_at= h->has_rollback() ? - THD_ABORT_SOFTLY : THD_ABORT_ASAP; - if (thd_kill_level(thd) > abort_at) - return CHECK_ABORTED_BY_USER; - if (h->end_range && h->compare_key2(h->end_range) > 0) + enum thd_kill_levels killed= thd_kill_level(thd); + if (unlikely(killed != THD_IS_NOT_KILLED)) + { + enum thd_kill_levels abort_at= (h->has_transactions() ? + THD_ABORT_SOFTLY : + THD_ABORT_ASAP); + if (killed > abort_at) + return CHECK_ABORTED_BY_USER; + } + if (unlikely(h->end_range) && h->compare_key2(h->end_range) > 0) return CHECK_OUT_OF_RANGE; h->increment_statistics(&SSV::ha_icp_attempts); - if ((res= h->pushed_idx_cond->val_int()? CHECK_POS : CHECK_NEG) == - CHECK_POS) - h->increment_statistics(&SSV::ha_icp_match); + res= CHECK_NEG; + if (h->pushed_idx_cond->val_int()) + { + res= CHECK_POS; + h->fast_increment_statistics(&SSV::ha_icp_match); + } return res; } @@ -6783,17 +6791,23 @@ check_result_t handler_rowid_filter_check(void *h_arg) { THD *thd= h->table->in_use; DEBUG_SYNC(thd, "handler_rowid_filter_check"); - enum thd_kill_levels abort_at= h->has_transactions() ? - THD_ABORT_SOFTLY : THD_ABORT_ASAP; - if (thd_kill_level(thd) > abort_at) - return CHECK_ABORTED_BY_USER; + + enum thd_kill_levels killed= thd_kill_level(thd); + if (unlikely(killed != THD_IS_NOT_KILLED)) + { + enum thd_kill_levels abort_at= (h->has_transactions() ? + THD_ABORT_SOFTLY : + THD_ABORT_ASAP); + if (killed > abort_at) + return CHECK_ABORTED_BY_USER; + } if (h->end_range && h->compare_key2(h->end_range) > 0) return CHECK_OUT_OF_RANGE; } h->position(tab->record[0]); - return h->pushed_rowid_filter->check((char*)h->ref)? CHECK_POS: CHECK_NEG; + return h->pushed_rowid_filter->check((char*)h->ref) ? CHECK_POS: CHECK_NEG; } diff --git a/sql/handler.h b/sql/handler.h index 6b05da2ca98..2b5e41d1bdd 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3559,6 +3559,10 @@ public: table_share= share; reset_statistics(); } + + /* + Time for a full table scan of data file + */ virtual double scan_time() { return ((ulonglong2double(stats.data_file_length) / stats.block_size + 2) * @@ -4785,7 +4789,13 @@ protected: However, engines that implement read_range_XXX() (like MariaRocks) or embed other engines (like ha_partition) may need to call these also */ + /* + Increment statistics. As a side effect increase accessed_rows_and_keys + and checks if lex->limit_rows_examined_cnt is reached + */ inline void increment_statistics(ulong SSV::*offset) const; + /* Same as increment_statistics but doesn't increase accessed_rows_and_keys */ + inline void fast_increment_statistics(ulong SSV::*offset) const; inline void decrement_statistics(ulong SSV::*offset) const; private: diff --git a/sql/sql_class.h b/sql/sql_class.h index e13fe9defcb..5e61f94b8ae 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3400,7 +3400,7 @@ public: Check if the number of rows accessed by a statement exceeded LIMIT ROWS EXAMINED. If so, signal the query engine to stop execution. */ - void check_limit_rows_examined() + inline void check_limit_rows_examined() { if (++accessed_rows_and_keys > lex->limit_rows_examined_cnt) set_killed(ABORT_QUERY); @@ -7408,6 +7408,11 @@ inline void handler::increment_statistics(ulong SSV::*offset) const table->in_use->check_limit_rows_examined(); } +inline void handler::fast_increment_statistics(ulong SSV::*offset) const +{ + status_var_increment(table->in_use->status_var.*offset); +} + inline void handler::decrement_statistics(ulong SSV::*offset) const { status_var_decrement(table->in_use->status_var.*offset); From 7d0bef6cd7be6a2764be05071b4ea78729698f6b Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 6 Oct 2021 12:34:54 +0300 Subject: [PATCH 011/123] Fixed bug in SQL_SELECT_LIMIT We where comparing costs when we should be comparing number of rows that will be examined --- mysql-test/suite/sys_vars/r/max_join_size_func.result | 6 +++--- mysql-test/suite/sys_vars/r/sql_big_selects_func.result | 2 +- mysql-test/suite/sys_vars/t/max_join_size_func.test | 4 ++-- mysql-test/suite/sys_vars/t/sql_big_selects_func.test | 4 +--- sql/sql_select.cc | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/max_join_size_func.result b/mysql-test/suite/sys_vars/r/max_join_size_func.result index cacc918ea02..d46b89d1f44 100644 --- a/mysql-test/suite/sys_vars/r/max_join_size_func.result +++ b/mysql-test/suite/sys_vars/r/max_join_size_func.result @@ -39,19 +39,19 @@ id name id name connect test_con1, localhost, root,,; connection test_con1; ## Setting value of max_join_size ## -SET @@session.max_join_size=8; +SET @@session.max_join_size=4; ## Since total joins are more than max_join_size value so error will occur ## SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id; ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay '#--------------------FN_DYNVARS_079_03-------------------------#' ## Setting global value of variable ## -SET @@global.max_join_size=8; +SET @@global.max_join_size=4; connect test_con2, localhost, root,,; connection test_con2; ## Verifying value of max_join_size ## SELECT @@global.max_join_size; @@global.max_join_size -8 +4 ## Since total joins are more than max_join_size value so error will occur ## SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id; ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay diff --git a/mysql-test/suite/sys_vars/r/sql_big_selects_func.result b/mysql-test/suite/sys_vars/r/sql_big_selects_func.result index 609401c771c..104103f681e 100644 --- a/mysql-test/suite/sys_vars/r/sql_big_selects_func.result +++ b/mysql-test/suite/sys_vars/r/sql_big_selects_func.result @@ -3,7 +3,7 @@ SET @session_sql_big_selects = @@SESSION.sql_big_selects; SET @session_max_join_size = @@SESSION.max_join_size; SET @global_max_join_size = @@GLOBAL.max_join_size; -SET MAX_JOIN_SIZE=9; +SET MAX_JOIN_SIZE=21; CREATE TEMPORARY TABLE t1(a varchar(20) not null, b varchar(20)); CREATE TEMPORARY TABLE t2(a varchar(20) null, b varchar(20)); INSERT INTO t1 VALUES('aa','bb'); diff --git a/mysql-test/suite/sys_vars/t/max_join_size_func.test b/mysql-test/suite/sys_vars/t/max_join_size_func.test index c649c036565..5fc8ee5855b 100644 --- a/mysql-test/suite/sys_vars/t/max_join_size_func.test +++ b/mysql-test/suite/sys_vars/t/max_join_size_func.test @@ -84,7 +84,7 @@ connect (test_con1, localhost, root,,); connection test_con1; --echo ## Setting value of max_join_size ## -SET @@session.max_join_size=8; +SET @@session.max_join_size=4; --echo ## Since total joins are more than max_join_size value so error will occur ## --Error ER_TOO_BIG_SELECT @@ -97,7 +97,7 @@ SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id; ########################################################## --echo ## Setting global value of variable ## -SET @@global.max_join_size=8; +SET @@global.max_join_size=4; connect (test_con2, localhost, root,,); connection test_con2; diff --git a/mysql-test/suite/sys_vars/t/sql_big_selects_func.test b/mysql-test/suite/sys_vars/t/sql_big_selects_func.test index 59d8184861d..b8ff7c53f75 100644 --- a/mysql-test/suite/sys_vars/t/sql_big_selects_func.test +++ b/mysql-test/suite/sys_vars/t/sql_big_selects_func.test @@ -28,7 +28,7 @@ SET @session_sql_big_selects = @@SESSION.sql_big_selects; SET @session_max_join_size = @@SESSION.max_join_size; SET @global_max_join_size = @@GLOBAL.max_join_size; -SET MAX_JOIN_SIZE=9; +SET MAX_JOIN_SIZE=21; # # Create tables @@ -115,8 +115,6 @@ disconnect con_int2; # # Cleanup # - - SET @@SESSION.sql_big_selects = @session_sql_big_selects; SET @@SESSION.max_join_size = @session_max_join_size; SET @@GLOBAL.max_join_size = @global_max_join_size; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 88a3c1e12de..13131ecf7f6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2621,7 +2621,7 @@ int JOIN::optimize_stage2() goto setup_subq_exit; } if (!(thd->variables.option_bits & OPTION_BIG_SELECTS) && - best_read > (double) thd->variables.max_join_size && + join_record_count > (double) thd->variables.max_join_size && !(select_options & SELECT_DESCRIBE)) { /* purecov: inspected */ my_message(ER_TOO_BIG_SELECT, ER_THD(thd, ER_TOO_BIG_SELECT), MYF(0)); From dc2f0d138d3a90903013d2133199c9b6723b5971 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 6 Oct 2021 12:53:18 +0300 Subject: [PATCH 012/123] Fix calculation of selectivity calculate_cond_selectivity_for_table() is largely rewritten: - Process keys in the order of rows found, smaller ranges first. If two ranges has equal number of rows, use the one with more key parts. This helps us to mark more used fields to not be used for further selectivity calculations. See cmp_quick_ranges(). - Ignore keys with fields that where used by previous keys - Don't use rec_per_key[] to calculate selectivity for smaller secondary key parts. This does not work as rec_per_key[] value is calculated in the context of the previous key parts, not for the key part itself. The one exception is if the previous key parts are all constants. Other things: - Ensure that select->cond_selectivity is always between 0 and 1. - Ensure that select->opt_range_condition_rows is never updated to a higher value. It is initially set to the number of rows in table. - We now store in table->opt_range_condition_rows the lowest number of rows that any row-read-method has found so far. Before it was only done for QUICK_SELECT_I::QS_TYPE_ROR_UNION and QUICK_SELECT_I::QS_TYPE_INDEX_MERGE. Now it is done for a lot more methods. See calculate_cond_selectivity_for_table() for details. - Calculate and use selectivity for the first key part of a multiple key part if the first key part is a constant. WHERE key1_part1=5 and key2_part1=5. IF key1 is used, then we can still use selectivity for key2 Changes in test results: - 'filtered' is slightly changed, usually to something slightly smaller. - A few cases where for group by queries the table order changed. This was because the number of resulting rows from a group by query with MIN/MAX is now set to be smaller. - A few index was changed as we now prefer index with more key parts if the number of resulting rows is the same. --- mysql-test/main/group_min_max.result | 4 +- mysql-test/main/mdev-25830.result | 2 +- mysql-test/main/opt_trace_index_merge.result | 6 +- mysql-test/main/opt_trace_selectivity.result | 341 +++++++++++++++++++ mysql-test/main/opt_trace_selectivity.test | 52 +++ sql/opt_range.cc | 264 ++++++++------ sql/opt_range.h | 7 + sql/sql_select.cc | 37 +- sql/table.h | 14 +- 9 files changed, 622 insertions(+), 105 deletions(-) create mode 100644 mysql-test/main/opt_trace_selectivity.result create mode 100644 mysql-test/main/opt_trace_selectivity.test diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index 0b29dbf7329..54ae9e1c9e0 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -2460,8 +2460,8 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1_outer index a a 10 NULL 15 Using where; Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1_outer.a 1 +1 PRIMARY ALL distinct_key NULL NULL NULL 2 +1 PRIMARY t1_outer ref a a 5 .max(b) 3 Using index 2 MATERIALIZED t1 range a a 5 NULL 5 Using where; Using index EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); diff --git a/mysql-test/main/mdev-25830.result b/mysql-test/main/mdev-25830.result index e62d1ff3f55..2c606205565 100644 --- a/mysql-test/main/mdev-25830.result +++ b/mysql-test/main/mdev-25830.result @@ -47,7 +47,7 @@ WHERE task2.`sys_id` LIKE '8e7792a7dbfffb00fff8a345ca961934%' ORDER BY sysapproval_approver0.`order` LIMIT 0, 50 ; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE task2 range PRIMARY,sys_class_name_2,sys_domain_path PRIMARY 96 NULL 1 0.00 98.00 100.00 Using where; Using temporary; Using filesort +1 SIMPLE task2 range PRIMARY,sys_class_name_2,sys_domain_path PRIMARY 96 NULL 1 0.00 100.00 100.00 Using where; Using temporary; Using filesort 1 SIMPLE task1 ref PRIMARY,task_parent,sys_class_name_2,sys_domain_path task_parent 99 test.task2.sys_id 1 NULL 100.00 NULL Using index condition; Using where 1 SIMPLE sysapproval_approver0 ref sysapproval_approver_ref5,sys_domain_path,sysapproval_approver_CHG1975376 sysapproval_approver_ref5 99 test.task1.sys_id 1 NULL 100.00 NULL Using index condition; Using where drop table sysapproval_approver,task; diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result index 0ffa930e2b0..dd23093ad9e 100644 --- a/mysql-test/main/opt_trace_index_merge.result +++ b/mysql-test/main/opt_trace_index_merge.result @@ -193,7 +193,11 @@ explain select * from t1 where a=1 or b=1 { } }, { - "selectivity_for_indexes": [], + "selectivity_for_indexes": [ + { + "use_opt_range_condition_rows_selectivity": 0.002 + } + ], "selectivity_for_columns": [], "cond_selectivity": 0.002 } diff --git a/mysql-test/main/opt_trace_selectivity.result b/mysql-test/main/opt_trace_selectivity.result new file mode 100644 index 00000000000..0c493d37812 --- /dev/null +++ b/mysql-test/main/opt_trace_selectivity.result @@ -0,0 +1,341 @@ +create or replace table t1 (a int, b int, c int, key(a,c), key(b,c), key (c,b)) engine=aria; +insert into t1 select seq/100+1, mod(seq,10), mod(seq,15) from seq_1_to_10000; +insert into t1 select seq/100+1, mod(seq,10), 10 from seq_1_to_1000; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +select count(*) from t1 where a=2; +count(*) +200 +select count(*) from t1 where b=5; +count(*) +1100 +select count(*) from t1 where c=5; +count(*) +667 +select count(*) from t1 where c=10; +count(*) +1667 +select count(*) from t1 where a=2 and b=5; +count(*) +20 +select count(*) from t1 where c=10 and b=5; +count(*) +433 +select count(*) from t1 where c=5 and b=5; +count(*) +334 +set optimizer_trace="enabled=on"; +select count(*) from t1 where a=2 and b=5 and c=10; +count(*) +14 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) +[ + [ + { + "plan_prefix": + [], + "get_costs_for_tables": + [ + { + "best_access_path": + { + "table": "t1", + "considered_access_paths": + [ + { + "access_type": "ref", + "index": "a", + "used_range_estimates": true, + "rows": 104, + "cost": 104.16562, + "chosen": true + }, + { + "access_type": "ref", + "index": "b", + "used_range_estimates": true, + "rows": 340, + "cost": 340.2577963, + "chosen": false, + "cause": "cost" + }, + { + "access_type": "ref", + "index": "c", + "used_range_estimates": true, + "rows": 632, + "cost": 632.3718449, + "chosen": false, + "cause": "cost" + }, + { + "access_type": "index_merge", + "resulting_rows": 7, + "cost": 2.173416331, + "chosen": true + } + ], + "chosen_access_method": + { + "type": "index_merge", + "records": 7, + "cost": 2.173416331, + "uses_join_buffering": false + } + } + } + ] + }, + { + "plan_prefix": + [], + "table": "t1", + "rows_for_plan": 7, + "cost_for_plan": 3.573416331 + } + ] +] +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 0.009454545 + }, + { + "index_name": "b", + "selectivity_from_index": 0.1 + }, + { + "use_opt_range_condition_rows_selectivity": 6.363636e-4 + } + ] +] +select count(*) from t1 where a=2 and b=5 and c=5; +count(*) +3 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) +[ + [ + { + "plan_prefix": + [], + "get_costs_for_tables": + [ + { + "best_access_path": + { + "table": "t1", + "considered_access_paths": + [ + { + "access_type": "ref", + "index": "a", + "used_range_estimates": true, + "rows": 6, + "cost": 6.127343464, + "chosen": true + }, + { + "access_type": "ref", + "index": "b", + "used_range_estimates": true, + "rows": 232, + "cost": 232.2156139, + "chosen": false, + "cause": "cost" + }, + { + "access_type": "ref", + "index": "c", + "used_range_estimates": true, + "rows": 293, + "cost": 293.2394392, + "chosen": false, + "cause": "cost" + }, + { + "access_type": "index_merge", + "resulting_rows": 0.6, + "cost": 2.172957403, + "chosen": true + } + ], + "chosen_access_method": + { + "type": "index_merge", + "records": 0.6, + "cost": 2.172957403, + "uses_join_buffering": false + } + } + } + ] + }, + { + "plan_prefix": + [], + "table": "t1", + "rows_for_plan": 0.6, + "cost_for_plan": 2.292957403 + } + ] +] +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 5.454545e-4 + }, + { + "index_name": "b", + "selectivity_from_index": 0.1 + } + ] +] +# Ensure that we only use selectivity from non used index for simple cases +select count(*) from t1 where (a=2 and b= 5); +count(*) +20 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 0.017545455 + }, + { + "index_name": "b", + "selectivity_from_index": 0.073181818 + } + ] +] +# All of the following should have selectivity=1 for index 'b' +select count(*) from t1 where (a=2 and b between 0 and 100); +count(*) +200 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 0.017545455 + }, + { + "index_name": "b", + "selectivity_from_index": 1 + } + ] +] +select count(*) from t1 where (a in (2,3) and b between 0 and 100); +count(*) +400 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 0.035090909 + }, + { + "index_name": "b", + "selectivity_from_index": 1 + } + ] +] +select count(*) from t1 where (a>2 and b between 0 and 100); +count(*) +10702 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 0.973909091 + }, + { + "index_name": "b", + "selectivity_from_index": 1 + } + ] +] +select count(*) from t1 where (a>=2 and b between 0 and 100); +count(*) +10902 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 0.991454545 + }, + { + "index_name": "b", + "selectivity_from_index": 1 + } + ] +] +select count(*) from t1 where (a<=2 and b between 0 and 100); +count(*) +298 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 0.026181818 + }, + { + "index_name": "b", + "selectivity_from_index": 1 + } + ] +] +select count(*) from t1 where (a<2 and b between 0 and 100); +count(*) +98 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 0.008636364 + }, + { + "index_name": "b", + "selectivity_from_index": 1 + } + ] +] +select count(*) from t1 where (a between 2 and 3 and b between 0 and 100); +count(*) +400 +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) +[ + [ + { + "index_name": "a", + "selectivity_from_index": 0.035090909 + }, + { + "index_name": "b", + "selectivity_from_index": 1 + } + ] +] +drop table t1; +set optimizer_trace='enabled=off'; diff --git a/mysql-test/main/opt_trace_selectivity.test b/mysql-test/main/opt_trace_selectivity.test new file mode 100644 index 00000000000..4d59d4974cd --- /dev/null +++ b/mysql-test/main/opt_trace_selectivity.test @@ -0,0 +1,52 @@ +--source include/have_sequence.inc +--source include/not_embedded.inc + +# +# Test changes in calculate_cond_selectivity_for_table() +# +create or replace table t1 (a int, b int, c int, key(a,c), key(b,c), key (c,b)) engine=aria; +insert into t1 select seq/100+1, mod(seq,10), mod(seq,15) from seq_1_to_10000; +insert into t1 select seq/100+1, mod(seq,10), 10 from seq_1_to_1000; +optimize table t1; + +select count(*) from t1 where a=2; +select count(*) from t1 where b=5; +select count(*) from t1 where c=5; +select count(*) from t1 where c=10; +select count(*) from t1 where a=2 and b=5; +select count(*) from t1 where c=10 and b=5; +select count(*) from t1 where c=5 and b=5; + +set optimizer_trace="enabled=on"; +select count(*) from t1 where a=2 and b=5 and c=10; +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; + +select count(*) from t1 where a=2 and b=5 and c=5; +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; + +--echo # Ensure that we only use selectivity from non used index for simple cases + + +select count(*) from t1 where (a=2 and b= 5); +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; + +--echo # All of the following should have selectivity=1 for index 'b' +select count(*) from t1 where (a=2 and b between 0 and 100); +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +select count(*) from t1 where (a in (2,3) and b between 0 and 100); +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +select count(*) from t1 where (a>2 and b between 0 and 100); +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +select count(*) from t1 where (a>=2 and b between 0 and 100); +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +select count(*) from t1 where (a<=2 and b between 0 and 100); +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +select count(*) from t1 where (a<2 and b between 0 and 100); +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +select count(*) from t1 where (a between 2 and 3 and b between 0 and 100); +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_indexes')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; + +drop table t1; +set optimizer_trace='enabled=off'; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 5e01b1272cc..dc39040aab4 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2749,7 +2749,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, KEY_PART *key_parts; KEY *key_info; PARAM param; - bool force_group_by = false; + bool force_group_by= false, group_by_optimization_used= false; if (check_stack_overrun(thd, 2*STACK_MIN_SIZE + sizeof(PARAM), buff)) DBUG_RETURN(0); // Fatal error flag is set @@ -3040,8 +3040,14 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, restore_nonrange_trees(¶m, tree, backup_keys); if ((group_trp= get_best_group_min_max(¶m, tree, read_time))) { - param.table->opt_range_condition_rows= MY_MIN(group_trp->records, - table_records); + /* mark that we are changing opt_range_condition_rows */ + group_by_optimization_used= 1; + set_if_smaller(param.table->opt_range_condition_rows, group_trp->records); + DBUG_PRINT("info", ("table_rows: %llu opt_range_condition_rows: %llu " + "group_trp->records: %ull", + table_records, param.table->opt_range_condition_rows, + group_trp->records)); + Json_writer_object grp_summary(thd, "best_group_range_summary"); if (unlikely(thd->trace_started())) @@ -3071,6 +3077,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, delete quick; quick= NULL; } + else + quick->group_by_optimization_used= group_by_optimization_used; } possible_keys= param.possible_keys; @@ -3316,12 +3324,12 @@ double records_in_column_ranges(PARAM *param, uint idx, */ static -int cmp_quick_ranges(TABLE *table, uint *a, uint *b) +int cmp_quick_ranges(TABLE::OPT_RANGE **a, TABLE::OPT_RANGE **b) { - int tmp= CMP_NUM(table->opt_range[*a].rows, table->opt_range[*b].rows); + int tmp=CMP_NUM((*a)->rows, (*b)->rows); if (tmp) return tmp; - return -CMP_NUM(table->opt_range[*a].key_parts, table->opt_range[*b].key_parts); + return -CMP_NUM((*a)->key_parts, (*b)->key_parts); } @@ -3366,14 +3374,14 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) { uint keynr, range_index, ranges; MY_BITMAP *used_fields= &table->cond_set; - double table_records= (double)table->stat_records(); - uint optimal_key_order[MAX_KEY]; + double table_records= (double)table->stat_records(), original_selectivity; + TABLE::OPT_RANGE *optimal_key_order[MAX_KEY]; MY_BITMAP handled_columns; my_bitmap_map *buf; QUICK_SELECT_I *quick; DBUG_ENTER("calculate_cond_selectivity_for_table"); - table->cond_selectivity= 1.0; + table->set_cond_selectivity(1.0); if (table_records == 0) DBUG_RETURN(FALSE); @@ -3381,7 +3389,10 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) if ((quick=table->reginfo.join_tab->quick) && quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) { - table->cond_selectivity*= (quick->records/table_records); + DBUG_ASSERT(table->opt_range_condition_rows <= quick->records); + table->set_cond_selectivity(MY_MIN(quick->records, + table->opt_range_condition_rows)/ + table_records); DBUG_RETURN(FALSE); } @@ -3413,93 +3424,135 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) */ for (ranges= keynr= 0 ; keynr < table->s->keys; keynr++) if (table->opt_range_keys.is_set(keynr)) - optimal_key_order[ranges++]= keynr; + optimal_key_order[ranges++]= table->opt_range + keynr; - my_qsort2(optimal_key_order, ranges, - sizeof(optimal_key_order[0]), - (qsort2_cmp) cmp_quick_ranges, table); + my_qsort(optimal_key_order, ranges, + sizeof(optimal_key_order[0]), + (qsort_cmp) cmp_quick_ranges); for (range_index= 0 ; range_index < ranges ; range_index++) { - uint keynr= optimal_key_order[range_index]; - { - { - uint i; - uint used_key_parts= table->opt_range[keynr].key_parts; - double quick_cond_selectivity= (table->opt_range[keynr].rows / - table_records); - KEY *key_info= table->key_info + keynr; - KEY_PART_INFO* key_part= key_info->key_part; - /* - Suppose, there are range conditions on two keys - KEY1 (col1, col2) - KEY2 (col3, col2) - - we don't want to count selectivity of condition on col2 twice. - - First, find the longest key prefix that's made of columns whose - selectivity wasn't already accounted for. - */ - for (i= 0; i < used_key_parts; i++, key_part++) - { - if (bitmap_is_set(&handled_columns, key_part->fieldnr-1)) - break; - bitmap_set_bit(&handled_columns, key_part->fieldnr-1); - } - if (i) - { - double UNINIT_VAR(selectivity_mult); + TABLE::OPT_RANGE *range= optimal_key_order[range_index]; + uint keynr= (uint)(range - table->opt_range); + uint i; + uint used_key_parts= range->key_parts; + double quick_cond_selectivity= (range->rows / table_records); + KEY *key_info= table->key_info + keynr; + KEY_PART_INFO* key_part= key_info->key_part; + DBUG_ASSERT(quick_cond_selectivity <= 1.0); - /* - There is at least 1-column prefix of columns whose selectivity has - not yet been accounted for. - */ - table->cond_selectivity*= quick_cond_selectivity; - Json_writer_object selectivity_for_index(thd); - selectivity_for_index.add("index_name", key_info->name) - .add("selectivity_from_index", - quick_cond_selectivity); - if (i != used_key_parts) - { - /* - Range access got us estimate for #used_key_parts. - We need estimate for #(i-1) key parts. - */ - double f1= key_info->actual_rec_per_key(i-1); - double f2= key_info->actual_rec_per_key(i); - if (f1 > 0 && f2 > 0) - selectivity_mult= f1 / f2; - else - { - /* - No statistics available, assume the selectivity is proportional - to the number of key parts. - (i=0 means 1 keypart, i=1 means 2 keyparts, so use i+1) - */ - selectivity_mult= ((double)(i+1)) / i; - } - table->cond_selectivity*= selectivity_mult; - selectivity_for_index.add("selectivity_multiplier", - selectivity_mult); - } + /* + Suppose, there are range conditions on these keys + KEY1 (col1, col2) + KEY2 (col2, col6) + KEY3 (col3, col2) + KEY4 (col4, col5) + + We don't want to count selectivity for ranges that uses a column + that was used before. + If the first column of an index was not used before, we can use the + key part statistics to calculate selectivity for this column. We cannot + calculate statistics for any other columns as the key part statistics + is also depending on the values of the previous key parts and not only + the last key part. + + In other words, if KEY1 has the smallest range, we will only use first + part of KEY3 and range of KEY4 to calculate selectivity. + */ + for (i= 0; i < used_key_parts; i++) + { + if (bitmap_is_set(&handled_columns, key_part[i].fieldnr-1)) + { + double rec_per_key; + if (!i) + { /* - We need to set selectivity for fields supported by indexes. - For single-component indexes and for some first components - of other indexes we do it here. For the remaining fields - we do it later in this function, in the same way as for the - fields not used in any indexes. - */ - if (i == 1) - { - uint fieldnr= key_info->key_part[0].fieldnr; - table->field[fieldnr-1]->cond_selectivity= quick_cond_selectivity; - if (i != used_key_parts) - table->field[fieldnr-1]->cond_selectivity*= selectivity_mult; - bitmap_clear_bit(used_fields, fieldnr-1); - } + We cannot use this key part for selectivity calculation as + key_info->actual_rec_per_key for later keys are depending on the + distribution of the previous key parts. + */ + goto end_of_range_loop; } + /* + A later key part was already used. We can still use key + statistics for the first key part to get some approximation + of the selectivity of this key. This can be done if the + first key part is a constant: + WHERE key1_part1=1 and key2_part1=5 and key2_part2 BETWEEN 0 and 10 + Even if key1 is used and it also includes the field for key2_part1 + as a key part, we can still use selectivity for key2_part1 + */ + if ((rec_per_key= key_info->actual_rec_per_key(0)) == 0.0 || + !range->first_key_part_has_only_one_value) + goto end_of_range_loop; + /* + Use key distribution statistics, except if range selectivity + is bigger. This can happen if the used key value has more + than an average number of instances. + */ + set_if_smaller(rec_per_key, rows2double(table->file->stats.records)); + set_if_bigger(quick_cond_selectivity, + rec_per_key / table->file->stats.records); + used_key_parts= 1; + break; } } + /* Set bits only after we have checked the used columns */ + for (i= 0; i < used_key_parts; i++, key_part++) + bitmap_set_bit(&handled_columns, key_part->fieldnr-1); + + /* + There is at least 1-column prefix of columns whose selectivity has + not yet been accounted for. + */ + table->multiply_cond_selectivity(quick_cond_selectivity); + + { + Json_writer_object selectivity_for_index(thd); + selectivity_for_index.add("index_name", key_info->name) + .add("selectivity_from_index", + quick_cond_selectivity); + } + /* + We need to set selectivity for fields supported by indexes. + For single-component indexes and for some first components + of other indexes we do it here. For the remaining fields + we do it later in this function, in the same way as for the + fields not used in any indexes. + */ + if (used_key_parts == 1) + { + uint fieldnr= key_info->key_part[0].fieldnr; + table->field[fieldnr-1]->cond_selectivity= quick_cond_selectivity; + DBUG_ASSERT(table->field[fieldnr-1]->cond_selectivity <= 1.0); + /* + Reset bit in used_fields to ensure this field is ignored in the loop + below. + */ + bitmap_clear_bit(used_fields, fieldnr-1); + } +end_of_range_loop: + continue; + } + /* + Take into account number of matching rows calculated by + get_best_ror_intersect() stored in table->opt_range_condition_rows + Use the smaller found selectivity. + */ + original_selectivity= (table->opt_range_condition_rows / + table_records); + if (original_selectivity < table->cond_selectivity) + { + DBUG_ASSERT(quick && + (quick->group_by_optimization_used || + quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT || + quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_UNION || + quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE || + quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT)); + Json_writer_object selectivity_for_index(thd); + table->cond_selectivity= original_selectivity; + selectivity_for_index.add("use_opt_range_condition_rows_selectivity", + original_selectivity); } selectivity_for_indexes.end(); @@ -3582,6 +3635,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) if (rows != DBL_MAX) { key->field->cond_selectivity= rows/table_records; + DBUG_ASSERT(key->field->cond_selectivity <= 1.0); selectivity_for_column.add("selectivity_from_histogram", key->field->cond_selectivity); } @@ -3596,7 +3650,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) table_field->cond_selectivity < 1.0) { if (!bitmap_is_set(&handled_columns, table_field->field_index)) - table->cond_selectivity*= table_field->cond_selectivity; + table->multiply_cond_selectivity(table_field->cond_selectivity); } } @@ -3608,12 +3662,6 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) } selectivity_for_columns.end(); - if (quick && (quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_UNION || - quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE)) - { - table->cond_selectivity*= (quick->records/table_records); - } - bitmap_union(used_fields, &handled_columns); /* Check if we can improve selectivity estimates by using sampling */ @@ -3651,7 +3699,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) DBUG_PRINT("info", ("The predicate selectivity : %g", (double)stat->positive / examined_rows)); double selectivity= ((double)stat->positive) / examined_rows; - table->cond_selectivity*= selectivity; + table->multiply_cond_selectivity(selectivity); /* If a field is involved then we register its selectivity in case there in an equality with the field. @@ -11519,6 +11567,26 @@ void SEL_ARG::test_use_count(SEL_ARG *root) } #endif + +/** + Check if first key part has only one value + + @retval 1 yes + @retval 0 no +*/ + +static bool check_if_first_key_part_has_only_one_value(SEL_ARG *arg) +{ + if (arg->left != &null_element || arg->right != &null_element) + return 0; // Multiple key values + if ((arg->min_flag | arg->max_flag) & (NEAR_MIN | NEAR_MAX)) + return 0; + if (unlikely(arg->type != SEL_ARG::KEY_RANGE)) // Not a valid range + return 0; + return arg->min_value == arg->max_value || !arg->cmp_min_to_max(arg); +} + + /* Calculate cost and E(#rows) for a given index and intervals tree @@ -11640,6 +11708,8 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only, range->index_only_cost= 0; else range->index_only_cost= cost->index_only_cost(); + range->first_key_part_has_only_one_value= + check_if_first_key_part_has_only_one_value(tree); } } @@ -11672,6 +11742,8 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only, *is_ror_scan= seq.is_ror_scan; DBUG_PRINT("exit", ("Records: %lu", (ulong) rows)); + DBUG_ASSERT(rows == HA_POS_ERROR || + rows <= MY_MAX(param->table->stat_records(), 1)); DBUG_RETURN(rows); //psergey-merge:todo: maintain first_null_comp. } diff --git a/sql/opt_range.h b/sql/opt_range.h index 7a067b49295..0973a9a944e 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -1109,6 +1109,13 @@ public: */ uint used_key_parts; + /* + Set to 1 if we used group by optimization to calculate number of rows + in the result, stored in table->opt_range_condition_rows. + This is only used for asserts. + */ + bool group_by_optimization_used; + QUICK_SELECT_I(); virtual ~QUICK_SELECT_I(){}; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 13131ecf7f6..d58b5790183 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5819,7 +5819,8 @@ make_join_statistics(JOIN *join, List &tables_list, get_delayed_table_estimates(s->table, &s->records, &s->read_time, &s->startup_cost); s->found_records= s->records; - table->opt_range_condition_rows=s->records; + s->table->opt_range_condition_rows= s->records; + s->table->used_stat_records= s->records; } else s->scan_time(); @@ -5843,8 +5844,12 @@ make_join_statistics(JOIN *join, List &tables_list, */ add_group_and_distinct_keys(join, s); - s->table->cond_selectivity= 1.0; - + /* This will be updated in calculate_cond_selectivity_for_table() */ + s->table->set_cond_selectivity(1.0); + DBUG_ASSERT(s->table->used_stat_records == 0 || + s->table->cond_selectivity <= + s->table->opt_range_condition_rows / + s->table->used_stat_records); /* Perform range analysis if there are keys it could use (1). Don't do range analysis for materialized subqueries (2). @@ -7725,6 +7730,15 @@ double matching_candidates_in_table(JOIN_TAB *s, bool with_found_constraint, TABLE *table= s->table; double sel= table->cond_selectivity; double table_records= rows2double(s->records); + DBUG_ASSERT(sel >= 0 && sel <= 1.0); + /* + table->cond_selectivity will include data from opt_range. + Here we check that this is indeeded the case. + Note that if table_records == 0, then 'sel' is probably 1 + */ + DBUG_ASSERT(table_records == 0 || + sel <= s->table->opt_range_condition_rows / + table_records); dbl_records= table_records * sel; return dbl_records; } @@ -9915,7 +9929,11 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, However if sel becomes greater than 2 then with high probability something went wrong. */ - sel /= (double)table->opt_range[key].rows / (double) table->stat_records(); + DBUG_ASSERT(sel <= 1.0); + DBUG_ASSERT(table->opt_range[key].rows <= + (double) table->stat_records()); + sel /= ((double) table->opt_range[key].rows / + (double) table->stat_records()); set_if_smaller(sel, 1.0); used_range_selectivity= true; } @@ -10059,6 +10077,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, exit: if (ref_keyuse_steps != ref_keyuse_steps_buf) my_free(ref_keyuse_steps); + DBUG_ASSERT(sel >= 0.0 and sel <= 1.0); return sel; } @@ -11489,6 +11508,7 @@ bool JOIN::get_best_combination() */ j->records_read= best_positions[tablenr].records_read; j->cond_selectivity= best_positions[tablenr].cond_selectivity; + DBUG_ASSERT(j->cond_selectivity <= 1.0); map2table[j->table->tablenr]= j; /* If we've reached the end of sjm nest, switch back to main sequence */ @@ -27824,6 +27844,15 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, KEY *key_info= 0; uint key_len= 0; +#ifdef NOT_YET + /* + Would be good to keep this condition up to date. + Another alternative is to remove JOIN_TAB::cond_selectivity and use + TABLE::cond_selectivity everywhere + */ + DBUG_ASSERT(cond_selectivity == table->cond_selectivity); +#endif + explain_plan= eta; eta->key.clear(); eta->quick_info= NULL; diff --git a/sql/table.h b/sql/table.h index 5e858a24f88..877af624837 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1398,6 +1398,7 @@ public: index only access for it is stored in index_only_costs[i] */ double index_only_cost; + bool first_key_part_has_only_one_value; } *opt_range; /* Bitmaps of key parts that =const for the duration of join execution. If @@ -1839,7 +1840,18 @@ public: DBUG_ASSERT(s->period.name); return field[s->period.end_fieldno]; } - + void set_cond_selectivity(double selectivity) + { + DBUG_ASSERT(selectivity >= 0.0 && selectivity <= 1.0); + cond_selectivity= selectivity; + DBUG_PRINT("info", ("cond_selectivity: %g", cond_selectivity)); + } + void multiply_cond_selectivity(double selectivity) + { + DBUG_ASSERT(selectivity >= 0.0 && selectivity <= 1.0); + cond_selectivity*= selectivity; + DBUG_PRINT("info", ("cond_selectivity: %g", cond_selectivity)); + } ulonglong vers_start_id() const; ulonglong vers_end_id() const; From b67144893a3ddf96ace15d21ed1bd572e19a33e0 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 7 Oct 2021 20:15:34 +0300 Subject: [PATCH 013/123] Update matching_candidates_in_table() to treat all conditions similar Fixed also that the 'with_found_constraint parameter' to matching_candidates_in_table() is as documented: It is now true only if there is a reference to a previous table in the WHERE condition for the current examined table (as it was originally documented) Changes in test results: - Filtered was 25% smaller for some queries (expected). - Some join order changed (probably because the tables had very few rows). - Some more table scans, probably because there would be fewer returned rows. - Some tests exposes a bug that if there is more filtered rows, then the cost for table scan will be higher. This will be fixed in a later commit. --- mysql-test/main/cte_recursive.result | 16 +-- mysql-test/main/delete.result | 6 +- mysql-test/main/derived_view.result | 24 ++-- mysql-test/main/distinct.result | 6 +- mysql-test/main/greedy_optimizer.result | 120 +++++++++--------- mysql-test/main/group_by.result | 8 +- mysql-test/main/join.result | 2 +- mysql-test/main/join.test | 2 +- mysql-test/main/join_cache.result | 8 +- mysql-test/main/join_nested.result | 2 +- mysql-test/main/join_nested_jcl6.result | 10 +- mysql-test/main/limit_rows_examined.result | 6 +- mysql-test/main/multi_update.result | 4 +- .../main/myisam_explain_non_select_all.result | 22 ++-- mysql-test/main/opt_trace.result | 40 +++--- mysql-test/main/rowid_filter.result | 31 ++--- mysql-test/main/rowid_filter_innodb.result | 31 ++--- mysql-test/main/select.result | 2 +- mysql-test/main/select_jcl6.result | 2 +- mysql-test/main/select_pkeycache.result | 2 +- mysql-test/main/selectivity.result | 8 +- mysql-test/main/stat_tables.result | 8 +- mysql-test/main/subselect.result | 14 +- mysql-test/main/subselect3.result | 2 +- mysql-test/main/subselect3_jcl6.result | 2 +- mysql-test/main/subselect_exists2in.result | 2 +- mysql-test/main/subselect_mat.result | 4 +- .../main/subselect_mat_cost_bugs.result | 2 +- .../main/subselect_no_exists_to_in.result | 12 +- mysql-test/main/subselect_no_mat.result | 14 +- mysql-test/main/subselect_no_opts.result | 6 +- mysql-test/main/subselect_no_scache.result | 14 +- mysql-test/main/subselect_no_semijoin.result | 18 +-- mysql-test/main/subselect_sj.result | 16 +-- mysql-test/main/subselect_sj_jcl6.result | 16 +-- mysql-test/main/subselect_sj_mat.result | 10 +- mysql-test/main/union.result | 2 +- mysql-test/suite/maria/mrr.result | 4 +- sql/sql_select.cc | 53 +++++--- .../r/direct_left_right_join_nullable.result | 2 +- ...rect_right_left_right_join_nullable.result | 2 +- 41 files changed, 286 insertions(+), 269 deletions(-) diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index 31bc12f2332..deb787f20fd 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -3260,10 +3260,10 @@ ORDER BY path; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 15 Using filesort 2 DERIVED t2 ALL NULL NULL NULL NULL 15 Using where -3 RECURSIVE UNION t2 ALL NULL NULL NULL NULL 15 Using where -3 RECURSIVE UNION ref key0 key0 5 test.t2.id 2 -4 RECURSIVE UNION t2 ALL NULL NULL NULL NULL 15 Using where -4 RECURSIVE UNION ref key0 key0 5 test.t2.id 2 +3 RECURSIVE UNION t2 ALL NULL NULL NULL NULL 15 +3 RECURSIVE UNION ALL NULL NULL NULL NULL 15 Using where; Using join buffer (flat, BNL join) +4 RECURSIVE UNION t2 ALL NULL NULL NULL NULL 15 +4 RECURSIVE UNION ALL NULL NULL NULL NULL 15 Using where; Using join buffer (flat, BNL join) NULL UNION RESULT ALL NULL NULL NULL NULL NULL DROP TABLE t1,t2; set tmp_memory_table_size=default; @@ -4467,8 +4467,8 @@ NULL UNION RESULT ALL NULL NULL NULL NULL NULL 3 DERIVED v ALL NULL NULL NULL NULL 12 Using where 3 DERIVED h ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 3 DERIVED w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (incremental, BNL join) -2 RECURSIVE UNION ALL NULL NULL NULL NULL 2 -2 RECURSIVE UNION h ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) +2 RECURSIVE UNION h ALL NULL NULL NULL NULL 12 +2 RECURSIVE UNION ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 2 RECURSIVE UNION w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (incremental, BNL join) NULL UNION RESULT ALL NULL NULL NULL NULL NULL prepare stmt from "with recursive @@ -4566,8 +4566,8 @@ id select_type table type possible_keys key key_len ref rows Extra 5 RECURSIVE UNION ALL NULL NULL NULL NULL 2 NULL UNION RESULT ALL NULL NULL NULL NULL NULL 2 DERIVED h ALL NULL NULL NULL NULL 12 -2 DERIVED w ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join) -2 DERIVED ALL NULL NULL NULL NULL 12 Using where; Using join buffer (incremental, BNL join) +2 DERIVED ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) +2 DERIVED w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (incremental, BNL join) prepare stmt from "with recursive ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, w_id, w_name, w_dob, w_father, w_mother) diff --git a/mysql-test/main/delete.result b/mysql-test/main/delete.result index ed3683d52f9..5bca2bd5ec2 100644 --- a/mysql-test/main/delete.result +++ b/mysql-test/main/delete.result @@ -205,13 +205,13 @@ insert into t3 values (1,1),(2,1),(1,3); select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; a b a b a b 1 1 1 1 1 1 -2 1 2 2 2 1 1 3 1 1 1 3 +2 1 2 2 2 1 explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 -1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b,test.t1.b 1 Using index +1 SIMPLE t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index; Using join buffer (flat, BNL join) +1 SIMPLE t3 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index; Using join buffer (incremental, BNL join) delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; select * from t3; a b diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index b86cd1c42cc..916fd71b92e 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -2044,16 +2044,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 2 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -1 SIMPLE t3 ref e e 3 test.t2.d 1 Using index 1 SIMPLE t4 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 index e e 7 NULL 8 Using where; Using index; Using join buffer (flat, BNL join) SELECT t2.d FROM t1,t2,v3 WHERE v3.e = t2.d AND v3.i < 3; d -w -w -w -w -w -w d d d @@ -2072,6 +2066,12 @@ e e e e +w +w +w +w +w +w SET SESSION join_cache_level = @exit_join_cache_level; SET SESSION join_buffer_size = @exit_join_buffer_size; DROP VIEW v3; @@ -2459,6 +2459,8 @@ SELECT * FROM t1; a 1 1 +1 +1 drop table t1,t2; set optimizer_switch=@save968720_optimizer_switch; # @@ -2595,8 +2597,8 @@ CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; EXPLAIN EXTENDED SELECT v1.c1, v1.c2 FROM v1, t2 WHERE v1.c1=t2.c1 AND v1.c2=t2.c2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY ref key0 key0 5 test.t2.c2 2 100.00 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY ALL NULL NULL NULL NULL 5 75.00 Using where; Using join buffer (flat, BNL join) 2 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00 Warnings: Note 1003 /* select#1 */ select `v1`.`c1` AS `c1`,`v1`.`c2` AS `c2` from `test`.`v1` join `test`.`t2` where `v1`.`c1` = `test`.`t2`.`c1` and `v1`.`c2` = `test`.`t2`.`c2` @@ -2608,8 +2610,8 @@ EXPLAIN EXTENDED SELECT t2.c1, t2.c2 FROM (SELECT c1 g, MAX(c2) m FROM t1 GROUP BY c1) t, t2 WHERE t.g=t2.c1 AND t.m=t2.c2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY ref key0 key0 5 test.t2.c2 2 100.00 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY ALL NULL NULL NULL NULL 5 75.00 Using where; Using join buffer (flat, BNL join) 2 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from (/* select#2 */ select `test`.`t1`.`c1` AS `g`,max(`test`.`t1`.`c2`) AS `m` from `test`.`t1` group by `test`.`t1`.`c1`) `t` join `test`.`t2` where `t`.`g` = `test`.`t2`.`c1` and `t`.`m` = `test`.`t2`.`c2` diff --git a/mysql-test/main/distinct.result b/mysql-test/main/distinct.result index cad56fdc92a..e02c5c2a7c7 100644 --- a/mysql-test/main/distinct.result +++ b/mysql-test/main/distinct.result @@ -173,9 +173,9 @@ INSERT INTO t2 values (1),(2),(3); INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2'); explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index a a 4 NULL 5 Using index; Using temporary -1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using temporary 1 SIMPLE t3 ref a a 5 test.t1.b 2 Using index +1 SIMPLE t2 index a a 4 NULL 5 Using where; Using index; Using join buffer (flat, BNL join) SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; a 1 @@ -523,7 +523,7 @@ EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2 WHERE t1_1.a = t1_2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1_1 ALL PRIMARY NULL NULL NULL 3 Using temporary -1 SIMPLE t1_2 eq_ref PRIMARY PRIMARY 4 test.t1_1.a 1 Using index; Distinct +1 SIMPLE t1_2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index; Using join buffer (flat, BNL join) EXPLAIN SELECT a FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index diff --git a/mysql-test/main/greedy_optimizer.result b/mysql-test/main/greedy_optimizer.result index 55812cb6ff9..5a5d24c973e 100644 --- a/mysql-test/main/greedy_optimizer.result +++ b/mysql-test/main/greedy_optimizer.result @@ -142,52 +142,52 @@ Variable_name Value Last_query_cost 1693.637037 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where -1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 set optimizer_prune_level=0; select @@optimizer_prune_level; @@optimizer_prune_level @@ -454,52 +454,52 @@ Variable_name Value Last_query_cost 1693.637037 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 -1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where -1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) -show status like 'Last_query_cost'; -Variable_name Value -Last_query_cost 844.037037 -explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where -1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 +explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where +1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) +show status like 'Last_query_cost'; +Variable_name Value +Last_query_cost 642.737037 set optimizer_search_depth=1; select @@optimizer_search_depth; @@optimizer_search_depth @@ -606,52 +606,52 @@ Variable_name Value Last_query_cost 1693.637037 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 -1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where -1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) -show status like 'Last_query_cost'; -Variable_name Value -Last_query_cost 844.037037 -explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where -1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 844.037037 +Last_query_cost 642.737037 +explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where +1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) +show status like 'Last_query_cost'; +Variable_name Value +Last_query_cost 642.737037 drop table t1,t2,t3,t4,t5,t6,t7; CREATE TABLE t1 (a int, b int, d int, i int); INSERT INTO t1 VALUES (1,1,1,1); diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index 994805303f2..7f1e40bd314 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -552,12 +552,12 @@ a b 3 1 explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL a NULL NULL NULL 4 Using temporary; Using filesort -1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +1 SIMPLE t2 ALL a NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL a NULL NULL NULL 4 Using temporary -1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary +1 SIMPLE t2 ALL a NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) drop table t1,t2; SET @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity,@@optimizer_switch=@save_optimizer_switch; create table t1 (a int, b int); diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result index 59d6ae98ff3..e621197692a 100644 --- a/mysql-test/main/join.result +++ b/mysql-test/main/join.result @@ -258,7 +258,7 @@ name varchar(255) default NULL, PRIMARY KEY (id) ) ENGINE=MyISAM; INSERT INTO t2 VALUES (1,'s1'),(2,'s2'),(3,'s3'),(4,'s4'),(5,'s5'); -select t1.*, t2.* from t1, t2 where t2.id=t1.t2_id limit 2; +select straight_join t1.*, t2.* from t2, t1 where t2.id=t1.t2_id limit 2; t1_id t2_id type cost_unit min_value max_value t3_id item_id id name 12 5 Percent Cost -1 0 -1 -1 5 s5 14 4 Percent Cost -1 0 -1 -1 4 s4 diff --git a/mysql-test/main/join.test b/mysql-test/main/join.test index 1668787d33e..88f30540589 100644 --- a/mysql-test/main/join.test +++ b/mysql-test/main/join.test @@ -253,7 +253,7 @@ CREATE TABLE t2 ( PRIMARY KEY (id) ) ENGINE=MyISAM; INSERT INTO t2 VALUES (1,'s1'),(2,'s2'),(3,'s3'),(4,'s4'),(5,'s5'); -select t1.*, t2.* from t1, t2 where t2.id=t1.t2_id limit 2; +select straight_join t1.*, t2.* from t2, t1 where t2.id=t1.t2_id limit 2; drop table t1,t2; # diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index 938167035a2..1e649c193b6 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -3071,11 +3071,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t7 ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using index 1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaidformatid 4 test.t1.metaid 1 Using index condition; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t4 eq_ref PRIMARY,t4_formatclassid,t4_formats_idx PRIMARY 4 test.t3.formatid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t9 index PRIMARY,t9_subgenreid,t9_metaid PRIMARY 8 NULL 2 Using where; Using index; Using join buffer (incremental, BNL join) 1 SIMPLE t10 eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaidformatid 4 test.t1.metaid 1 Using index condition; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t4 eq_ref PRIMARY,t4_formatclassid,t4_formats_idx PRIMARY 4 test.t3.formatid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t1.uniquekey, t1.xml AS affiliateXml, t8.name AS artistName, t8.artistid, t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, @@ -4507,8 +4507,8 @@ SET SESSION join_buffer_size = 256; EXPLAIN SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL idx NULL NULL NULL 15 Using where -1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t2.a 36 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t1 ALL NULL NULL NULL NULL 36 +1 SIMPLE t2 ALL idx NULL NULL NULL 15 Using where; Using join buffer (flat, BNL join) SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99; a c SET SESSION join_cache_level=@save_join_cache_level; diff --git a/mysql-test/main/join_nested.result b/mysql-test/main/join_nested.result index fdfc5a2e7f5..741c3e4038e 100644 --- a/mysql-test/main/join_nested.result +++ b/mysql-test/main/join_nested.result @@ -1064,7 +1064,7 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ref idx_a idx_a 5 const 2 100.00 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t1 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t1 ALL idx_b NULL NULL NULL 7 75.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result index 451accd7b1c..0a5560bc849 100644 --- a/mysql-test/main/join_nested_jcl6.result +++ b/mysql-test/main/join_nested_jcl6.result @@ -1073,7 +1073,7 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ref idx_a idx_a 5 const 2 100.00 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t1 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t1 ALL idx_b NULL NULL NULL 7 75.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) @@ -2120,9 +2120,9 @@ FROM t5 LEFT JOIN ON (t5.b=t8.b); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 2 -1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) +1 SIMPLE t8 ALL b_i NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using join buffer (incremental, BNL join) 1 SIMPLE t7 const PRIMARY PRIMARY 4 const 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t8 ALL b_i NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join) SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 LEFT JOIN (t6 LEFT JOIN t7 ON t7.a=1, t8) @@ -2137,9 +2137,9 @@ FROM t5 LEFT JOIN ON (t5.b=t8.b); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 2 -1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) +1 SIMPLE t8 ALL b_i NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using join buffer (incremental, BNL join) 1 SIMPLE t7 ref b_i b_i 5 const 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t8 ALL b_i NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join) SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 LEFT JOIN (t6 LEFT JOIN t7 ON t7.b=2, t8) diff --git a/mysql-test/main/limit_rows_examined.result b/mysql-test/main/limit_rows_examined.result index f0a22b8f3f2..abed46ff235 100644 --- a/mysql-test/main/limit_rows_examined.result +++ b/mysql-test/main/limit_rows_examined.result @@ -49,11 +49,10 @@ explain select * from t1i, t2i where c1 = c2 LIMIT ROWS EXAMINED 6; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1i index PRIMARY PRIMARY 2 NULL 4 Using index -1 SIMPLE t2i eq_ref PRIMARY PRIMARY 2 test.t1i.c1 1 Using index +1 SIMPLE t2i index PRIMARY PRIMARY 2 NULL 4 Using where; Using index; Using join buffer (flat, BNL join) select * from t1i, t2i where c1 = c2 LIMIT ROWS EXAMINED 6; c1 c2 bb bb -cc cc Warnings: Warning 1931 Query execution was interrupted. The query examined at least 7 rows, which exceeds LIMIT ROWS EXAMINED (6). The query result may be incomplete set @@join_cache_level=6; @@ -70,11 +69,10 @@ explain select * from t1i, t2i where c1 = c2 LIMIT ROWS EXAMINED 6; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1i index PRIMARY PRIMARY 2 NULL 4 Using index -1 SIMPLE t2i eq_ref PRIMARY PRIMARY 2 test.t1i.c1 1 Using index +1 SIMPLE t2i index PRIMARY PRIMARY 2 NULL 4 Using where; Using index; Using join buffer (flat, BNL join) select * from t1i, t2i where c1 = c2 LIMIT ROWS EXAMINED 6; c1 c2 bb bb -cc cc Warnings: Warning 1931 Query execution was interrupted. The query examined at least 7 rows, which exceeds LIMIT ROWS EXAMINED (6). The query result may be incomplete Mix LIMIT ROWS EXAMINED with LIMIT diff --git a/mysql-test/main/multi_update.result b/mysql-test/main/multi_update.result index 674dc79fe12..1af632a19c8 100644 --- a/mysql-test/main/multi_update.result +++ b/mysql-test/main/multi_update.result @@ -1092,8 +1092,8 @@ a b c a b c set optimizer_switch='firstmatch=off'; explain update t1, t2 set t2.c=1 where t1.a=t2.a and t1.b in (select b from t3 where t3.c< t2.c) order by t2.c, t1.c limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary; Using filesort -1 PRIMARY t1 ref a a 5 test.t2.a 1 +1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort +1 PRIMARY t1 ALL a NULL NULL NULL 10 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 10 Using where; Start temporary; End temporary update t1, t2 set t2.c=1 where t1.a=t2.a and t1.b in (select b from t3 where t3.c<=t2.c) order by t2.c, t1.c limit 5; select * from t2; diff --git a/mysql-test/main/myisam_explain_non_select_all.result b/mysql-test/main/myisam_explain_non_select_all.result index 2ff966fdfd3..1c2deb32224 100644 --- a/mysql-test/main/myisam_explain_non_select_all.result +++ b/mysql-test/main/myisam_explain_non_select_all.result @@ -932,15 +932,15 @@ Warning 1287 ' INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 -1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 3 Using where -1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 3 Using where +1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 -1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 3 75.00 Using where -1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 3 75.00 Using where +1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 13 @@ -949,8 +949,8 @@ FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 -1 SIMPLE t2 index PRIMARY PRIMARY 8 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join) -1 SIMPLE t3 index PRIMARY PRIMARY 8 NULL 3 75.00 Using where; Using index; Using join buffer (incremental, BNL join) +1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 Using index +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a2` = `test`.`t1`.`a1` and `test`.`t3`.`a3` = `test`.`t2`.`b2` and `test`.`t3`.`b3` = `test`.`t1`.`b1` # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution @@ -960,16 +960,16 @@ Warnings: Warning 1287 ' INTO FROM...' instead # Status of "equivalent" SELECT query execution: Variable_name Value -Handler_read_first 2 -Handler_read_key 13 -Handler_read_next 6 +Handler_read_key 19 +Handler_read_next 3 Handler_read_rnd_next 4 # Status of testing query execution: Variable_name Value Handler_delete 8 -Handler_read_key 13 +Handler_read_key 19 +Handler_read_next 3 Handler_read_rnd 5 -Handler_read_rnd_next 28 +Handler_read_rnd_next 4 DROP TABLE t1, t2, t3; #20 @@ -1507,7 +1507,7 @@ FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +1 SIMPLE t2 index NULL a 15 NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution @@ -1517,11 +1517,9 @@ Warnings: Warning 1287 ' INTO FROM...' instead # Status of "equivalent" SELECT query execution: Variable_name Value +Handler_read_first 1 Handler_read_key 8 -Handler_read_rnd_next 27 -Sort_priority_queue_sorts 1 -Sort_rows 1 -Sort_scan 1 +Handler_read_next 26 # Status of testing query execution: Variable_name Value Handler_delete 1 @@ -2024,7 +2022,7 @@ FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +1 SIMPLE t2 index NULL a 15 NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution @@ -2034,11 +2032,9 @@ Warnings: Warning 1287 ' INTO FROM...' instead # Status of "equivalent" SELECT query execution: Variable_name Value +Handler_read_first 1 Handler_read_key 8 -Handler_read_rnd_next 27 -Sort_priority_queue_sorts 1 -Sort_rows 1 -Sort_scan 1 +Handler_read_next 26 # Status of testing query execution: Variable_name Value Handler_read_key 8 diff --git a/mysql-test/main/null_key.result b/mysql-test/main/null_key.result index 6b9d59c636a..d59a1cd0a2e 100644 --- a/mysql-test/main/null_key.result +++ b/mysql-test/main/null_key.result @@ -160,12 +160,12 @@ a b 7 NULL explain select * from t1 where (a = 7 or a is null) and (b=7 or b is null); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null a,b a 5 const 5 Using where; Using index +1 SIMPLE t1 range a,b a 10 NULL 4 Using where; Using index select * from t1 where (a = 7 or a is null) and (b=7 or b is null); a b +NULL 7 7 NULL 7 7 -NULL 7 explain select * from t1 where (a = 7 or a is null) and (a = 7 or a is null); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref_or_null a a 5 const 5 Using where; Using index diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 33bf157ab3f..c859c1de513 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -135,14 +135,14 @@ select * from v1 { { "access_type": "scan", "resulting_rows": 1, - "cost": 2.204394531, + "cost": 2.404394531, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 1, - "cost": 2.204394531, + "cost": 2.404394531, "uses_join_buffering": false } } @@ -153,12 +153,13 @@ select * from v1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 2.404394531 + "cost_for_plan": 2.604394531 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 2.603394531 }, { "substitute_best_equal": { @@ -293,14 +294,14 @@ select * from (select * from t1 where t1.a=1)q { { "access_type": "scan", "resulting_rows": 1, - "cost": 2.204394531, + "cost": 2.404394531, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 1, - "cost": 2.204394531, + "cost": 2.404394531, "uses_join_buffering": false } } @@ -311,12 +312,13 @@ select * from (select * from t1 where t1.a=1)q { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 2.404394531 + "cost_for_plan": 2.604394531 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 2.603394531 }, { "substitute_best_equal": { @@ -456,7 +458,7 @@ select * from v2 { { "access_type": "scan", "resulting_rows": 1, - "cost": 2.204394531, + "cost": 2.404394531, "chosen": true, "use_tmp_table": true } @@ -464,7 +466,7 @@ select * from v2 { "chosen_access_method": { "type": "scan", "records": 1, - "cost": 2.204394531, + "cost": 2.404394531, "uses_join_buffering": false } } @@ -475,13 +477,14 @@ select * from v2 { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 2.404394531, + "cost_for_plan": 2.604394531, "cost_for_sorting": 1 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 3.603394531 }, { "substitute_best_equal": { @@ -536,14 +539,14 @@ select * from v2 { { "access_type": "scan", "resulting_rows": 2, - "cost": 2, + "cost": 2.4, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 2, - "cost": 2, + "cost": 2.4, "uses_join_buffering": false } } @@ -554,12 +557,13 @@ select * from v2 { "plan_prefix": [], "table": "", "rows_for_plan": 2, - "cost_for_plan": 2.4 + "cost_for_plan": 2.8 } ] }, { - "best_join_order": [""] + "best_join_order": [""], + "cost": 2.799 }, { "attaching_conditions_to_tables": { @@ -680,14 +684,14 @@ explain select * from v2 { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.021972656, + "cost": 4.021972656, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.021972656, + "cost": 4.021972656, "uses_join_buffering": false } } @@ -698,12 +702,13 @@ explain select * from v2 { "plan_prefix": [], "table": "t2", "rows_for_plan": 10, - "cost_for_plan": 4.021972656 + "cost_for_plan": 6.021972656 } ] }, { - "best_join_order": ["t2"] + "best_join_order": ["t2"], + "cost": 6.020972656 }, { "attaching_conditions_to_tables": { @@ -803,7 +808,7 @@ explain select * from v1 { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.021972656, + "cost": 4.021972656, "chosen": true, "use_tmp_table": true } @@ -811,7 +816,7 @@ explain select * from v1 { "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.021972656, + "cost": 4.021972656, "uses_join_buffering": false } } @@ -822,13 +827,14 @@ explain select * from v1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 10, - "cost_for_plan": 4.021972656, + "cost_for_plan": 6.021972656, "cost_for_sorting": 10 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 16.02097266 }, { "attaching_conditions_to_tables": { @@ -877,14 +883,14 @@ explain select * from v1 { { "access_type": "scan", "resulting_rows": 10, - "cost": 10, + "cost": 12, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10, - "cost": 10, + "cost": 12, "uses_join_buffering": false } } @@ -895,12 +901,13 @@ explain select * from v1 { "plan_prefix": [], "table": "", "rows_for_plan": 10, - "cost_for_plan": 12 + "cost_for_plan": 14 } ] }, { - "best_join_order": [""] + "best_join_order": [""], + "cost": 13.999 }, { "attaching_conditions_to_tables": { @@ -1056,14 +1063,14 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { { "access_type": "scan", "resulting_rows": 100, - "cost": 2.317382812, + "cost": 22.31738281, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 100, - "cost": 2.317382812, + "cost": 22.31738281, "uses_join_buffering": false } } @@ -1075,14 +1082,14 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { { "access_type": "scan", "resulting_rows": 100, - "cost": 2.317382812, + "cost": 22.31738281, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 100, - "cost": 2.317382812, + "cost": 22.31738281, "uses_join_buffering": false } } @@ -1093,7 +1100,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": [], "table": "t1", "rows_for_plan": 100, - "cost_for_plan": 22.31738281, + "cost_for_plan": 42.31738281, "rest_of_plan": [ { "plan_prefix": ["t1"], @@ -1107,22 +1114,23 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "index": "a", "used_range_estimates": false, "reason": "not available", - "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, - "cost": 200.0585794, + "cond_check_cost": 2.200585794, + "startup_cost": 0, + "cost": 220.0585794, "chosen": true }, { "access_type": "scan", "resulting_rows": 75, - "cost": 7.317382812, + "cost": 1522.317383, "chosen": false } ], "chosen_access_method": { "type": "ref", "records": 1, - "cost": 200.0585794, + "cost": 220.0585794, "uses_join_buffering": false } } @@ -1133,7 +1141,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": ["t1"], "table": "t2", "rows_for_plan": 100, - "cost_for_plan": 242.3759623 + "cost_for_plan": 282.3759623 } ] }, @@ -1141,7 +1149,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": [], "table": "t2", "rows_for_plan": 100, - "cost_for_plan": 22.31738281, + "cost_for_plan": 42.31738281, "rest_of_plan": [ { "plan_prefix": ["t2"], @@ -1155,22 +1163,23 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "index": "a", "used_range_estimates": false, "reason": "not available", - "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, - "cost": 200.0585794, + "cond_check_cost": 2.200585794, + "startup_cost": 0, + "cost": 220.0585794, "chosen": true }, { "access_type": "scan", "resulting_rows": 75, - "cost": 7.317382812, + "cost": 1522.317383, "chosen": false } ], "chosen_access_method": { "type": "ref", "records": 1, - "cost": 200.0585794, + "cost": 220.0585794, "uses_join_buffering": false } } @@ -1181,17 +1190,18 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": ["t2"], "table": "t1", "rows_for_plan": 100, - "cost_for_plan": 242.3759623, + "cost_for_plan": 282.3759623, "pruned_by_cost": true, - "current_cost": 242.3759623, - "best_cost": 242.3759623 + "current_cost": 282.3759623, + "best_cost": 282.3759623 } ] } ] }, { - "best_join_order": ["t1", "t2"] + "best_join_order": ["t1", "t2"], + "cost": 282.3749623 }, { "substitute_best_equal": { @@ -1372,7 +1382,8 @@ EXPLAIN SELECT DISTINCT a FROM t1 { ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 7.499 }, { "attaching_conditions_to_tables": { @@ -1546,7 +1557,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { { "access_type": "scan", "resulting_rows": 1, - "cost": 3.229052734, + "cost": 3.429052734, "chosen": true, "use_tmp_table": true } @@ -1554,7 +1565,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "chosen_access_method": { "type": "scan", "records": 1, - "cost": 3.229052734, + "cost": 3.429052734, "uses_join_buffering": false } } @@ -1565,13 +1576,14 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 3.429052734, + "cost_for_plan": 3.629052734, "cost_for_sorting": 1 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 4.628052734 }, { "substitute_best_equal": { @@ -1594,7 +1606,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "reconsidering_access_paths_for_index_ordering": { "clause": "GROUP BY", "fanout": 1, - "read_time": 3.230052734, + "read_time": 3.430052734, "table": "t1", "rows_estimation": 7, "possible_keys": [ @@ -1797,7 +1809,8 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 14.049 }, { "substitute_best_equal": { @@ -1992,7 +2005,8 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 14.049 }, { "substitute_best_equal": { @@ -2248,9 +2262,10 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "access_type": "ref", "index": "a_c", "used_range_estimates": true, - "rowid_filter_skipped": "worst/max seeks clipping", "rows": 180, - "cost": 180.2743776, + "cond_check_cost": 216.2743776, + "startup_cost": 0, + "cost": 216.2743776, "chosen": true }, { @@ -2258,7 +2273,9 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "index": "a_b", "used_range_estimates": true, "rows": 21, - "cost": 21.14242739, + "cond_check_cost": 25.34242739, + "startup_cost": 0, + "cost": 25.34242739, "chosen": true }, { @@ -2270,7 +2287,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "chosen_access_method": { "type": "ref", "records": 21, - "cost": 21.14242739, + "cost": 25.34242739, "uses_join_buffering": false } } @@ -2281,12 +2298,13 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 21, - "cost_for_plan": 25.34242739 + "cost_for_plan": 29.54242739 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 29.54142739 }, { "substitute_best_equal": { @@ -2309,7 +2327,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "reconsidering_access_paths_for_index_ordering": { "clause": "ORDER BY", "fanout": 1, - "read_time": 21.14342739, + "read_time": 25.34342739, "table": "t1", "rows_estimation": 21, "possible_keys": [ @@ -2525,14 +2543,14 @@ select t1.a from t1 left join t2 on t1.a=t2.a { { "access_type": "scan", "resulting_rows": 4, - "cost": 2.006835938, + "cost": 2.806835937, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.006835938, + "cost": 2.806835937, "uses_join_buffering": false } } @@ -2543,12 +2561,13 @@ select t1.a from t1 left join t2 on t1.a=t2.a { "plan_prefix": ["t2"], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.806835937 + "cost_for_plan": 3.606835937 } ] }, { - "best_join_order": ["t2", "t1"] + "best_join_order": ["t2", "t1"], + "cost": 3.605835937 }, { "substitute_best_equal": { @@ -2672,14 +2691,14 @@ explain select * from t1 left join t2 on t2.a=t1.a { { "access_type": "scan", "resulting_rows": 4, - "cost": 2.006835938, + "cost": 2.806835937, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.006835938, + "cost": 2.806835937, "uses_join_buffering": false } } @@ -2690,7 +2709,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { "plan_prefix": [], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.806835937, + "cost_for_plan": 3.606835937, "rest_of_plan": [ { "plan_prefix": ["t1"], @@ -2703,20 +2722,22 @@ explain select * from t1 left join t2 on t2.a=t1.a { "access_type": "eq_ref", "index": "PRIMARY", "rows": 1, - "cost": 4, + "cond_check_cost": 1.2, + "startup_cost": 0, + "cost": 4.8, "chosen": true }, { "access_type": "scan", "resulting_rows": 1.5, - "cost": 8.417578125, + "cost": 10.81757812, "chosen": false } ], "chosen_access_method": { "type": "eq_ref", "records": 1, - "cost": 4, + "cost": 4.8, "uses_join_buffering": false } } @@ -2727,14 +2748,15 @@ explain select * from t1 left join t2 on t2.a=t1.a { "plan_prefix": ["t1"], "table": "t2", "rows_for_plan": 4, - "cost_for_plan": 7.606835937 + "cost_for_plan": 9.206835937 } ] } ] }, { - "best_join_order": ["t1", "t2"] + "best_join_order": ["t1", "t2"], + "cost": 9.205835937 }, { "substitute_best_equal": { @@ -2900,14 +2922,14 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and { "access_type": "scan", "resulting_rows": 4, - "cost": 2.006835938, + "cost": 2.806835937, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.006835938, + "cost": 2.806835937, "uses_join_buffering": false } } @@ -2918,12 +2940,13 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and "plan_prefix": ["t3", "t2"], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.806835937 + "cost_for_plan": 3.606835937 } ] }, { - "best_join_order": ["t3", "t2", "t1"] + "best_join_order": ["t3", "t2", "t1"], + "cost": 3.605835937 }, { "substitute_best_equal": { @@ -3115,14 +3138,14 @@ explain extended select * from t1 where a in (select pk from t10) { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.021972656, + "cost": 4.021972656, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.021972656, + "cost": 4.021972656, "uses_join_buffering": false } } @@ -3133,7 +3156,7 @@ explain extended select * from t1 where a in (select pk from t10) { "plan_prefix": [], "table": "t10", "rows_for_plan": 10, - "cost_for_plan": 4.021972656 + "cost_for_plan": 6.021972656 } ] } @@ -3152,14 +3175,14 @@ explain extended select * from t1 where a in (select pk from t10) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.006591797, + "cost": 2.606591797, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.006591797, + "cost": 2.606591797, "uses_join_buffering": false } } @@ -3171,14 +3194,14 @@ explain extended select * from t1 where a in (select pk from t10) { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.021972656, + "cost": 4.021972656, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.021972656, + "cost": 4.021972656, "uses_join_buffering": false } } @@ -3189,7 +3212,7 @@ explain extended select * from t1 where a in (select pk from t10) { "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 2.606591797, + "cost_for_plan": 3.206591797, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -3202,14 +3225,14 @@ explain extended select * from t1 where a in (select pk from t10) { { "access_type": "scan", "resulting_rows": 10, - "cost": 2.021972656, + "cost": 10.02197266, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10, - "cost": 2.021972656, + "cost": 10.02197266, "uses_join_buffering": true } } @@ -3220,22 +3243,22 @@ explain extended select * from t1 where a in (select pk from t10) { "plan_prefix": ["t1"], "table": "t10", "rows_for_plan": 30, - "cost_for_plan": 10.62856445, + "cost_for_plan": 19.22856445, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 3, - "read_time": 10.62856445 + "read_time": 19.22856445 }, { "strategy": "SJ-Materialization", "records": 3, - "read_time": 5.278564453 + "read_time": 7.878564453 }, { "strategy": "DuplicateWeedout", "records": 3, - "read_time": 27.12856445 + "read_time": 35.72856445 }, { "chosen_strategy": "SJ-Materialization" @@ -3248,7 +3271,7 @@ explain extended select * from t1 where a in (select pk from t10) { "plan_prefix": [], "table": "t10", "rows_for_plan": 10, - "cost_for_plan": 4.021972656, + "cost_for_plan": 6.021972656, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -3267,7 +3290,8 @@ explain extended select * from t1 where a in (select pk from t10) { ] }, { - "best_join_order": ["t1", ""] + "best_join_order": ["t1", ""], + "cost": 7.877564453 }, { "substitute_best_equal": { @@ -3602,7 +3626,9 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk", "used_range_estimates": true, "rows": 1, - "cost": 1.125585794, + "cond_check_cost": 1.325585794, + "startup_cost": 0, + "cost": 1.325585794, "chosen": true }, { @@ -3610,7 +3636,9 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk_a", "used_range_estimates": true, "rows": 1, - "cost": 1.125829876, + "cond_check_cost": 1.325829876, + "startup_cost": 0, + "cost": 1.325829876, "chosen": false, "cause": "cost" }, @@ -3619,7 +3647,9 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk_a_b", "used_range_estimates": true, "rows": 1, - "cost": 0.126073957, + "cond_check_cost": 0.326073957, + "startup_cost": 0, + "cost": 0.326073957, "chosen": true }, { @@ -3631,7 +3661,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "chosen_access_method": { "type": "ref", "records": 1, - "cost": 0.126073957, + "cost": 0.326073957, "uses_join_buffering": false } } @@ -3642,12 +3672,13 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 0.326073957 + "cost_for_plan": 0.526073957 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 0.525073957 }, { "substitute_best_equal": { @@ -3760,14 +3791,14 @@ select f1(a) from t1 { { "access_type": "scan", "resulting_rows": 4, - "cost": 2.006835938, + "cost": 2.806835937, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.006835938, + "cost": 2.806835937, "uses_join_buffering": false } } @@ -3778,12 +3809,13 @@ select f1(a) from t1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.806835937 + "cost_for_plan": 3.606835937 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 3.605835937 }, { "attaching_conditions_to_tables": { @@ -3864,14 +3896,14 @@ select f2(a) from t1 { { "access_type": "scan", "resulting_rows": 4, - "cost": 2.006835938, + "cost": 2.806835937, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 4, - "cost": 2.006835938, + "cost": 2.806835937, "uses_join_buffering": false } } @@ -3882,12 +3914,13 @@ select f2(a) from t1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.806835937 + "cost_for_plan": 3.606835937 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 3.605835937 }, { "attaching_conditions_to_tables": { @@ -3928,7 +3961,7 @@ a 2 select length(trace) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; length(trace) -2360 +2393 set optimizer_trace_max_mem_size=100; select * from t1; a @@ -3942,7 +3975,7 @@ select * from t1 { "join_preparation": { "select_id": 1, "steps": [ - 2260 0 + 2293 0 set optimizer_trace_max_mem_size=0; select * from t1; a @@ -3950,7 +3983,7 @@ a 2 select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES -select * from t1 2360 0 +select * from t1 2393 0 drop table t1; set optimizer_trace='enabled=off'; set @@optimizer_trace_max_mem_size= @save_optimizer_trace_max_mem_size; @@ -4305,9 +4338,10 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "index": "a", "used_range_estimates": false, "reason": "not better than ref estimates", - "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, - "cost": 3.001757383, + "cond_check_cost": 1.200585794, + "startup_cost": 0, + "cost": 3.601757383, "chosen": true }, { @@ -4319,7 +4353,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "chosen_access_method": { "type": "ref", "records": 1, - "cost": 3.001757383, + "cost": 3.601757383, "uses_join_buffering": false } } @@ -4330,7 +4364,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "plan_prefix": ["t0"], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 4.948514767 + "cost_for_plan": 5.548514767 } ] }, @@ -4353,9 +4387,10 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "rec_per_key_stats_missing": true, "used_range_estimates": false, "reason": "not better than ref estimates", - "rowid_filter_skipped": "worst/max seeks clipping", "rows": 2, - "cost": 3.003514767, + "cond_check_cost": 1.401171589, + "startup_cost": 0, + "cost": 4.203514767, "chosen": true }, { @@ -4367,7 +4402,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "chosen_access_method": { "type": "ref", "records": 2, - "cost": 3.003514767, + "cost": 4.203514767, "uses_join_buffering": false } } @@ -4378,17 +4413,18 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "plan_prefix": ["t1"], "table": "t0", "rows_for_plan": 6, - "cost_for_plan": 5.55027215, + "cost_for_plan": 6.75027215, "pruned_by_cost": true, - "current_cost": 5.55027215, - "best_cost": 4.948514767 + "current_cost": 6.75027215, + "best_cost": 5.548514767 } ] } ] }, { - "best_join_order": ["t0", "t1"] + "best_join_order": ["t0", "t1"], + "cost": 5.547514767 }, { "substitute_best_equal": { @@ -4514,14 +4550,14 @@ explain select * from (select rand() from t1)q { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -4532,12 +4568,13 @@ explain select * from (select rand() from t1)q { "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953 + "cost_for_plan": 3.205126953 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 3.204126953 }, { "attaching_conditions_to_tables": { @@ -4586,14 +4623,14 @@ explain select * from (select rand() from t1)q { { "access_type": "scan", "resulting_rows": 3, - "cost": 3, + "cost": 3.6, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 3, + "cost": 3.6, "uses_join_buffering": false } } @@ -4604,12 +4641,13 @@ explain select * from (select rand() from t1)q { "plan_prefix": [], "table": "", "rows_for_plan": 3, - "cost_for_plan": 3.6 + "cost_for_plan": 4.2 } ] }, { - "best_join_order": [""] + "best_join_order": [""], + "cost": 4.199 }, { "attaching_conditions_to_tables": { @@ -4800,14 +4838,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -4819,14 +4857,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -4837,7 +4875,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "rest_of_plan": [ { "plan_prefix": ["t_inner_1"], @@ -4849,14 +4887,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 4.405126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 4.405126953, "uses_join_buffering": true } } @@ -4867,7 +4905,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": ["t_inner_1"], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 6.410253906 + "cost_for_plan": 9.410253906 } ] }, @@ -4875,7 +4913,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "pruned_by_heuristic": true } ] @@ -4895,14 +4933,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -4914,14 +4952,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -4933,14 +4971,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -4951,7 +4989,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -4964,14 +5002,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 4.405126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 4.405126953, "uses_join_buffering": true } } @@ -4983,14 +5021,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 4.405126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 4.405126953, "uses_join_buffering": true } } @@ -5001,7 +5039,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": ["t1"], "table": "t_inner_1", "rows_for_plan": 9, - "cost_for_plan": 6.410253906, + "cost_for_plan": 9.410253906, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5014,14 +5052,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 8.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 8.005126953, "uses_join_buffering": true } } @@ -5032,22 +5070,22 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": ["t1", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 27, - "cost_for_plan": 13.81538086, + "cost_for_plan": 22.81538086, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 3, - "read_time": 33.86665039 + "read_time": 48.86665039 }, { "strategy": "SJ-Materialization", "records": 3, - "read_time": 7.215380859 + "read_time": 10.81538086 }, { "strategy": "DuplicateWeedout", "records": 3, - "read_time": 18.31538086 + "read_time": 27.31538086 }, { "chosen_strategy": "SJ-Materialization" @@ -5060,7 +5098,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": ["t1"], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 6.410253906, + "cost_for_plan": 9.410253906, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -5070,7 +5108,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -5078,7 +5116,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -5100,7 +5138,8 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ] }, { - "best_join_order": ["t1", ""] + "best_join_order": ["t1", ""], + "cost": 10.81438086 }, { "substitute_best_equal": { @@ -5382,14 +5421,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -5401,14 +5440,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -5420,14 +5459,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 3.815380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 3.815380859, "uses_join_buffering": false } } @@ -5439,14 +5478,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 3.815380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 3.815380859, "uses_join_buffering": false } } @@ -5458,14 +5497,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -5477,14 +5516,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 3.815380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 3.815380859, "uses_join_buffering": false } } @@ -5495,7 +5534,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_outer_1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5508,14 +5547,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 4.405126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 4.405126953, "uses_join_buffering": true } } @@ -5527,14 +5566,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -5546,14 +5585,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -5565,14 +5604,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 4.405126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 4.405126953, "uses_join_buffering": true } } @@ -5584,14 +5623,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -5602,7 +5641,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_outer_2", "rows_for_plan": 27, - "cost_for_plan": 10.02050781, + "cost_for_plan": 17.82050781, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5615,14 +5654,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -5634,14 +5673,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 18.80512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 18.80512695, "uses_join_buffering": true } } @@ -5653,14 +5692,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 18.80512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 18.80512695, "uses_join_buffering": true } } @@ -5672,14 +5711,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -5690,7 +5729,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_1", "rows_for_plan": 81, - "cost_for_plan": 28.22563477, + "cost_for_plan": 52.82563477, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5703,14 +5742,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -5722,14 +5761,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 51.20512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 51.20512695, "uses_join_buffering": true } } @@ -5741,14 +5780,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -5759,17 +5798,17 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 729, - "cost_for_plan": 176.0410156, + "cost_for_plan": 348.2410156, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 27, - "read_time": 389.4047852 + "read_time": 721.2047852 }, { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 289.4410156 + "read_time": 461.6410156 }, { "chosen_strategy": "DuplicateWeedout" @@ -5791,14 +5830,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 18.80512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 18.80512695, "uses_join_buffering": true } } @@ -5810,14 +5849,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -5833,7 +5872,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 307.6461426, + "cost_for_plan": 496.6461426, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5852,14 +5891,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -5876,17 +5915,17 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 455.4615234, + "cost_for_plan": 792.0615234, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 27, - "read_time": 668.825293 + "read_time": 1165.025293 }, { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 568.8615234 + "read_time": 905.4615234 }, { "chosen_strategy": "DuplicateWeedout" @@ -5904,7 +5943,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 340.0563965, + "cost_for_plan": 562.6563965, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -5914,7 +5953,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_4", "rows_for_plan": 243, - "cost_for_plan": 78.83076172, + "cost_for_plan": 152.6307617, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5932,14 +5971,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 441.2153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 441.2153809, "uses_join_buffering": true } } @@ -5951,14 +5990,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 441.2153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 441.2153809, "uses_join_buffering": true } } @@ -5974,70 +6013,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_2", "rows_for_plan": 2187, - "cost_for_plan": 518.2461426, + "cost_for_plan": 1031.246143, "semijoin_strategy_choice": [], - "rest_of_plan": [ - { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_4", - "t_inner_2" - ], - "get_costs_for_tables": [ - { - "best_access_path": { - "table": "t_inner_3", - "considered_access_paths": [ - { - "access_type": "scan", - "resulting_rows": 9, - "cost": 2.015380859, - "chosen": true - } - ], - "chosen_access_method": { - "type": "scan", - "records": 9, - "cost": 2.015380859, - "uses_join_buffering": true - } - } - } - ] - }, - { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_4", - "t_inner_2" - ], - "table": "t_inner_3", - "rows_for_plan": 19683, - "cost_for_plan": 4456.861523, - "semijoin_strategy_choice": [ - { - "strategy": "FirstMatch", - "records": 27, - "read_time": 9562.749707 - }, - { - "strategy": "DuplicateWeedout", - "records": 27, - "read_time": 7413.361523 - }, - { - "chosen_strategy": "FirstMatch" - } - ], - "pruned_by_cost": true, - "current_cost": 9562.749707, - "best_cost": 568.8615234 - } - ] + "pruned_by_cost": true, + "current_cost": 1031.246143, + "best_cost": 905.4615234 }, { "plan_prefix": [ @@ -6048,9 +6028,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 2187, - "cost_for_plan": 518.2461426, + "cost_for_plan": 1031.246143, "semijoin_strategy_choice": [], - "pruned_by_heuristic": true + "pruned_by_cost": true, + "current_cost": 1031.246143, + "best_cost": 905.4615234 } ] }, @@ -6058,7 +6040,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 176.0410156, + "cost_for_plan": 348.2410156, "semijoin_strategy_choice": [], "pruned_by_heuristic": "min_read_time" } @@ -6068,7 +6050,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_2", "rows_for_plan": 243, - "cost_for_plan": 60.63588867, + "cost_for_plan": 118.8358887, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6076,7 +6058,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 28.22563477, + "cost_for_plan": 52.82563477, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6084,7 +6066,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 60.63588867, + "cost_for_plan": 118.8358887, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6094,7 +6076,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_1", "rows_for_plan": 9, - "cost_for_plan": 6.410253906, + "cost_for_plan": 9.410253906, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6107,14 +6089,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -6126,14 +6108,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -6145,14 +6127,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 8.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 8.005126953, "uses_join_buffering": true } } @@ -6164,14 +6146,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -6182,7 +6164,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_outer_2", "rows_for_plan": 81, - "cost_for_plan": 24.62563477, + "cost_for_plan": 45.62563477, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6195,14 +6177,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -6214,14 +6196,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 51.20512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 51.20512695, "uses_join_buffering": true } } @@ -6233,14 +6215,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -6251,12 +6233,12 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], "table": "t_inner_2", "rows_for_plan": 729, - "cost_for_plan": 172.4410156, + "cost_for_plan": 341.0410156, "semijoin_strategy_choice": [ { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 285.8410156 + "read_time": 454.4410156 }, { "chosen_strategy": "DuplicateWeedout" @@ -6278,14 +6260,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 18.80512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 18.80512695, "uses_join_buffering": true } } @@ -6297,14 +6279,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -6320,7 +6302,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 304.0461426, + "cost_for_plan": 489.4461426, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6339,14 +6321,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -6363,17 +6345,17 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 451.8615234, + "cost_for_plan": 784.8615234, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 27, - "read_time": 665.225293 + "read_time": 1157.825293 }, { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 565.2615234 + "read_time": 898.2615234 }, { "chosen_strategy": "DuplicateWeedout" @@ -6391,7 +6373,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 336.4563965, + "cost_for_plan": 555.4563965, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6401,7 +6383,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], "table": "t_inner_4", "rows_for_plan": 243, - "cost_for_plan": 75.23076172, + "cost_for_plan": 145.4307617, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6419,14 +6401,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 441.2153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 441.2153809, "uses_join_buffering": true } } @@ -6438,14 +6420,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 441.2153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 441.2153809, "uses_join_buffering": true } } @@ -6461,65 +6443,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_2", "rows_for_plan": 2187, - "cost_for_plan": 514.6461426, + "cost_for_plan": 1024.046143, "semijoin_strategy_choice": [], - "rest_of_plan": [ - { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4", - "t_inner_2" - ], - "get_costs_for_tables": [ - { - "best_access_path": { - "table": "t_inner_3", - "considered_access_paths": [ - { - "access_type": "scan", - "resulting_rows": 9, - "cost": 2.015380859, - "chosen": true - } - ], - "chosen_access_method": { - "type": "scan", - "records": 9, - "cost": 2.015380859, - "uses_join_buffering": true - } - } - } - ] - }, - { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4", - "t_inner_2" - ], - "table": "t_inner_3", - "rows_for_plan": 19683, - "cost_for_plan": 4453.261523, - "semijoin_strategy_choice": [ - { - "strategy": "DuplicateWeedout", - "records": 27, - "read_time": 7409.761523 - }, - { - "chosen_strategy": "DuplicateWeedout" - } - ], - "pruned_by_cost": true, - "current_cost": 7409.761523, - "best_cost": 565.2615234 - } - ] + "pruned_by_cost": true, + "current_cost": 1024.046143, + "best_cost": 898.2615234 }, { "plan_prefix": [ @@ -6530,9 +6458,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 2187, - "cost_for_plan": 514.6461426, + "cost_for_plan": 1024.046143, "semijoin_strategy_choice": [], - "pruned_by_heuristic": true + "pruned_by_cost": true, + "current_cost": 1024.046143, + "best_cost": 898.2615234 } ] }, @@ -6540,7 +6470,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 172.4410156, + "cost_for_plan": 341.0410156, "semijoin_strategy_choice": [], "pruned_by_heuristic": "min_read_time" } @@ -6550,17 +6480,17 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 81, - "cost_for_plan": 24.62563477, + "cost_for_plan": 45.62563477, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 3, - "read_time": 44.75893555 + "read_time": 81.35893555 }, { "strategy": "DuplicateWeedout", "records": 3, - "read_time": 37.22563477 + "read_time": 58.22563477 }, { "chosen_strategy": "DuplicateWeedout" @@ -6577,14 +6507,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -6596,14 +6526,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 4.405126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 4.405126953, "uses_join_buffering": true } } @@ -6615,14 +6545,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -6633,7 +6563,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_outer_2", "rows_for_plan": 27, - "cost_for_plan": 44.64101563, + "cost_for_plan": 72.84101562, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6651,14 +6581,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 18.80512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 18.80512695, "uses_join_buffering": true } } @@ -6670,14 +6600,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -6693,7 +6623,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 62.84614258, + "cost_for_plan": 107.8461426, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6712,14 +6642,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -6736,17 +6666,17 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 210.6615234, + "cost_for_plan": 403.2615234, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 27, - "read_time": 424.025293 + "read_time": 776.225293 }, { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 324.0615234 + "read_time": 516.6615234 }, { "chosen_strategy": "DuplicateWeedout" @@ -6764,7 +6694,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 95.25639648, + "cost_for_plan": 173.8563965, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6774,7 +6704,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_inner_4", "rows_for_plan": 9, - "cost_for_plan": 41.03076172, + "cost_for_plan": 64.43076172, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6792,14 +6722,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -6811,14 +6741,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -6834,7 +6764,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_outer_2", "rows_for_plan": 81, - "cost_for_plan": 59.24614258, + "cost_for_plan": 100.6461426, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6853,14 +6783,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -6877,12 +6807,12 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 207.0615234, + "cost_for_plan": 396.0615234, "semijoin_strategy_choice": [ { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 320.4615234 + "read_time": 509.4615234 }, { "chosen_strategy": "DuplicateWeedout" @@ -6900,7 +6830,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 81, - "cost_for_plan": 59.24614258, + "cost_for_plan": 100.6461426, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6910,7 +6840,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 44.64101563, + "cost_for_plan": 72.84101562, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6920,7 +6850,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_4", "rows_for_plan": 27, - "cost_for_plan": 13.81538086, + "cost_for_plan": 22.81538086, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6933,14 +6863,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -6952,14 +6882,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -6971,14 +6901,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -6989,7 +6919,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], "table": "t_outer_2", "rows_for_plan": 243, - "cost_for_plan": 64.43076172, + "cost_for_plan": 123.8307617, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7007,14 +6937,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 441.2153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 441.2153809, "uses_join_buffering": true } } @@ -7026,14 +6956,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 441.2153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 441.2153809, "uses_join_buffering": true } } @@ -7049,11 +6979,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_2", "rows_for_plan": 2187, - "cost_for_plan": 503.8461426, + "cost_for_plan": 1002.446143, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 503.8461426, - "best_cost": 320.4615234 + "current_cost": 1002.446143, + "best_cost": 509.4615234 }, { "plan_prefix": [ @@ -7064,11 +6994,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 2187, - "cost_for_plan": 503.8461426, + "cost_for_plan": 1002.446143, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 503.8461426, - "best_cost": 320.4615234 + "current_cost": 1002.446143, + "best_cost": 509.4615234 } ] }, @@ -7076,7 +7006,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], "table": "t_inner_2", "rows_for_plan": 243, - "cost_for_plan": 64.43076172, + "cost_for_plan": 123.8307617, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7084,7 +7014,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 64.43076172, + "cost_for_plan": 123.8307617, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7094,7 +7024,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_3", "rows_for_plan": 81, - "cost_for_plan": 24.62563477, + "cost_for_plan": 45.62563477, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7104,7 +7034,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_2", "rows_for_plan": 27, - "cost_for_plan": 10.02050781, + "cost_for_plan": 17.82050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7112,7 +7042,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_4", "rows_for_plan": 9, - "cost_for_plan": 6.410253906, + "cost_for_plan": 9.410253906, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7120,7 +7050,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 10.02050781, + "cost_for_plan": 17.82050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7130,7 +7060,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_outer_2", "rows_for_plan": 9, - "cost_for_plan": 3.815380859, + "cost_for_plan": 5.615380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7138,7 +7068,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7146,7 +7076,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 3.815380859, + "cost_for_plan": 5.615380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7154,7 +7084,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_4", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7162,7 +7092,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_3", "rows_for_plan": 9, - "cost_for_plan": 3.815380859, + "cost_for_plan": 5.615380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7186,7 +7116,8 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "t_inner_4", "t_outer_2", "t_inner_3" - ] + ], + "cost": 509.4605234 }, { "substitute_best_equal": { @@ -7471,14 +7402,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -7490,14 +7421,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 3.815380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 3.815380859, "uses_join_buffering": false } } @@ -7508,7 +7439,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "rest_of_plan": [ { "plan_prefix": ["t_inner_1"], @@ -7520,14 +7451,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -7538,7 +7469,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_inner_1"], "table": "t_inner_2", "rows_for_plan": 27, - "cost_for_plan": 10.02050781 + "cost_for_plan": 17.82050781 } ] }, @@ -7546,7 +7477,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 3.815380859, + "cost_for_plan": 5.615380859, "pruned_by_heuristic": true } ] @@ -7563,14 +7494,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -7582,14 +7513,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 3.815380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 3.815380859, "uses_join_buffering": false } } @@ -7600,7 +7531,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_4", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "rest_of_plan": [ { "plan_prefix": ["t_inner_4"], @@ -7612,14 +7543,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -7630,7 +7561,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_inner_4"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 10.02050781 + "cost_for_plan": 17.82050781 } ] }, @@ -7638,7 +7569,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_3", "rows_for_plan": 9, - "cost_for_plan": 3.815380859, + "cost_for_plan": 5.615380859, "pruned_by_heuristic": true } ] @@ -7658,14 +7589,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -7677,14 +7608,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -7696,14 +7627,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 3.815380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 3.815380859, "uses_join_buffering": false } } @@ -7715,14 +7646,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 3.815380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 3.815380859, "uses_join_buffering": false } } @@ -7734,14 +7665,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -7753,14 +7684,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 3.815380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 3.815380859, "uses_join_buffering": false } } @@ -7771,7 +7702,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_outer_1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7784,14 +7715,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 4.405126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 4.405126953, "uses_join_buffering": true } } @@ -7803,14 +7734,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -7822,14 +7753,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -7841,14 +7772,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 4.405126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 4.405126953, "uses_join_buffering": true } } @@ -7860,14 +7791,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -7878,7 +7809,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_outer_2", "rows_for_plan": 27, - "cost_for_plan": 10.02050781, + "cost_for_plan": 17.82050781, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7891,14 +7822,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -7910,14 +7841,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 18.80512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 18.80512695, "uses_join_buffering": true } } @@ -7929,14 +7860,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 18.80512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 18.80512695, "uses_join_buffering": true } } @@ -7948,14 +7879,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -7966,7 +7897,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_1", "rows_for_plan": 81, - "cost_for_plan": 28.22563477, + "cost_for_plan": 52.82563477, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7979,14 +7910,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -7998,14 +7929,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 51.20512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 51.20512695, "uses_join_buffering": true } } @@ -8017,14 +7948,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -8035,22 +7966,22 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 729, - "cost_for_plan": 176.0410156, + "cost_for_plan": 348.2410156, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 27, - "read_time": 389.4047852 + "read_time": 721.2047852 }, { "strategy": "SJ-Materialization", "records": 27, - "read_time": 16.74101562 + "read_time": 32.34101562 }, { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 289.4410156 + "read_time": 461.6410156 }, { "chosen_strategy": "SJ-Materialization" @@ -8072,14 +8003,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 18.80512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 18.80512695, "uses_join_buffering": true } } @@ -8091,14 +8022,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -8114,7 +8045,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 34.94614258, + "cost_for_plan": 67.34614258, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -8133,14 +8064,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 149.6153809, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 149.6153809, "uses_join_buffering": true } } @@ -8157,22 +8088,22 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 182.7615234, + "cost_for_plan": 362.7615234, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 27, - "read_time": 396.125293 + "read_time": 735.725293 }, { "strategy": "SJ-Materialization", "records": 27, - "read_time": 23.46152344 + "read_time": 46.86152344 }, { "strategy": "DuplicateWeedout", "records": 27, - "read_time": 296.1615234 + "read_time": 476.1615234 }, { "chosen_strategy": "SJ-Materialization" @@ -8190,11 +8121,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 67.35639648, + "cost_for_plan": 133.3563965, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 67.35639648, - "best_cost": 23.46152344 + "current_cost": 133.3563965, + "best_cost": 46.86152344 } ] }, @@ -8202,21 +8133,21 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_4", "rows_for_plan": 243, - "cost_for_plan": 78.83076172, + "cost_for_plan": 152.6307617, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 78.83076172, - "best_cost": 23.46152344 + "current_cost": 152.6307617, + "best_cost": 46.86152344 }, { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 176.0410156, + "cost_for_plan": 348.2410156, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 176.0410156, - "best_cost": 23.46152344 + "current_cost": 348.2410156, + "best_cost": 46.86152344 } ] }, @@ -8224,31 +8155,31 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_2", "rows_for_plan": 243, - "cost_for_plan": 60.63588867, + "cost_for_plan": 118.8358887, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 60.63588867, - "best_cost": 23.46152344 + "current_cost": 118.8358887, + "best_cost": 46.86152344 }, { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 28.22563477, + "cost_for_plan": 52.82563477, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 28.22563477, - "best_cost": 23.46152344 + "current_cost": 52.82563477, + "best_cost": 46.86152344 }, { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 60.63588867, + "cost_for_plan": 118.8358887, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 60.63588867, - "best_cost": 23.46152344 + "current_cost": 118.8358887, + "best_cost": 46.86152344 } ] }, @@ -8256,7 +8187,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_1", "rows_for_plan": 9, - "cost_for_plan": 6.410253906, + "cost_for_plan": 9.410253906, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -8269,14 +8200,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -8288,14 +8219,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -8307,14 +8238,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 8.005126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 8.005126953, "uses_join_buffering": true } } @@ -8326,14 +8257,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -8344,32 +8275,132 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_outer_2", "rows_for_plan": 81, - "cost_for_plan": 24.62563477, + "cost_for_plan": 45.62563477, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 24.62563477, - "best_cost": 23.46152344 + "rest_of_plan": [ + { + "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "t_inner_2", + "considered_access_paths": [ + { + "access_type": "scan", + "resulting_rows": 9, + "cost": 149.6153809, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "records": 9, + "cost": 149.6153809, + "uses_join_buffering": true + } + } + }, + { + "best_access_path": { + "table": "t_inner_4", + "considered_access_paths": [ + { + "access_type": "scan", + "resulting_rows": 3, + "cost": 51.20512695, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "records": 3, + "cost": 51.20512695, + "uses_join_buffering": true + } + } + }, + { + "best_access_path": { + "table": "t_inner_3", + "considered_access_paths": [ + { + "access_type": "scan", + "resulting_rows": 9, + "cost": 149.6153809, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "records": 9, + "cost": 149.6153809, + "uses_join_buffering": true + } + } + } + ] + }, + { + "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "table": "t_inner_2", + "rows_for_plan": 729, + "cost_for_plan": 341.0410156, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicateWeedout", + "records": 27, + "read_time": 454.4410156 + }, + { + "chosen_strategy": "DuplicateWeedout" + } + ], + "pruned_by_cost": true, + "current_cost": 454.4410156, + "best_cost": 46.86152344 + }, + { + "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "table": "t_inner_4", + "rows_for_plan": 243, + "cost_for_plan": 145.4307617, + "semijoin_strategy_choice": [], + "pruned_by_cost": true, + "current_cost": 145.4307617, + "best_cost": 46.86152344 + }, + { + "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "table": "t_inner_3", + "rows_for_plan": 729, + "cost_for_plan": 341.0410156, + "semijoin_strategy_choice": [], + "pruned_by_cost": true, + "current_cost": 341.0410156, + "best_cost": 46.86152344 + } + ] }, { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 81, - "cost_for_plan": 24.62563477, + "cost_for_plan": 45.62563477, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", "records": 3, - "read_time": 44.75893555 + "read_time": 81.35893555 }, { "strategy": "SJ-Materialization", "records": 3, - "read_time": 8.125634766 + "read_time": 16.52563477 }, { "strategy": "DuplicateWeedout", "records": 3, - "read_time": 37.22563477 + "read_time": 58.22563477 }, { "chosen_strategy": "SJ-Materialization" @@ -8386,14 +8417,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -8405,14 +8436,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 4.405126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 4.405126953, "uses_join_buffering": true } } @@ -8424,14 +8455,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 9.215380859, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 9.215380859, "uses_join_buffering": true } } @@ -8442,7 +8473,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_outer_2", "rows_for_plan": 27, - "cost_for_plan": 15.54101562, + "cost_for_plan": 31.14101563, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -8460,14 +8491,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 18.80512695, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 18.80512695, "uses_join_buffering": true } } @@ -8479,14 +8510,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 52.41538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 52.41538086, "uses_join_buffering": true } } @@ -8502,11 +8533,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 33.74614258, + "cost_for_plan": 66.14614258, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 33.74614258, - "best_cost": 23.46152344 + "current_cost": 66.14614258, + "best_cost": 46.86152344 }, { "plan_prefix": [ @@ -8517,11 +8548,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 66.15639648, + "cost_for_plan": 132.1563965, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 66.15639648, - "best_cost": 23.46152344 + "current_cost": 132.1563965, + "best_cost": 46.86152344 } ] }, @@ -8529,7 +8560,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_inner_4", "rows_for_plan": 9, - "cost_for_plan": 11.93076172, + "cost_for_plan": 22.73076172, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -8547,14 +8578,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -8566,14 +8597,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "resulting_rows": 9, - "cost": 2.015380859, + "cost": 20.01538086, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 9, - "cost": 2.015380859, + "cost": 20.01538086, "uses_join_buffering": true } } @@ -8589,11 +8620,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_outer_2", "rows_for_plan": 81, - "cost_for_plan": 30.14614258, + "cost_for_plan": 58.94614258, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 30.14614258, - "best_cost": 23.46152344 + "current_cost": 58.94614258, + "best_cost": 46.86152344 }, { "plan_prefix": [ @@ -8604,11 +8635,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 81, - "cost_for_plan": 30.14614258, + "cost_for_plan": 58.94614258, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 30.14614258, - "best_cost": 23.46152344 + "current_cost": 58.94614258, + "best_cost": 46.86152344 } ] }, @@ -8616,7 +8647,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 15.54101562, + "cost_for_plan": 31.14101563, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -8626,7 +8657,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_4", "rows_for_plan": 27, - "cost_for_plan": 13.81538086, + "cost_for_plan": 22.81538086, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -8634,11 +8665,9 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_3", "rows_for_plan": 81, - "cost_for_plan": 24.62563477, + "cost_for_plan": 45.62563477, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 24.62563477, - "best_cost": 23.46152344 + "pruned_by_heuristic": true } ] }, @@ -8646,7 +8675,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_2", "rows_for_plan": 27, - "cost_for_plan": 10.02050781, + "cost_for_plan": 17.82050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -8654,7 +8683,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_4", "rows_for_plan": 9, - "cost_for_plan": 6.410253906, + "cost_for_plan": 9.410253906, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -8662,7 +8691,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 10.02050781, + "cost_for_plan": 17.82050781, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -8672,7 +8701,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_outer_2", "rows_for_plan": 9, - "cost_for_plan": 3.815380859, + "cost_for_plan": 5.615380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -8680,7 +8709,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -8688,7 +8717,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 3.815380859, + "cost_for_plan": 5.615380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -8696,7 +8725,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_4", "rows_for_plan": 3, - "cost_for_plan": 2.605126953, + "cost_for_plan": 3.205126953, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -8704,7 +8733,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_3", "rows_for_plan": 9, - "cost_for_plan": 3.815380859, + "cost_for_plan": 5.615380859, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -8742,7 +8771,8 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "t_outer_2", "", "" - ] + ], + "cost": 46.86052344 }, { "substitute_best_equal": { @@ -9328,7 +9358,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 5, - "cost": 3.017089844, + "cost": 4.017089844, "chosen": true } ], @@ -9336,7 +9366,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 5, - "cost": 3.017089844, + "cost": 4.017089844, "uses_join_buffering": false } } @@ -9350,7 +9380,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 800, - "cost": 44.19726562, + "cost": 204.1972656, "chosen": true } ], @@ -9358,7 +9388,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 800, - "cost": 44.19726562, + "cost": 204.1972656, "uses_join_buffering": false } } @@ -9370,7 +9400,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "A", "rows_for_plan": 5, - "cost_for_plan": 4.017089844, + "cost_for_plan": 5.017089844, "rest_of_plan": [ { @@ -9387,7 +9417,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 800, - "cost": 220.9863281, + "cost": 1820.986328, "chosen": true } ], @@ -9395,7 +9425,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 800, - "cost": 220.9863281, + "cost": 1820.986328, "uses_join_buffering": false } } @@ -9407,7 +9437,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ["A"], "table": "B", "rows_for_plan": 4000, - "cost_for_plan": 1025.003418 + "cost_for_plan": 2626.003418 } ] }, @@ -9416,7 +9446,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "B", "rows_for_plan": 800, - "cost_for_plan": 204.1972656, + "cost_for_plan": 364.1972656, "pruned_by_heuristic": true } ] @@ -9445,7 +9475,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 10, - "cost": 2.017089844, + "cost": 4.017089844, "chosen": true } ], @@ -9453,7 +9483,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 10, - "cost": 2.017089844, + "cost": 4.017089844, "uses_join_buffering": false } } @@ -9467,7 +9497,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 800, - "cost": 44.19726562, + "cost": 204.1972656, "chosen": true } ], @@ -9475,7 +9505,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 800, - "cost": 44.19726562, + "cost": 204.1972656, "uses_join_buffering": false } } @@ -9487,7 +9517,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "A", "rows_for_plan": 10, - "cost_for_plan": 4.017089844, + "cost_for_plan": 6.017089844, "rest_of_plan": [ { @@ -9506,15 +9536,16 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "b", "used_range_estimates": false, "reason": "not available", - "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, - "cost": 20.00585794, + "cond_check_cost": 2.200585794, + "startup_cost": 0, + "cost": 22.00585794, "chosen": true }, { "access_type": "scan", "resulting_rows": 600, - "cost": 84.19726562, + "cost": 1404.197266, "chosen": false } ], @@ -9522,7 +9553,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "ref", "records": 1, - "cost": 20.00585794, + "cost": 22.00585794, "uses_join_buffering": false } } @@ -9534,7 +9565,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ["A"], "table": "B", "rows_for_plan": 10, - "cost_for_plan": 26.02294779, + "cost_for_plan": 30.02294779, "selectivity": 0.8, "estimated_join_cardinality": 8 } @@ -9545,10 +9576,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "B", "rows_for_plan": 800, - "cost_for_plan": 204.1972656, + "cost_for_plan": 364.1972656, "pruned_by_cost": true, - "current_cost": 204.1972656, - "best_cost": 26.02294779 + "current_cost": 364.1972656, + "best_cost": 30.02294779 } ] ] @@ -9673,7 +9704,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 10, - "cost": 2.021972656, + "cost": 4.021972656, "chosen": true } ], @@ -9681,7 +9712,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 10, - "cost": 2.021972656, + "cost": 4.021972656, "uses_join_buffering": false } } @@ -9695,7 +9726,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "resulting_rows": 100, - "cost": 2.219726562, + "cost": 22.21972656, "chosen": true, "use_tmp_table": true } @@ -9704,7 +9735,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "scan", "records": 100, - "cost": 2.219726562, + "cost": 22.21972656, "uses_join_buffering": false } } @@ -9716,7 +9747,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "t1", "rows_for_plan": 10, - "cost_for_plan": 4.021972656, + "cost_for_plan": 6.021972656, "rest_of_plan": [ { @@ -9735,15 +9766,16 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "a", "used_range_estimates": false, "reason": "not available", - "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, - "cost": 20.00585794, + "cond_check_cost": 2.200585794, + "startup_cost": 0, + "cost": 22.00585794, "chosen": true }, { "access_type": "scan", "resulting_rows": 75, - "cost": 7.219726562, + "cost": 172.2197266, "chosen": false } ], @@ -9751,7 +9783,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "type": "ref", "records": 1, - "cost": 20.00585794, + "cost": 22.00585794, "uses_join_buffering": false } } @@ -9763,7 +9795,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ["t1"], "table": "t2", "rows_for_plan": 10, - "cost_for_plan": 26.0278306, + "cost_for_plan": 30.0278306, "cost_for_sorting": 10 } ] @@ -9773,59 +9805,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "t2", "rows_for_plan": 100, - "cost_for_plan": 22.21972656, - "rest_of_plan": - [ - { - "plan_prefix": - ["t2"], - "get_costs_for_tables": - [ - { - "best_access_path": - { - "table": "t1", - "considered_access_paths": - [ - { - "access_type": "ref", - "index": "a", - "used_range_estimates": false, - "reason": "not available", - "rowid_filter_skipped": "cost_factor <= 0", - "rows": 1, - "cost": 200.0585794, - "chosen": true - }, - { - "access_type": "scan", - "resulting_rows": 7.5, - "cost": 2.521972656, - "chosen": true - } - ], - "chosen_access_method": - { - "type": "scan", - "records": 7.5, - "cost": 2.521972656, - "uses_join_buffering": true - } - } - } - ] - }, - { - "plan_prefix": - ["t2"], - "table": "t1", - "rows_for_plan": 750, - "cost_for_plan": 174.7416992, - "pruned_by_cost": true, - "current_cost": 174.7416992, - "best_cost": 36.0278306 - } - ] + "cost_for_plan": 42.21972656, + "pruned_by_cost": true, + "current_cost": 42.21972656, + "best_cost": 40.0278306 } ] ] @@ -10042,14 +10025,14 @@ select count(*) from seq_1_to_10000000 { { "access_type": "scan", "resulting_rows": 10000000, - "cost": 10000000, + "cost": 12000000, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 10000000, - "cost": 10000000, + "cost": 12000000, "uses_join_buffering": false } } @@ -10060,12 +10043,13 @@ select count(*) from seq_1_to_10000000 { "plan_prefix": [], "table": "seq_1_to_10000000", "rows_for_plan": 10000000, - "cost_for_plan": 12000000 + "cost_for_plan": 14000000 } ] }, { - "best_join_order": ["seq_1_to_10000000"] + "best_join_order": ["seq_1_to_10000000"], + "cost": 14000000 }, { "attaching_conditions_to_tables": { @@ -10128,8 +10112,9 @@ set @tmp=@@in_predicate_conversion_threshold; set in_predicate_conversion_threshold=3; explain select * from t0 where a in (1,2,3,4,5,6); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where -1 PRIMARY ref key0 key0 4 test.t0.a 2 FirstMatch(t0) +1 PRIMARY t0 ALL NULL NULL NULL NULL 10 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED ALL NULL NULL NULL NULL 6 3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) from information_schema.optimizer_trace; @@ -10231,8 +10216,6 @@ S { "access_type": "ref", "index": "PRIMARY", - "rows": 1.79769e308, - "cost": 1.79769e308, "chosen": false, "cause": "no predicate for first keypart" } @@ -10423,7 +10406,9 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "used_range_estimates": false, "reason": "not available", "rows": 1.8367, - "cost": 2.000585794, + "cond_check_cost": 2.367925794, + "startup_cost": 0, + "cost": 2.367925794, "chosen": true }, { @@ -10436,7 +10421,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) { "type": "ref", "records": 1.8367, - "cost": 2.000585794, + "cost": 2.367925794, "uses_join_buffering": false } } @@ -10448,7 +10433,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) [], "table": "t2", "rows_for_plan": 1.8367, - "cost_for_plan": 2.367925794, + "cost_for_plan": 2.735265794, "cost_for_sorting": 1.8367 } ] @@ -10459,8 +10444,8 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "table": "t2", "key": "idx_a", "record_count": 4, - "cost": 2.488945919, - "unsplit_cost": 25.72361682 + "cost": 2.856285919, + "unsplit_cost": 43.72361682 } } ] @@ -10472,8 +10457,8 @@ information_schema.optimizer_trace; json_detailed(json_extract(trace, '$**.lateral_derived')) [ { - "startup_cost": 9.955783677, - "splitting_cost": 2.488945919, + "startup_cost": 11.42514368, + "splitting_cost": 2.856285919, "records": 1 } ] diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result index dd23093ad9e..5944bfc8c3f 100644 --- a/mysql-test/main/opt_trace_index_merge.result +++ b/mysql-test/main/opt_trace_index_merge.result @@ -238,7 +238,8 @@ explain select * from t1 where a=1 or b=1 { ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 2.883903732 }, { "substitute_best_equal": { diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result index adb9cd5d622..0ce74504b13 100644 --- a/mysql-test/main/opt_trace_index_merge_innodb.result +++ b/mysql-test/main/opt_trace_index_merge_innodb.result @@ -212,7 +212,9 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "index": "key1", "used_range_estimates": true, "rows": 1, - "cost": 1.125146475, + "cond_check_cost": 1.325146475, + "startup_cost": 0, + "cost": 1.325146475, "chosen": true }, { @@ -224,7 +226,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "chosen_access_method": { "type": "ref", "records": 1, - "cost": 1.125146475, + "cost": 1.325146475, "uses_join_buffering": false } } @@ -235,12 +237,13 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 1.325146475 + "cost_for_plan": 1.525146475 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 1.524146475 }, { "substitute_best_equal": { diff --git a/mysql-test/main/opt_trace_security.result b/mysql-test/main/opt_trace_security.result index 48ca5c5e36f..ed828cda438 100644 --- a/mysql-test/main/opt_trace_security.result +++ b/mysql-test/main/opt_trace_security.result @@ -97,14 +97,14 @@ select * from db1.t1 { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -115,12 +115,13 @@ select * from db1.t1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953 + "cost_for_plan": 3.205126953 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 3.204126953 }, { "attaching_conditions_to_tables": { @@ -226,14 +227,14 @@ select * from db1.v1 { { "access_type": "scan", "resulting_rows": 3, - "cost": 2.005126953, + "cost": 2.605126953, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 3, - "cost": 2.005126953, + "cost": 2.605126953, "uses_join_buffering": false } } @@ -244,12 +245,13 @@ select * from db1.v1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 2.605126953 + "cost_for_plan": 3.205126953 } ] }, { - "best_join_order": ["t1"] + "best_join_order": ["t1"], + "cost": 3.204126953 }, { "attaching_conditions_to_tables": { diff --git a/mysql-test/main/opt_trace_selectivity.result b/mysql-test/main/opt_trace_selectivity.result index 31eddaf5c10..86290a631fd 100644 --- a/mysql-test/main/opt_trace_selectivity.result +++ b/mysql-test/main/opt_trace_selectivity.result @@ -49,7 +49,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "a", "used_range_estimates": true, "rows": 104, - "cost": 104.16562, + "cond_check_cost": 124.96562, + "startup_cost": 0, + "cost": 124.96562, "chosen": true }, { @@ -57,7 +59,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "b", "used_range_estimates": true, "rows": 340, - "cost": 340.2577963, + "cond_check_cost": 408.2577963, + "startup_cost": 0, + "cost": 408.2577963, "chosen": false, "cause": "cost" }, @@ -66,7 +70,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "c", "used_range_estimates": true, "rows": 632, - "cost": 632.3718449, + "cond_check_cost": 758.7718449, + "startup_cost": 0, + "cost": 758.7718449, "chosen": false, "cause": "cost" }, @@ -137,7 +143,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "a", "used_range_estimates": true, "rows": 6, - "cost": 6.127343464, + "cond_check_cost": 7.327343464, + "startup_cost": 0, + "cost": 7.327343464, "chosen": true }, { @@ -145,7 +153,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "b", "used_range_estimates": true, "rows": 232, - "cost": 232.2156139, + "cond_check_cost": 278.6156139, + "startup_cost": 0, + "cost": 278.6156139, "chosen": false, "cause": "cost" }, @@ -154,7 +164,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "c", "used_range_estimates": true, "rows": 293, - "cost": 293.2394392, + "cond_check_cost": 351.8394392, + "startup_cost": 0, + "cost": 351.8394392, "chosen": false, "cause": "cost" }, diff --git a/mysql-test/main/opt_tvc.result b/mysql-test/main/opt_tvc.result index eaf75ed7999..504038954b2 100644 --- a/mysql-test/main/opt_tvc.result +++ b/mysql-test/main/opt_tvc.result @@ -150,11 +150,11 @@ from t2 where b in (3,4) id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED ref key0 key0 4 test.t2.b 2 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `test`.`t2`.`b` = `tvc_0`.`_col_1` +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `tvc_0`.`_col_1` = `test`.`t2`.`b` explain extended select * from t1 where a in ( @@ -168,11 +168,11 @@ from (values (3),(4)) as tvc_0 id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED ref key0 key0 4 test.t2.b 2 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `test`.`t2`.`b` = `tvc_0`.`3` +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `tvc_0`.`3` = `test`.`t2`.`b` # derived table with IN-predicate select * from ( @@ -382,11 +382,11 @@ as dr_table id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED ref key0 key0 4 test.t1.a 2 100.00 5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `test`.`t1`.`a` = `tvc_0`.`_col_1` +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `tvc_0`.`_col_1` = `test`.`t1`.`a` explain extended select * from t1 where a in ( @@ -407,11 +407,11 @@ as dr_table id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED ref key0 key0 4 test.t1.a 2 100.00 5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `test`.`t1`.`a` = `tvc_0`.`1` +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `tvc_0`.`1` = `test`.`t1`.`a` # derived table with IN-predicate and group by select * from ( @@ -568,18 +568,18 @@ explain extended select * from t1 where (a,b) not in ((1,2),(8,9), (5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key +2 MATERIALIZED ALL NULL NULL NULL NULL 3 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(((`test`.`t1`.`a`) in (temporary) on key0 where trigcond((`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond((`test`.`t1`.`b`) = `tvc_0`.`_col_2`))))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`_col_1` and `test`.`t1`.`b` = ``.`_col_2`)))) explain extended select * from t1 where (a,b) not in (select * from (values (1,2),(8,9), (5,1)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key +2 MATERIALIZED ALL NULL NULL NULL NULL 3 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(((`test`.`t1`.`a`) in (temporary) on key0 where trigcond((`test`.`t1`.`a`) = `tvc_0`.`1`) and trigcond((`test`.`t1`.`b`) = `tvc_0`.`2`))))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`1` and `test`.`t1`.`b` = ``.`2`)))) select * from t1 where b < 7 and (a,b) not in ((1,2),(8,9), (5,1)); a b @@ -590,10 +590,10 @@ explain extended select * from t1 where b < 7 and (a,b) not in ((1,2),(8,9), (5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key +2 MATERIALIZED ALL NULL NULL NULL NULL 3 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(((`test`.`t1`.`a`) in (temporary) on key0 where trigcond((`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond((`test`.`t1`.`b`) = `tvc_0`.`_col_2`))))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`_col_1` and `test`.`t1`.`b` = ``.`_col_2`)))) select * from t2 where (a,c) not in ((1,2),(8,9), (5,1)); a b c @@ -606,10 +606,10 @@ explain extended select * from t2 where (a,c) not in ((1,2),(8,9), (5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key +2 MATERIALIZED ALL NULL NULL NULL NULL 3 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<`test`.`t2`.`a`,`test`.`t2`.`c`>(((`test`.`t2`.`a`,`test`.`t2`.`c`),(((`test`.`t2`.`a`) in (temporary) on key0 where trigcond((`test`.`t2`.`a`) = `tvc_0`.`_col_1`) and trigcond((`test`.`t2`.`c`) = `tvc_0`.`_col_2`))))) +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<`test`.`t2`.`a`,`test`.`t2`.`c`>(((`test`.`t2`.`a`,`test`.`t2`.`c`),(`test`.`t2`.`a`,`test`.`t2`.`c`) in ( (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), (`test`.`t2`.`a` in on distinct_key where `test`.`t2`.`a` = ``.`_col_1` and `test`.`t2`.`c` = ``.`_col_2`)))) drop table t1, t2, t3; set @@in_predicate_conversion_threshold= default; # diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index 1311f42dac2..c1016393828 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -3188,13 +3188,13 @@ explain select t2.pk,t2.a,t2.b,t3.pk,t3.a,t3.b from t2, t3 where t2.a=t3.a order by t2.a limit 25; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL a NULL NULL NULL 200 Using where; Using filesort +1 SIMPLE t2 index a a 5 NULL 25 Using where 1 SIMPLE t3 ref a a 5 test.t2.a 1 explain select t2.pk,t2.a,t2.b,t3.pk,t3.a,t3.b from t2, t3 where t2.a=t3.a order by t3.a limit 25; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL a NULL NULL NULL 200 Using where; Using filesort +1 SIMPLE t2 index a a 5 NULL 25 Using where 1 SIMPLE t3 ref a a 5 test.t2.a 1 select t2.pk,t2.a,t2.b,t3.pk,t3.a,t3.b from t2, t3 where t2.a=t3.a order by t2.a limit 25; diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result index ec0cb144a51..519bf590b9b 100644 --- a/mysql-test/main/partition_pruning.result +++ b/mysql-test/main/partition_pruning.result @@ -2677,7 +2677,7 @@ select * from t1 X, t1 Y where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3); id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE X p1,p2 range a,b a 4 NULL 4 Using where -1 SIMPLE Y p2,p3 ref a,b b 4 test.X.b 2 Using where +1 SIMPLE Y p2,p3 ref|filter a,b b|a 4|4 test.X.b 2 (50%) Using where; Using rowid filter explain partitions select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); id select_type table partitions type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index e86cff59bd3..3f27ef6540f 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -360,7 +360,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 Using index condition -1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (5%) Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND @@ -397,6 +397,14 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 69, + "selectivity_pct": 4.6 + }, "rows": 1, "filtered": 4.599999905, "attached_condition": "orders.o_totalprice between 200000 and 230000" @@ -411,7 +419,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 98.00 100.00 100.00 Using index condition -1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 4.60 11.22 Using where +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (5%) 0.11 (10%) 4.60 100.00 Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND @@ -458,13 +466,26 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 69, + "selectivity_pct": 4.6, + "r_rows": 71, + "r_lookups": 96, + "r_selectivity_pct": 10.41666667, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, "r_loops": 98, "rows": 1, - "r_rows": 1, + "r_rows": 0.112244898, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 4.599999905, - "r_filtered": 11.2244898, + "r_filtered": 100, "attached_condition": "orders.o_totalprice between 200000 and 230000" } } @@ -627,7 +648,7 @@ l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) Using index condition; Using where; Using rowid filter -1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (9%) Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -675,6 +696,14 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 139, + "selectivity_pct": 9.266666667 + }, "rows": 1, "filtered": 9.266666412, "attached_condition": "orders.o_totalprice between 180000 and 230000" @@ -690,7 +719,7 @@ l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) 60.00 (11%) 11.69 100.00 Using index condition; Using where; Using rowid filter -1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.27 26.67 Using where +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (9%) 0.27 (25%) 9.27 100.00 Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -753,13 +782,26 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 139, + "selectivity_pct": 9.266666667, + "r_rows": 144, + "r_lookups": 59, + "r_selectivity_pct": 25.42372881, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, "r_loops": 60, "rows": 1, - "r_rows": 1, + "r_rows": 0.266666667, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 9.266666412, - "r_filtered": 26.66666667, + "r_filtered": 100, "attached_condition": "orders.o_totalprice between 180000 and 230000" } } @@ -941,7 +983,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 Using index condition -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) Using where; Using rowid filter +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -978,14 +1020,6 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 509, - "selectivity_pct": 8.476269775 - }, "rows": 4, "filtered": 8.476269722, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" @@ -1000,7 +1034,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 71.00 100.00 100.00 Using index condition -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) 0.52 (7%) 8.48 100.00 Using where; Using rowid filter +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.70 8.48 7.77 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -1047,26 +1081,13 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 509, - "selectivity_pct": 8.476269775, - "r_rows": 510, - "r_lookups": 476, - "r_selectivity_pct": 7.773109244, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, "r_loops": 71, "rows": 4, - "r_rows": 0.521126761, + "r_rows": 6.704225352, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.476269722, - "r_filtered": 100, + "r_filtered": 7.773109244, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -2257,8 +2278,8 @@ pk1 a1 b1 pk2 a2 b2 EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 -1 PRIMARY t1 ALL a1,b1 NULL NULL NULL 400 21.56 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where +1 PRIMARY t1 ref|filter a1,b1 a1|b1 5|4 test.t2.a2 36 (29%) 28.75 Using where; Using rowid filter 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t1`.`pk1` + 1 = `test`.`t2`.`pk2` + 2 @@ -2274,23 +2295,30 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 101, - "filtered": 100 + "filtered": 100, + "attached_condition": "t2.a2 is not null" } }, { - "block-nl-join": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "possible_keys": ["a1", "b1"], - "rows": 400, - "filtered": 21.5625, - "attached_condition": "t1.b1 <= (subquery#2)" + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a1", "b1"], + "key": "a1", + "key_length": "5", + "used_key_parts": ["a1"], + "ref": ["test.t2.a2"], + "rowid_filter": { + "range": { + "key": "b1", + "used_key_parts": ["b1"] + }, + "rows": 115, + "selectivity_pct": 28.75 }, - "buffer_type": "flat", - "buffer_size": "1Kb", - "join_type": "BNL", - "attached_condition": "t1.a1 = t2.a2 and t1.pk1 + 1 = t2.pk2 + 2" + "rows": 36, + "filtered": 28.75, + "attached_condition": "t1.b1 <= (subquery#2) and t1.pk1 + 1 = t2.pk2 + 2" } } ], @@ -2740,33 +2768,20 @@ ANALYZE { "table": { "table_name": "t1", - "access_type": "ref", + "access_type": "range", "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "5", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 44, - "selectivity_pct": 0.44, - "r_rows": 44, - "r_lookups": 1000, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, + "key": "idx1", + "key_length": "256", + "used_key_parts": ["nm"], "r_loops": 1, - "rows": 863, - "r_rows": 0, + "rows": 44, + "r_rows": 44, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 0.439999998, - "r_filtered": 100, - "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" + "filtered": 8.630000114, + "r_filtered": 0, + "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", + "attached_condition": "t1.fl2 = 0" } } ] @@ -2806,31 +2821,20 @@ ANALYZE { "table": { "table_name": "t1", - "access_type": "ref", + "access_type": "range", "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "5", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 44, - "selectivity_pct": 0.44, - "r_rows": 0, - "r_lookups": 0, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, + "key": "idx1", + "key_length": "256", + "used_key_parts": ["nm"], "r_loops": 1, - "rows": 853, + "rows": 44, "r_rows": 0, - "filtered": 0.439999998, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.529999733, "r_filtered": 100, - "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" + "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", + "attached_condition": "t1.fl2 = 0" } } ] diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index 51c061fe3a4..c8220e0f5a1 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -2730,33 +2730,20 @@ ANALYZE { "table": { "table_name": "t1", - "access_type": "ref", + "access_type": "range", "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "5", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 44, - "selectivity_pct": 0.44, - "r_rows": 44, - "r_lookups": 1000, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, + "key": "idx1", + "key_length": "256", + "used_key_parts": ["nm"], "r_loops": 1, - "rows": 863, - "r_rows": 0, + "rows": 44, + "r_rows": 44, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 0.439999998, - "r_filtered": 100, - "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" + "filtered": 8.630000114, + "r_filtered": 0, + "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", + "attached_condition": "t1.fl2 = 0" } } ] @@ -2796,31 +2783,20 @@ ANALYZE { "table": { "table_name": "t1", - "access_type": "ref", + "access_type": "range", "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "5", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 44, - "selectivity_pct": 0.44, - "r_rows": 0, - "r_lookups": 0, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, + "key": "idx1", + "key_length": "256", + "used_key_parts": ["nm"], "r_loops": 1, - "rows": 853, + "rows": 44, "r_rows": 0, - "filtered": 0.439999998, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.529999733, "r_filtered": 100, - "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" + "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", + "attached_condition": "t1.fl2 = 0" } } ] diff --git a/mysql-test/main/rowid_filter_innodb_debug.test b/mysql-test/main/rowid_filter_innodb_debug.test index 60381658eaf..99d32f9616d 100644 --- a/mysql-test/main/rowid_filter_innodb_debug.test +++ b/mysql-test/main/rowid_filter_innodb_debug.test @@ -1,7 +1,9 @@ --source include/have_innodb.inc +--source include/have_sequence.inc --source include/no_valgrind_without_big.inc set default_storage_engine=innodb; --source include/rowid_filter_debug_kill.inc set default_storage_engine=default; + diff --git a/mysql-test/main/select.result b/mysql-test/main/select.result index bedc8bfa4b8..2b545fe5e94 100644 --- a/mysql-test/main/select.result +++ b/mysql-test/main/select.result @@ -3480,7 +3480,7 @@ EXPLAIN SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using index condition; Using where -1 SIMPLE t2 ALL c NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c c 5 test.t1.a 2 DROP TABLE t1, t2; create table t1 ( a int unsigned not null auto_increment primary key, @@ -3616,7 +3616,7 @@ t3.a=t2.a AND t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 4 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND @@ -3624,7 +3624,7 @@ t3.a=t2.a AND t3.c IN ('bb','ee') ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 4 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3717,7 +3717,7 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -3731,7 +3731,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/select_jcl6.result b/mysql-test/main/select_jcl6.result index 520eb5afa33..7541fdf9e56 100644 --- a/mysql-test/main/select_jcl6.result +++ b/mysql-test/main/select_jcl6.result @@ -3491,7 +3491,7 @@ EXPLAIN SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using index condition; Using where; Rowid-ordered scan -1 SIMPLE t2 ALL c NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c c 5 test.t1.a 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan DROP TABLE t1, t2; create table t1 ( a int unsigned not null auto_increment primary key, @@ -3627,7 +3627,7 @@ t3.a=t2.a AND t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 4 Using index condition; Using where; Rowid-ordered scan -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND @@ -3635,7 +3635,7 @@ t3.a=t2.a AND t3.c IN ('bb','ee') ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 4 Using index condition; Using where; Rowid-ordered scan -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3728,7 +3728,7 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -3742,7 +3742,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/select_pkeycache.result b/mysql-test/main/select_pkeycache.result index bedc8bfa4b8..2b545fe5e94 100644 --- a/mysql-test/main/select_pkeycache.result +++ b/mysql-test/main/select_pkeycache.result @@ -3480,7 +3480,7 @@ EXPLAIN SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using index condition; Using where -1 SIMPLE t2 ALL c NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c c 5 test.t1.a 2 DROP TABLE t1, t2; create table t1 ( a int unsigned not null auto_increment primary key, @@ -3616,7 +3616,7 @@ t3.a=t2.a AND t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 4 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND @@ -3624,7 +3624,7 @@ t3.a=t2.a AND t3.c IN ('bb','ee') ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 4 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3717,7 +3717,7 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -3731,7 +3731,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index e14bad43be9..1dff67e804a 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -114,17 +114,17 @@ order by s_acctbal desc, n_name, s_name, p_partkey; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using temporary; Using filesort +1 PRIMARY nation ref PRIMARY,i_n_regionkey i_n_regionkey 5 dbt3_s001.region.r_regionkey 5 100.00 +1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 2.08 Using where; Using join buffer (flat, BNL join) -1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 Using where -1 PRIMARY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where -1 PRIMARY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where +1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 100.00 Using where 2 DEPENDENT SUBQUERY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where 2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 2 DEPENDENT SUBQUERY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where 2 DEPENDENT SUBQUERY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.part.p_partkey' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `dbt3_s001`.`supplier`.`s_acctbal` AS `s_acctbal`,`dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`nation`.`n_name` AS `n_name`,`dbt3_s001`.`part`.`p_partkey` AS `p_partkey`,`dbt3_s001`.`part`.`p_mfgr` AS `p_mfgr`,`dbt3_s001`.`supplier`.`s_address` AS `s_address`,`dbt3_s001`.`supplier`.`s_phone` AS `s_phone`,`dbt3_s001`.`supplier`.`s_comment` AS `s_comment` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`part`.`p_size` = 9 and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_type` like '%TIN' and `dbt3_s001`.`partsupp`.`ps_supplycost` = <`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` +Note 1003 /* select#1 */ select `dbt3_s001`.`supplier`.`s_acctbal` AS `s_acctbal`,`dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`nation`.`n_name` AS `n_name`,`dbt3_s001`.`part`.`p_partkey` AS `p_partkey`,`dbt3_s001`.`part`.`p_mfgr` AS `p_mfgr`,`dbt3_s001`.`supplier`.`s_address` AS `s_address`,`dbt3_s001`.`supplier`.`s_phone` AS `s_phone`,`dbt3_s001`.`supplier`.`s_comment` AS `s_comment` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`part`.`p_size` = 9 and `dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_type` like '%TIN' and `dbt3_s001`.`partsupp`.`ps_supplycost` = <`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` === Q15 === create view revenue0 (supplier_no, total_revenue) as select l_suppkey, sum(l_extendedprice * (1 - l_discount)) @@ -1661,7 +1661,7 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` # gives selectivity data explain extended select * from t1 where a in (17,51,5) and b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ref b,a b 5 const 24 2.90 Using where +1 SIMPLE t1 ref|filter b,a b|a 5|5 const 24 (3%) 2.90 Using where; Using rowid filter Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5) drop table t1; diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index 2371cfa111c..cdde80cf248 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -77,8 +77,8 @@ and r_name = 'ASIA' order by s_acctbal desc, n_name, s_name, p_partkey; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using temporary; Using filesort -1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 0.50 Using where; Using join buffer (flat, BNL join) +1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 0.50 Using where; Using temporary; Using filesort +1 PRIMARY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where 1 PRIMARY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where 1 PRIMARY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where @@ -1673,7 +1673,7 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` # gives selectivity data explain extended select * from t1 where a in (17,51,5) and b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ref b,a b 5 const 24 2.90 Using where +1 SIMPLE t1 ref|filter b,a b|a 5|5 const 24 (3%) 2.90 Using where; Using rowid filter Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5) drop table t1; diff --git a/mysql-test/main/single_delete_update.result b/mysql-test/main/single_delete_update.result index 85e79f53c89..1f0299ac0fc 100644 --- a/mysql-test/main/single_delete_update.result +++ b/mysql-test/main/single_delete_update.result @@ -129,21 +129,21 @@ a b c d SHOW SESSION STATUS LIKE 'Sort%'; Variable_name Value Sort_merge_passes 0 -Sort_priority_queue_sorts 1 +Sort_priority_queue_sorts 0 Sort_range 0 -Sort_rows 1 -Sort_scan 1 +Sort_rows 0 +Sort_scan 0 SHOW STATUS LIKE 'Handler_read_%'; Variable_name Value -Handler_read_first 0 +Handler_read_first 1 Handler_read_key 0 Handler_read_last 0 -Handler_read_next 0 +Handler_read_next 16 Handler_read_prev 0 Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 -Handler_read_rnd_next 17 +Handler_read_rnd_next 0 FLUSH STATUS; DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; SHOW SESSION STATUS LIKE 'Sort%'; @@ -734,21 +734,21 @@ a b c d SHOW SESSION STATUS LIKE 'Sort%'; Variable_name Value Sort_merge_passes 0 -Sort_priority_queue_sorts 1 +Sort_priority_queue_sorts 0 Sort_range 0 -Sort_rows 1 -Sort_scan 1 +Sort_rows 0 +Sort_scan 0 SHOW STATUS LIKE 'Handler_read_%'; Variable_name Value -Handler_read_first 0 +Handler_read_first 1 Handler_read_key 0 Handler_read_last 0 -Handler_read_next 0 +Handler_read_next 16 Handler_read_prev 0 Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 -Handler_read_rnd_next 17 +Handler_read_rnd_next 0 FLUSH STATUS; UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; SHOW SESSION STATUS LIKE 'Sort%'; diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result index dd6251edcd5..a753aaa2e5d 100644 --- a/mysql-test/main/stat_tables.result +++ b/mysql-test/main/stat_tables.result @@ -71,10 +71,10 @@ order by revenue desc; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort 1 SIMPLE nation ref PRIMARY,i_n_regionkey i_n_regionkey 5 dbt3_s001.region.r_regionkey 5 +1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 1 SIMPLE orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (12%) Using where; Using rowid filter 1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where -1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey @@ -85,7 +85,7 @@ and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01' group by n_name order by revenue desc; n_name revenue -PERU 321915.8715 +PERU 321915.87150000007 ARGENTINA 69817.1451 set optimizer_switch=@save_optimizer_switch; delete from mysql.index_stats; @@ -178,10 +178,10 @@ order by revenue desc; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort 1 SIMPLE nation ref PRIMARY,i_n_regionkey i_n_regionkey 5 dbt3_s001.region.r_regionkey 5 +1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 1 SIMPLE orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (12%) Using where; Using rowid filter 1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where -1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey @@ -192,7 +192,7 @@ and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01' group by n_name order by revenue desc; n_name revenue -PERU 321915.8715 +PERU 321915.87150000007 ARGENTINA 69817.1451 set optimizer_switch=@save_optimizer_switch; EXPLAIN select o_year, diff --git a/mysql-test/main/status.result b/mysql-test/main/status.result index d17bd9c6a61..18e792ef02e 100644 --- a/mysql-test/main/status.result +++ b/mysql-test/main/status.result @@ -71,10 +71,10 @@ a 6 show status like 'last_query_cost'; Variable_name Value -Last_query_cost 12.084449 +Last_query_cost 22.084449 show status like 'last_query_cost'; Variable_name Value -Last_query_cost 12.084449 +Last_query_cost 22.084449 select 1; 1 1 @@ -134,13 +134,13 @@ a 1 SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 2.402418 +Last_query_cost 2.802418 EXPLAIN SELECT a FROM t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 2.402418 +Last_query_cost 2.802418 SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a; a 1 @@ -173,7 +173,7 @@ a a 1 1 SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 5.205836 +Last_query_cost 6.805836 DROP TABLE t1; connect con1,localhost,root,,; show status like 'com_show_status'; diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index 668ccdf773f..79c6cd78e92 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -1440,7 +1440,7 @@ a explain extended select * from t2 where t2.a in (select a from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 75.00 Using where; Using index; Using join buffer (flat, BNL join) +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select a from t1 where t1.b <> 30); @@ -1450,7 +1450,7 @@ a explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); @@ -1459,11 +1459,11 @@ a 3 explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 100.00 +1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join) -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where `test`.`t3`.`a` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t1`.`a` +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where `test`.`t3`.`a` = `test`.`t1`.`b` and `test`.`t1`.`a` = `test`.`t2`.`a` drop table t1, t2, t3; create table t1 (a int, b int, index a (a,b)); create table t2 (a int, index a (a)); @@ -4541,15 +4541,15 @@ SET @save_join_cache_level=@@join_cache_level; SET join_cache_level=0; EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary Warnings: Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` where ``.`min(a)` = 1 EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 WHERE a > 3 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary Warnings: Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select min(`test`.`t1`.`a`) from `test`.`t1` where `test`.`t1`.`a` > 3 group by `test`.`t1`.`a`) join `test`.`t1` where ``.`min(a)` = 1 @@ -7040,8 +7040,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY ALL distinct_key NULL NULL NULL 1 -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +2 SUBQUERY eq_ref distinct_key distinct_key 4 test.t2.c 1 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; diff --git a/mysql-test/main/subselect2.result b/mysql-test/main/subselect2.result index ebeda9a64af..db6c85900ad 100644 --- a/mysql-test/main/subselect2.result +++ b/mysql-test/main/subselect2.result @@ -132,7 +132,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3_b eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3_a.PARENTID 1 Using where 1 PRIMARY t3_c eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3_b.PARENTID 1 Using where 1 PRIMARY t3_d eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3_c.PARENTID 1 Using where -1 PRIMARY t3_e eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3_d.PARENTID 1 Using where +1 PRIMARY t3_e ref|filter PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX FFOLDERID_IDX|CMFLDRPARNT_IDX 34|35 test.t3_d.PARENTID 1 (29%) Using where; Using rowid filter drop table t1, t2, t3, t4; CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t1 VALUES (1),(2); diff --git a/mysql-test/main/subselect3.result b/mysql-test/main/subselect3.result index 2820775cb4f..28187e0ffdd 100644 --- a/mysql-test/main/subselect3.result +++ b/mysql-test/main/subselect3.result @@ -166,7 +166,7 @@ from t3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 2 DEPENDENT SUBQUERY t1 ref_or_null a a 5 func 4 100.00 Using where; Full scan on NULL key -2 DEPENDENT SUBQUERY t2 ALL a NULL NULL NULL 10 75.00 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 100.00 Using where Warnings: Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<`test`.`t3`.`a`,`test`.`t3`.`oref`>((`test`.`t3`.`a`,(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` and `test`.`t2`.`b` = `test`.`t3`.`oref` and trigcond((`test`.`t3`.`a`) = `test`.`t1`.`a` or `test`.`t1`.`a` is null) having trigcond(`test`.`t1`.`a` is null)))) AS `Z` from `test`.`t3` diff --git a/mysql-test/main/subselect3_jcl6.result b/mysql-test/main/subselect3_jcl6.result index 8be02ad5c2a..9df821e07dc 100644 --- a/mysql-test/main/subselect3_jcl6.result +++ b/mysql-test/main/subselect3_jcl6.result @@ -169,7 +169,7 @@ from t3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 2 DEPENDENT SUBQUERY t1 ref_or_null a a 5 func 4 100.00 Using where; Full scan on NULL key -2 DEPENDENT SUBQUERY t2 ALL a NULL NULL NULL 10 75.00 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan Warnings: Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<`test`.`t3`.`a`,`test`.`t3`.`oref`>((`test`.`t3`.`a`,(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` and `test`.`t2`.`b` = `test`.`t3`.`oref` and trigcond((`test`.`t3`.`a`) = `test`.`t1`.`a` or `test`.`t1`.`a` is null) having trigcond(`test`.`t1`.`a` is null)))) AS `Z` from `test`.`t3` diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index 5589272d066..6f29fe34ca5 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -1279,8 +1279,8 @@ EXPLAIN SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 0 Const row not found +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2); @@ -1288,8 +1288,8 @@ c1 c1 c1 EXPLAIN SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2); id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t4 index NULL PRIMARY 3 NULL 2 Using index 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -1 PRIMARY t4 index NULL PRIMARY 3 NULL 2 Using index; Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2); @@ -1370,8 +1370,8 @@ GROUP BY SQ1_t1.f4)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where -3 SUBQUERY SQ1_t3 range f4 f4 5 NULL 2 Using where; Using index; Using temporary -3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using join buffer (flat, BNL join) +3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary +3 SUBQUERY SQ1_t3 range f4 f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) SELECT * FROM t1 WHERE (SELECT f2 FROM t2 WHERE f4 <= ALL diff --git a/mysql-test/main/subselect_exists2in.result b/mysql-test/main/subselect_exists2in.result index d03edf522eb..a473f48e0f6 100644 --- a/mysql-test/main/subselect_exists2in.result +++ b/mysql-test/main/subselect_exists2in.result @@ -902,8 +902,8 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +3 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 100.00 Using where 3 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) 4 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Warnings: Note 1276 Field or reference 'sq1.pk' of SELECT #3 was resolved in SELECT #1 @@ -922,8 +922,8 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +3 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 100.00 Using where 3 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) 4 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Warnings: Note 1276 Field or reference 'sq1.pk' of SELECT #3 was resolved in SELECT #1 diff --git a/mysql-test/main/subselect_innodb.result b/mysql-test/main/subselect_innodb.result index 242b01f8955..0c44708eb32 100644 --- a/mysql-test/main/subselect_innodb.result +++ b/mysql-test/main/subselect_innodb.result @@ -612,9 +612,9 @@ INNER JOIN ON ( 1 IN ( SELECT f4 FROM t4 ) ) ) ON ( f1 >= f2 ); id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join) -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (incremental, BNL join) 3 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result index 4f5739aa4a7..2353e18c28e 100644 --- a/mysql-test/main/subselect_mat.result +++ b/mysql-test/main/subselect_mat.result @@ -1889,8 +1889,8 @@ WHERE alias4.c = alias3.b ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2 -3 MATERIALIZED alias4 index c c 11 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2 Using where +3 MATERIALIZED alias4 ref c c 11 test.alias3.b 2 Using where; Using index DROP TABLE t1,t2; # # BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result @@ -2241,8 +2241,8 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY sq1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 -2 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 # this checks the result set above set optimizer_switch= 'materialization=off,semijoin=off'; @@ -2275,8 +2275,8 @@ WHERE EXISTS ( SELECT * FROM t2, t3 WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 index i2 i2 5 NULL 3 100.00 Using where; Using index 2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00 Warnings: @@ -2314,8 +2314,8 @@ SELECT pk, f1, ( SELECT COUNT(*) FROM t2 WHERE t1.pk IN ( SELECT f2 FROM t2 ) ) AS sq FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join) 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Warnings: Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 @@ -2462,8 +2462,8 @@ alter table t1 add key(id); explain SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index id id 4 NULL 9 Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY ALL distinct_key NULL NULL NULL 3 +1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); 1 @@ -2519,8 +2519,8 @@ INSERT INTO t2 VALUES (11,11),(12,12),(13,13); CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2; explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index id id 4 NULL 9 Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY ALL distinct_key NULL NULL NULL 3 +1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); 1 diff --git a/mysql-test/main/subselect_mat_cost_bugs.result b/mysql-test/main/subselect_mat_cost_bugs.result index 67a4feafeee..185a99672e6 100644 --- a/mysql-test/main/subselect_mat_cost_bugs.result +++ b/mysql-test/main/subselect_mat_cost_bugs.result @@ -196,8 +196,8 @@ ORDER BY field1 ; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 2 Using where; Using filesort 1 PRIMARY alias1 eq_ref PRIMARY PRIMARY 4 alias2.f3 1 Using index -3 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index -3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 +3 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) 2 DERIVED t2 ALL NULL NULL NULL NULL 2 SELECT alias2.f2 AS field1 FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1 diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index 4a8a9ffc322..18cc982c565 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -1444,7 +1444,7 @@ a explain extended select * from t2 where t2.a in (select a from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 75.00 Using where; Using index; Using join buffer (flat, BNL join) +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select a from t1 where t1.b <> 30); @@ -1454,7 +1454,7 @@ a explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); @@ -1463,11 +1463,11 @@ a 3 explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 100.00 +1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join) -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where `test`.`t3`.`a` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t1`.`a` +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where `test`.`t3`.`a` = `test`.`t1`.`b` and `test`.`t1`.`a` = `test`.`t2`.`a` drop table t1, t2, t3; create table t1 (a int, b int, index a (a,b)); create table t2 (a int, index a (a)); @@ -4543,15 +4543,15 @@ SET @save_join_cache_level=@@join_cache_level; SET join_cache_level=0; EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary Warnings: Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` where ``.`min(a)` = 1 EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 WHERE a > 3 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary Warnings: Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select min(`test`.`t1`.`a`) from `test`.`t1` where `test`.`t1`.`a` > 3 group by `test`.`t1`.`a`) join `test`.`t1` where ``.`min(a)` = 1 @@ -7040,8 +7040,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY ALL distinct_key NULL NULL NULL 1 -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +2 SUBQUERY eq_ref distinct_key distinct_key 4 test.t2.c 1 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index 42b767c505e..0aa5f00a149 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -1447,7 +1447,7 @@ a explain extended select * from t2 where t2.a in (select a from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 75.00 Using where; Using index; Using join buffer (flat, BNL join) +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select a from t1 where t1.b <> 30); @@ -1457,7 +1457,7 @@ a explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); @@ -1466,11 +1466,11 @@ a 3 explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 100.00 +1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join) -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where `test`.`t3`.`a` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t1`.`a` +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where `test`.`t3`.`a` = `test`.`t1`.`b` and `test`.`t1`.`a` = `test`.`t2`.`a` drop table t1, t2, t3; create table t1 (a int, b int, index a (a,b)); create table t2 (a int, index a (a)); diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index 51386376d80..e11c344cfb4 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -7031,8 +7031,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY ALL distinct_key NULL NULL NULL 1 -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +2 SUBQUERY eq_ref distinct_key distinct_key 4 test.t2.c 1 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 3b4f0aa368f..8208e7a5379 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -1446,7 +1446,7 @@ a explain extended select * from t2 where t2.a in (select a from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 75.00 Using where; Using index; Using join buffer (flat, BNL join) +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select a from t1 where t1.b <> 30); @@ -1456,7 +1456,7 @@ a explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); @@ -1465,11 +1465,11 @@ a 3 explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 100.00 +1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join) -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where `test`.`t3`.`a` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t1`.`a` +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where `test`.`t3`.`a` = `test`.`t1`.`b` and `test`.`t1`.`a` = `test`.`t2`.`a` drop table t1, t2, t3; create table t1 (a int, b int, index a (a,b)); create table t2 (a int, index a (a)); @@ -4547,15 +4547,15 @@ SET @save_join_cache_level=@@join_cache_level; SET join_cache_level=0; EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary Warnings: Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` where ``.`min(a)` = 1 EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 WHERE a > 3 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY const distinct_key distinct_key 4 const 1 100.00 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary Warnings: Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select min(`test`.`t1`.`a`) from `test`.`t1` where `test`.`t1`.`a` > 3 group by `test`.`t1`.`a`) join `test`.`t1` where ``.`min(a)` = 1 @@ -7046,8 +7046,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY ALL distinct_key NULL NULL NULL 1 -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +2 SUBQUERY eq_ref distinct_key distinct_key 4 test.t2.c 1 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index a66886cfc21..e14d3d8bb73 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -7031,8 +7031,8 @@ SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index -2 SUBQUERY ALL distinct_key NULL NULL NULL 1 -2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +2 SUBQUERY eq_ref distinct_key distinct_key 4 test.t2.c 1 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10; diff --git a/mysql-test/main/subselect_sj.result b/mysql-test/main/subselect_sj.result index 1da51e76b4d..8078700bf5b 100644 --- a/mysql-test/main/subselect_sj.result +++ b/mysql-test/main/subselect_sj.result @@ -160,26 +160,26 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY s47 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) 1 PRIMARY s48 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) 1 PRIMARY s49 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m00 ALL NULL NULL NULL NULL 3 Using where -2 DEPENDENT SUBQUERY m01 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m02 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m03 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m04 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m05 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m06 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m07 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m08 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m09 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m10 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m11 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m12 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m13 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m14 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m15 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m16 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m17 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m18 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m19 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m00 ALL NULL NULL NULL NULL 3 +2 MATERIALIZED m01 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m02 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m03 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m04 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m05 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m06 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m07 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m08 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m09 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m10 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m11 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m12 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m13 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m14 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m15 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m16 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m17 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m18 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m19 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) where t1.a < 5; @@ -344,8 +344,8 @@ WHERE PNUM IN (SELECT PNUM FROM PROJ)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY STAFF ALL NULL NULL NULL NULL 5 -1 PRIMARY PROJ ALL NULL NULL NULL NULL 6 -1 PRIMARY WORKS ALL NULL NULL NULL NULL 12 Using where; FirstMatch(STAFF) +1 PRIMARY PROJ ALL NULL NULL NULL NULL 6 Start temporary +1 PRIMARY WORKS ALL NULL NULL NULL NULL 12 Using where; End temporary SELECT EMPNUM, EMPNAME FROM STAFF WHERE EMPNUM IN @@ -763,16 +763,16 @@ explain extended select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 -1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where; FirstMatch(t1) +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 Using where; End temporary; Using join buffer (flat, BNL join) 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`c` = `test`.`t1`.`a` and (<`test`.`t2`.`d`,`test`.`t1`.`b`>((`test`.`t2`.`d`,(/* select#3 */ select `test`.`t3`.`e` from `test`.`t3` where `test`.`t1`.`b` = `test`.`t3`.`e` and (`test`.`t2`.`d`) >= `test`.`t3`.`e`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t2`.`c` and (<`test`.`t2`.`d`,`test`.`t1`.`b`>((`test`.`t2`.`d`,(/* select#3 */ select `test`.`t3`.`e` from `test`.`t3` where `test`.`t1`.`b` = `test`.`t3`.`e` and (`test`.`t2`.`d`) >= `test`.`t3`.`e`)))) show warnings; Level Code Message Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`c` = `test`.`t1`.`a` and (<`test`.`t2`.`d`,`test`.`t1`.`b`>((`test`.`t2`.`d`,(/* select#3 */ select `test`.`t3`.`e` from `test`.`t3` where `test`.`t1`.`b` = `test`.`t3`.`e` and (`test`.`t2`.`d`) >= `test`.`t3`.`e`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t2`.`c` and (<`test`.`t2`.`d`,`test`.`t1`.`b`>((`test`.`t2`.`d`,(/* select#3 */ select `test`.`t3`.`e` from `test`.`t3` where `test`.`t1`.`b` = `test`.`t3`.`e` and (`test`.`t2`.`d`) >= `test`.`t3`.`e`)))) select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); a @@ -1610,9 +1610,9 @@ A.t1field IN (SELECT C.t2field FROM t2 C WHERE C.t2field IN (SELECT D.t2field FROM t2 D)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY A index PRIMARY PRIMARY 4 NULL 3 Using index -1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; Start temporary; End temporary -1 PRIMARY C index PRIMARY PRIMARY 4 NULL 3 Using where; Using index; Using join buffer (flat, BNL join) +1 PRIMARY C eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index 1 PRIMARY D eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index +1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; Start temporary; End temporary SELECT * FROM t1 A WHERE A.t1field IN (SELECT A.t1field FROM t2 B) AND @@ -2178,10 +2178,10 @@ INSERT INTO t5 VALUES (7,0),(9,0); explain SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; Start temporary 1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where -1 PRIMARY t4 ALL NULL NULL NULL NULL 3 FirstMatch(t5) -1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 +1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; End temporary; Using join buffer (flat, BNL join) SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); a 0 diff --git a/mysql-test/main/subselect_sj2.result b/mysql-test/main/subselect_sj2.result index 6643aa13f83..52925aa030a 100644 --- a/mysql-test/main/subselect_sj2.result +++ b/mysql-test/main/subselect_sj2.result @@ -131,9 +131,8 @@ set join_buffer_size= @save_join_buffer_size; set max_heap_table_size= @save_max_heap_table_size; explain select * from t1 where a in (select b from t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 index b b 5 NULL 20 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t2 ref b b 5 test.t1.a 1 Using index; FirstMatch(t1) select * from t1; a b 1 1 @@ -840,9 +839,9 @@ SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 const PRIMARY PRIMARY 4 const # Using index -1 PRIMARY alias2 index f12 f12 7 NULL # Using index; LooseScan -1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index; FirstMatch(alias2) -1 PRIMARY t3 ALL NULL NULL NULL NULL # Using where; Using join buffer (flat, BNL join) +1 PRIMARY alias2 index f12 f12 7 NULL # Using index; Start temporary +1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index +1 PRIMARY t3 ALL NULL NULL NULL NULL # Using where; End temporary; Using join buffer (flat, BNL join) SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); f12 diff --git a/mysql-test/main/subselect_sj2_jcl6.result b/mysql-test/main/subselect_sj2_jcl6.result index 83abb68ca51..0539ab03a84 100644 --- a/mysql-test/main/subselect_sj2_jcl6.result +++ b/mysql-test/main/subselect_sj2_jcl6.result @@ -142,9 +142,8 @@ set join_buffer_size= @save_join_buffer_size; set max_heap_table_size= @save_max_heap_table_size; explain select * from t1 where a in (select b from t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 index b b 5 NULL 20 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t2 ref b b 5 test.t1.a 1 Using index; FirstMatch(t1) select * from t1; a b 1 1 @@ -853,9 +852,9 @@ SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 const PRIMARY PRIMARY 4 const # Using index -1 PRIMARY alias2 index f12 f12 7 NULL # Using index; LooseScan -1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index; FirstMatch(alias2) -1 PRIMARY t3 ALL NULL NULL NULL NULL # Using where; Using join buffer (flat, BNL join) +1 PRIMARY alias2 index f12 f12 7 NULL # Using index; Start temporary +1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index; Using join buffer (flat, BNL join) +1 PRIMARY t3 hash_ALL NULL #hash#$hj 3 test.alias2.f12 # Using where; End temporary; Using join buffer (incremental, BNLH join) SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); f12 @@ -924,9 +923,9 @@ SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a WHERE t3.b IN (SELECT b FROM t4); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 1 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 1 PRIMARY t2 hash_ALL NULL #hash#$hj 4 test.t3.a 1 Using where; Using join buffer (flat, BNLH join) 1 PRIMARY ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 2 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 3 DERIVED t1 ALL NULL NULL NULL NULL 1 SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a @@ -1238,9 +1237,9 @@ explain SELECT * FROM t1, t3 WHERE t3_c IN ( SELECT t1_pk2 FROM t4, t2 WHERE t2_c = t1_pk2 AND t2_i >= t3_i ) AND ( t1_pk1 = 'POL' ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ref PRIMARY PRIMARY 5 const 1 Using where; Using index -1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Start temporary; Using join buffer (flat, BNL join) -1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join) -1 PRIMARY t4 hash_index NULL #hash#$hj:PRIMARY 54:59 test.t3.t3_c 2 Using where; Using index; End temporary; Using join buffer (incremental, BNLH join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY t4 hash_index NULL #hash#$hj:PRIMARY 54:59 test.t2.t2_c 2 Using where; Using index; Using join buffer (incremental, BNLH join) +1 PRIMARY t3 hash_ALL NULL #hash#$hj 38 test.t2.t2_c 2 Using where; End temporary; Using join buffer (incremental, BNLH join) DROP TABLE t1,t2,t3,t4; # # MDEV-6263: Wrong result when using IN subquery with order by diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result index 5d7e7d49da2..024cfb53960 100644 --- a/mysql-test/main/subselect_sj2_mat.result +++ b/mysql-test/main/subselect_sj2_mat.result @@ -133,9 +133,8 @@ set join_buffer_size= @save_join_buffer_size; set max_heap_table_size= @save_max_heap_table_size; explain select * from t1 where a in (select b from t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 index b b 5 NULL 20 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t2 ref b b 5 test.t1.a 1 Using index; FirstMatch(t1) select * from t1; a b 1 1 @@ -842,9 +841,9 @@ SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 const PRIMARY PRIMARY 4 const # Using index -1 PRIMARY alias2 index f12 f12 7 NULL # Using index; LooseScan -1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index; FirstMatch(alias2) -1 PRIMARY t3 ALL NULL NULL NULL NULL # Using where; Using join buffer (flat, BNL join) +1 PRIMARY alias2 index f12 f12 7 NULL # Using index; Start temporary +1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index +1 PRIMARY t3 ALL NULL NULL NULL NULL # Using where; End temporary; Using join buffer (flat, BNL join) SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); f12 @@ -1511,8 +1510,7 @@ t3.sack_id = 33479 AND t3.kit_id = 6; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ref PRIMARY PRIMARY 5 const,const 5 Using index 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.cat_id 1 Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t4 index cat_id cat_id 4 NULL 19 Using index +1 PRIMARY t4 ref cat_id cat_id 4 test.t3.cat_id 1 Using index; FirstMatch(t1) SELECT count(*) FROM t1, t3 WHERE t1.cat_id = t3.cat_id AND t3.cat_id IN (SELECT cat_id FROM t4) AND @@ -1838,16 +1836,15 @@ explain SELECT t2.id FROM t2,t1 WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 30 Using index -1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where -2 MATERIALIZED t3 ALL NULL NULL NULL NULL 14 -2 MATERIALIZED t1 eq_ref PRIMARY PRIMARY 4 test.t3.id 1 Using index +1 PRIMARY t3 ALL NULL NULL NULL NULL 14 Using where; Start temporary +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.ref_id 1 Using where; Using index +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.id 1 Using index; End temporary +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.ref_id 1 Using where; Using index SELECT t2.id FROM t2,t1 WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id; id -10 11 +10 set optimizer_switch='materialization=off'; SELECT t2.id FROM t2,t1 WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id; @@ -1946,17 +1943,17 @@ AND t3.id_product IN (SELECT id_product FROM t2 t2_5 WHERE t2_5.id_t2 = 29 OR t2 id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 18 Using index 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where 1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using where; Using index; Using join buffer (flat, BNL join) +1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where +1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using where; Using index; Using join buffer (flat, BNL join) 3 MATERIALIZED t2_2 ref id_t2,id_product id_t2 5 const 12 -2 MATERIALIZED t2_1 ALL id_t2,id_product NULL NULL NULL 223 Using where -4 MATERIALIZED t2_3 range id_t2,id_product id_t2 5 NULL 33 Using index condition; Using where 5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where +4 MATERIALIZED t2_3 range id_t2,id_product id_t2 5 NULL 33 Using index condition; Using where +2 MATERIALIZED t2_1 ALL id_t2,id_product NULL NULL NULL 223 Using where 6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where set optimizer_switch='rowid_filter=default'; drop table t1,t2,t3,t4,t5; diff --git a/mysql-test/main/subselect_sj_jcl6.result b/mysql-test/main/subselect_sj_jcl6.result index d1f8080bfaa..a782280da96 100644 --- a/mysql-test/main/subselect_sj_jcl6.result +++ b/mysql-test/main/subselect_sj_jcl6.result @@ -171,26 +171,26 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY s47 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) 1 PRIMARY s48 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) 1 PRIMARY s49 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m00 ALL NULL NULL NULL NULL 3 Using where -2 DEPENDENT SUBQUERY m01 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY m02 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m03 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m04 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m05 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m06 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m07 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m08 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m09 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m10 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m11 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m12 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m13 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m14 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m15 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m16 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m17 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m18 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -2 DEPENDENT SUBQUERY m19 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m00 ALL NULL NULL NULL NULL 3 +2 MATERIALIZED m01 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +2 MATERIALIZED m02 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m03 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m04 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m05 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m06 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m07 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m08 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m09 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m10 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m11 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m12 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m13 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m14 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m15 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m16 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m17 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m18 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +2 MATERIALIZED m19 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) where t1.a < 5; @@ -355,8 +355,8 @@ WHERE PNUM IN (SELECT PNUM FROM PROJ)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY STAFF ALL NULL NULL NULL NULL 5 -1 PRIMARY PROJ ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join) -1 PRIMARY WORKS ALL NULL NULL NULL NULL 12 Using where; FirstMatch(STAFF); Using join buffer (incremental, BNL join) +1 PRIMARY PROJ ALL NULL NULL NULL NULL 6 Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY WORKS ALL NULL NULL NULL NULL 12 Using where; End temporary; Using join buffer (incremental, BNL join) SELECT EMPNUM, EMPNAME FROM STAFF WHERE EMPNUM IN @@ -1621,9 +1621,9 @@ A.t1field IN (SELECT C.t2field FROM t2 C WHERE C.t2field IN (SELECT D.t2field FROM t2 D)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY A index PRIMARY PRIMARY 4 NULL 3 Using index -1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(A); Using join buffer (flat, BNL join) -1 PRIMARY C index PRIMARY PRIMARY 4 NULL 3 Using where; Using index; Using join buffer (incremental, BNL join) +1 PRIMARY C eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index 1 PRIMARY D eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index +1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(D); Using join buffer (flat, BNL join) SELECT * FROM t1 A WHERE A.t1field IN (SELECT A.t1field FROM t2 B) AND @@ -2189,10 +2189,10 @@ INSERT INTO t5 VALUES (7,0),(9,0); explain SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where -1 PRIMARY t4 ALL NULL NULL NULL NULL 3 FirstMatch(t5) -1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; Start temporary +1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; End temporary; Using join buffer (incremental, BNL join) SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); a 0 diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result index b5f5099593d..4c88d3a78f1 100644 --- a/mysql-test/main/subselect_sj_mat.result +++ b/mysql-test/main/subselect_sj_mat.result @@ -380,7 +380,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where 5 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where -5 MATERIALIZED t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 75.00 Using where; Using index; Using join buffer (flat, BNL join) +5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: @@ -405,7 +405,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 5 MATERIALIZED t3c ALL NULL NULL NULL NULL 4 100.00 Using where -5 MATERIALIZED t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 75.00 Using where; Using index; Using join buffer (flat, BNL join) +5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3c.c1,test.t3c.c2 1 100.00 Using index 4 MATERIALIZED t3b ALL NULL NULL NULL NULL 4 100.00 Using where 3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: @@ -439,7 +439,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY eq_ref distinct_key # # # 1 100.00 # 2 MATERIALIZED t2 ALL NULL # # # 5 100.00 # 5 MATERIALIZED t3 ALL NULL # # # 4 100.00 # -5 MATERIALIZED t2i index it2i1,it2i2,it2i3 # # # 5 75.00 # +5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # 4 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 3 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 7 UNION t1i range it1i1,it1i2,it1i3 # # # 3 100.00 # @@ -475,7 +475,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where -4 MATERIALIZED t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 75.00 Using where; Using index; Using join buffer (flat, BNL join) +4 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -499,7 +499,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where -4 MATERIALIZED t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 75.00 Using where; Using index; Using join buffer (flat, BNL join) +4 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -2283,8 +2283,8 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY sq1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 -2 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 # this checks the result set above set optimizer_switch= 'materialization=off,semijoin=off'; @@ -2317,8 +2317,8 @@ WHERE EXISTS ( SELECT * FROM t2, t3 WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 index i2 i2 5 NULL 3 100.00 Using where; Using index 2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00 Warnings: @@ -2356,8 +2356,8 @@ SELECT pk, f1, ( SELECT COUNT(*) FROM t2 WHERE t1.pk IN ( SELECT f2 FROM t2 ) ) AS sq FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join) 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Warnings: Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 @@ -2504,8 +2504,8 @@ alter table t1 add key(id); explain SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index id id 4 NULL 9 Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY ALL distinct_key NULL NULL NULL 3 +1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); 1 @@ -2561,8 +2561,8 @@ INSERT INTO t2 VALUES (11,11),(12,12),(13,13); CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2; explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index id id 4 NULL 9 Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY ALL distinct_key NULL NULL NULL 3 +1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); 1 diff --git a/mysql-test/main/table_elim.result b/mysql-test/main/table_elim.result index 4da85c4a9ca..4b9956a4e48 100644 --- a/mysql-test/main/table_elim.result +++ b/mysql-test/main/table_elim.result @@ -563,9 +563,9 @@ JOIN t5 ON t4.f3 ON t3.f1 = t5.f5 ON t2.f4 = t3.f4 WHERE t3.f2 ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where +1 SIMPLE t2 ref f4 f4 1003 test.t3.f4 2 Using where 1 SIMPLE t5 ref f5 f5 5 test.t3.f1 2 Using where; Using index 1 SIMPLE t4 ALL NULL NULL NULL NULL 3 Using where -1 SIMPLE t2 ALL f4 NULL NULL NULL 11 Using where; Using join buffer (flat, BNL join) # ^^ The above must not produce a QEP of t3,t5,t2,t4 # as that violates the "no interleaving of outer join nests" rule. DROP TABLE t1,t2,t3,t4,t5; diff --git a/mysql-test/main/type_time_6065.result b/mysql-test/main/type_time_6065.result index 56de96870b6..5df612e3001 100644 --- a/mysql-test/main/type_time_6065.result +++ b/mysql-test/main/type_time_6065.result @@ -2267,8 +2267,8 @@ outr.col_varchar_key IS NULL ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY outr system col_datetime_key NULL NULL NULL 1 100.00 +1 PRIMARY outr2 index col_time_key col_time_key 4 NULL 20 100.00 Using where; Using index 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -1 PRIMARY outr2 index col_time_key col_time_key 4 NULL 20 100.00 Using where; Using index; Using join buffer (flat, BNL join) 2 MATERIALIZED innr ref col_int_key col_int_key 4 const 2 100.00 Using where Warnings: Note 1003 select 1 AS `col_int_nokey` from `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where `test`.`innr`.`col_int_key` = 1 and `test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey` and `test`.`outr2`.`col_time_key` > '2001-11-04 19:07:55' diff --git a/mysql-test/main/union.result b/mysql-test/main/union.result index a089ca43edd..aab13d191a4 100644 --- a/mysql-test/main/union.result +++ b/mysql-test/main/union.result @@ -565,7 +565,7 @@ explain (select * from t1 where a=1 and b=10) union (select straight_join t1.a,t id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2 UNION t1 index PRIMARY PRIMARY 4 NULL 4 Using index -2 UNION t2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index; Using join buffer (flat, BNL join) +2 UNION t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index NULL UNION RESULT ALL NULL NULL NULL NULL NULL set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity,@@optimizer_switch=@save_optimizer_switch; explain (select * from t1 where a=1) union (select * from t1 where b=1); diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index 3383d4b6826..d390b395d28 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -3290,8 +3290,8 @@ EXPLAIN SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t2 index NULL PRIMARY 4 NULL 1 Using index; FirstMatch(t1); Using join buffer (incremental, BNL join) +1 PRIMARY t2 index NULL PRIMARY 4 NULL 1 Using index; Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (incremental, BNL join) SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); b 1 diff --git a/mysql-test/suite/maria/mrr.result b/mysql-test/suite/maria/mrr.result index cc42f81e3c4..066f1a50aab 100644 --- a/mysql-test/suite/maria/mrr.result +++ b/mysql-test/suite/maria/mrr.result @@ -404,8 +404,8 @@ FROM t1 AS table1, t2 AS table2 WHERE table1.col_varchar_1024_latin1_key = table2.col_varchar_10_latin1 AND table1.pk<>0 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE table2 ALL NULL NULL NULL NULL 2 -1 SIMPLE table1 ALL PRIMARY,col_varchar_1024_latin1_key NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +1 SIMPLE table2 ALL NULL NULL NULL NULL 2 Using where +1 SIMPLE table1 ref PRIMARY,col_varchar_1024_latin1_key col_varchar_1024_latin1_key 1027 test.table2.col_varchar_10_latin1 2 Using index condition(BKA); Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan SELECT count(*) FROM t1 AS table1, t2 AS table2 WHERE diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result index 301c9defb6d..16e4e9f1ce1 100644 --- a/mysql-test/suite/vcol/r/vcol_select_myisam.result +++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result @@ -73,8 +73,8 @@ a b c 1 -1 -1 explain select * from t1 where c in (select c from t3 where c between -2 and -1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 range c c 5 NULL 2 Using where; Using index -1 PRIMARY t1 ref c c 5 test.t3.c 2 +1 PRIMARY t1 range c c 5 NULL 3 Using index condition +1 PRIMARY t3 eq_ref c c 5 test.t1.c 1 Using index # select_type=UNION, type=system # select_type=UNION RESULT, type= select * from t1 union select * from t2; diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc index 6dd54d259c0..8e723036b97 100644 --- a/sql/opt_trace.cc +++ b/sql/opt_trace.cc @@ -677,6 +677,10 @@ void print_final_join_order(JOIN *join) for (j= join->join_tab,i=0 ; i < join->top_join_tab_count; i++, j++) best_order.add_table_name(j); + best_order.end(); + + /* Write information about the resulting join */ + join_order.add("cost", join->best_read); } diff --git a/sql/rowid_filter.cc b/sql/rowid_filter.cc index 22e46c3f42d..8cd2a5aeddb 100644 --- a/sql/rowid_filter.cc +++ b/sql/rowid_filter.cc @@ -23,7 +23,6 @@ #include "opt_trace.h" -inline double Range_rowid_filter_cost_info:: lookup_cost(Rowid_filter_container_type cont_type) { diff --git a/sql/rowid_filter.h b/sql/rowid_filter.h index bcafb35d142..2bd21b5db79 100644 --- a/sql/rowid_filter.h +++ b/sql/rowid_filter.h @@ -390,7 +390,7 @@ public: whether usage of the range filter promises some gain. */ -class Range_rowid_filter_cost_info : public Sql_alloc +class Range_rowid_filter_cost_info final: public Sql_alloc { /* The table for which the range filter is to be built (if needed) */ TABLE *table; @@ -430,7 +430,8 @@ public: double build_cost(Rowid_filter_container_type container_type); - inline double lookup_cost(Rowid_filter_container_type cont_type); + double lookup_cost(Rowid_filter_container_type cont_type); + inline double lookup_cost() { return lookup_cost(container_type); } inline double avg_access_and_eval_gain_per_row(Rowid_filter_container_type cont_type); @@ -462,6 +463,8 @@ public: Rowid_filter_container *create_container(); + double get_setup_cost() { return cost_of_building_range_filter; } + double get_lookup_cost(); double get_gain() { return gain; } uint get_key_no() { return key_no; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3c443b56317..0243fe67605 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -83,6 +83,12 @@ */ #define FT_KEYPART (MAX_FIELDS+10) +/* + We assume that when we do hash join, only 10 % rows in the hash will + match the current found row. +*/ +#define HASH_FANOUT 0.1 + const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", "MAYBE_REF","ALL","range","index","fulltext", "ref_or_null","unique_subquery","index_subquery", @@ -7699,7 +7705,7 @@ void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key) @param s Current JOIN_TAB @param with_found_constraint There is a filtering condition on the - current table of type. See below. + current table. See more below. @param use_cond_selectivity Value of optimizer_use_condition_selectivity. If > 1 then use table->cond_selecitivity. @@ -7778,6 +7784,7 @@ static double matching_candidates_in_table(JOIN_TAB *s, if (with_found_constraint) dbl_records-= dbl_records/4; + DBUG_ASSERT(dbl_records <= s->records); /* Ensure we return at least one row if there is any possibility to have a matching row. Having rows >= 1.0 helps ensure that when we calculate @@ -7891,10 +7898,8 @@ best_access_path(JOIN *join, KEYUSE *best_key= 0; uint best_max_key_part= 0; my_bool found_constraint= 0; - double best= DBL_MAX; - double best_time= DBL_MAX; + double best_cost= DBL_MAX; double records= DBL_MAX; - ha_rows records_for_key; double best_filter_cmp_gain; table_map best_ref_depends_map= 0; /* @@ -7912,8 +7917,6 @@ best_access_path(JOIN *join, MY_BITMAP *eq_join_set= &s->table->eq_join_set; KEYUSE *hj_start_key= 0; SplM_plan_info *spl_plan= 0; - Range_rowid_filter_cost_info *filter= 0; - const char* cause= NULL; enum join_type best_type= JT_UNKNOWN, type= JT_UNKNOWN; disable_jbuf= disable_jbuf || idx == join->const_tables; @@ -7946,19 +7949,23 @@ best_access_path(JOIN *join, for (keyuse=s->keyuse ; keyuse->table == table ;) { KEY *keyinfo; + const char *cause= NULL; ulong key_flags; uint key_parts; key_part_map found_part= 0; - key_part_map notnull_part=0; // key parts which won't have NULL in lookup tuple. + /* key parts which won't have NULL in lookup tuple */ + key_part_map notnull_part=0; table_map found_ref= 0; uint key= keyuse->key; - filter= 0; bool ft_key= (keyuse->keypart == FT_KEYPART); /* Bitmap of keyparts where the ref access is over 'keypart=const': */ key_part_map const_part= 0; /* The or-null keypart in ref-or-null access: */ key_part_map ref_or_null_part= 0; key_part_map all_parts= 0; + double startup_cost= s->startup_cost; + double records_after_filter; + Range_rowid_filter_cost_info *filter= 0; if (is_hash_join_key_no(key)) { @@ -8065,11 +8072,15 @@ best_access_path(JOIN *join, */ if (ft_key) { + /* + Calculate an adjusted cost based on how many records are read + This will be later multipled by record_count. + */ + tmp= prev_record_reads(join_positions, idx, found_ref)/record_count; /* Really, there should be records=0.0 (yes!) but 1.0 would be probably safer */ - tmp= prev_record_reads(join_positions, idx, found_ref); records= 1.0; type= JT_FT; trace_access_idx.add("access_type", join_type_str[type]) @@ -8104,7 +8115,12 @@ best_access_path(JOIN *join, tmp= adjust_quick_cost(table->opt_range[key].cost, 1); else tmp= table->file->avg_io_cost(); - tmp*= prev_record_reads(join_positions, idx, found_ref); + /* + Calculate an adjusted cost based on how many records are read + This will be later multipled by record_count. + */ + tmp*= (prev_record_reads(join_positions, idx, found_ref) / + record_count); records=1.0; } else @@ -8137,15 +8153,12 @@ best_access_path(JOIN *join, trace_access_idx.add("used_range_estimates", true); tmp= adjust_quick_cost(table->opt_range[key].cost, table->opt_range[key].rows); - goto got_cost; - } - else - { - /* quick_range couldn't use key! */ - records= (double) s->records/rec; - trace_access_idx.add("used_range_estimates", false) - .add("reason", "not available"); + goto got_cost2; } + /* quick_range couldn't use key! */ + records= (double) s->records/rec; + trace_access_idx.add("used_range_estimates", false) + .add("reason", "not available"); } else { @@ -8193,15 +8206,9 @@ best_access_path(JOIN *join, } } } - /* Limit the number of matched rows */ + /* Calculate the cost of the index access */ tmp= cost_for_index_read(thd, table, key, (ha_rows) records, (ha_rows) s->worst_seeks); - records_for_key= (ha_rows) records; - set_if_smaller(records_for_key, thd->variables.max_seeks_for_key); - keyread_tmp= table->file->keyread_time(key, 1, records_for_key); - got_cost: - tmp= COST_MULT(tmp, record_count); - keyread_tmp= COST_MULT(keyread_tmp, record_count); } } else @@ -8212,7 +8219,8 @@ best_access_path(JOIN *join, /* Use as much key-parts as possible and a uniq key is better than a not unique key - Set tmp to (previous record count) * (records / combination) + Set tmp to the cost of the accessing the expected number of + records. */ if ((found_part & 1) && (!(table->file->index_flags(key, 0, 0) & HA_ONLY_WHOLE_INDEX) || @@ -8375,35 +8383,39 @@ best_access_path(JOIN *join, } } - /* Limit the number of matched rows */ + set_if_smaller(records, (double) s->records); tmp= cost_for_index_read(thd, table, key, (ha_rows) records, (ha_rows) s->worst_seeks); - records_for_key= (ha_rows) records; - set_if_smaller(records_for_key, thd->variables.max_seeks_for_key); - keyread_tmp= table->file->keyread_time(key, 1, records_for_key); - got_cost2: - tmp= COST_MULT(tmp, record_count); - keyread_tmp= COST_MULT(keyread_tmp, record_count); } else { if (!(found_part & 1)) cause= "no predicate for first keypart"; - tmp= best_time; // Do nothing + else + cause= "No full key found"; + trace_access_idx.add("chosen", false).add("cause", cause); + continue; } } - tmp= COST_ADD(tmp, s->startup_cost); - loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp, + got_cost2: + loose_scan_opt.check_ref_access_part2(key, start_key, records, + tmp + startup_cost, found_ref); } /* not ft_key */ - if (records < DBL_MAX && - (found_part & 1) && // start_key->key can be used for index access + if (records == DBL_MAX) // Key not usable + continue; + + startup_cost= s->startup_cost; + records_after_filter= records; + + if ((found_part & 1) && // start_key->key can be used for index access (table->file->index_flags(start_key->key,0,1) & HA_DO_RANGE_FILTER_PUSHDOWN)) { double rows= record_count * records; + double access_cost_factor= MY_MIN(tmp / records, 1.0); /* If we use filter F with selectivity s the the cost of fetching data @@ -8425,7 +8437,6 @@ best_access_path(JOIN *join, Here we have: cost_of_fetching_1_row = tmp/rows cost_of_fetching_1_key_tuple = keyread_tmp/rows - access_cost_factor is the gain we expect for using rowid filter. An access_cost_factor of 1.0 means that keyread_tmp is 0 (using key read is infinitely fast) and the gain for each row when @@ -8450,35 +8461,62 @@ best_access_path(JOIN *join, We cannot use filter with JT_EQ_REF as in this case 'tmp' is number of rows from prev_record_read() and keyread_tmp is 0. These numbers are not usable with rowid filter code. - */ - double access_cost_factor= MY_MIN((rows - keyread_tmp) / rows, 1.0); - if (!(records < s->worst_seeks && - records <= thd->variables.max_seeks_for_key)) - trace_access_idx.add("rowid_filter_skipped", "worst/max seeks clipping"); - else if (access_cost_factor <= 0.0) - trace_access_idx.add("rowid_filter_skipped", "cost_factor <= 0"); - else if (type != JT_EQ_REF) - { - filter= - table->best_range_rowid_filter_for_partial_join(start_key->key, - rows, - access_cost_factor); - if (filter) + */ + filter= + table->best_range_rowid_filter_for_partial_join(start_key->key, rows, + access_cost_factor); + if (filter) + { + double new_cost, new_records; + bool use_filter; + double filter_startup_cost= filter->get_setup_cost(); + double filter_lookup_cost= records * filter->lookup_cost(); + + /* Add cost of checking found rows against filter */ + new_cost= COST_ADD(tmp, filter_lookup_cost); + /* Calculate number of resulting rows after filtering */ + new_records= records * filter->selectivity; + DBUG_ASSERT(new_cost >= 0 && new_records >= 0); + use_filter= ((tmp + records/TIME_FOR_COMPARE) * record_count >= + (new_cost + new_records/TIME_FOR_COMPARE)*record_count + + filter_startup_cost); + + if (thd->trace_started()) { - tmp-= filter->get_adjusted_gain(rows) - filter->get_cmp_gain(rows); - DBUG_ASSERT(tmp >= 0); - trace_access_idx.add("rowid_filter_key", - table->key_info[filter->get_key_no()].name); + Json_writer_object trace_filter(thd, "filter"); + trace_filter.add("rowid_filter_key", + table->key_info[filter->get_key_no()].name). + add("original_found_rows_cost", tmp). + add("new_found_rows_cost", new_cost). + add("orginal_rows", records). + add("new_rows", new_records). + add("filter_startup_cost", filter_startup_cost). + add("filter_lookup_cost", filter_lookup_cost). + add("filter_selectivity", filter->selectivity). + add("filter_used", use_filter); } + if (use_filter) + { + tmp= new_cost; + records_after_filter= new_records; + startup_cost+= filter_startup_cost; + } + else + filter= 0; } } - trace_access_idx.add("rows", records).add("cost", tmp); + tmp= COST_ADD(tmp, records_after_filter/TIME_FOR_COMPARE); + trace_access_idx. + add("rows", records). + add("cond_check_cost",tmp). + add("startup_cost", startup_cost); - if (tmp + 0.0001 < best_time - records/TIME_FOR_COMPARE) + tmp= COST_MULT(tmp, record_count); + tmp= COST_ADD(tmp, startup_cost); + if (tmp + 0.0001 < best_cost) { - trace_access_idx.add("chosen", true); - best_time= COST_ADD(tmp, records/TIME_FOR_COMPARE); - best= tmp; + trace_access_idx.add("cost", tmp).add("chosen", true); + best_cost= tmp; best_records= records; best_key= start_key; best_max_key_part= max_key_part; @@ -8486,12 +8524,11 @@ best_access_path(JOIN *join, best_filter= filter; best_type= type; } - else + else if (thd->trace_started()) { - trace_access_idx.add("chosen", false) + trace_access_idx.add("cost",tmp).add("chosen", false) .add("cause", cause ? cause : "cost"); } - cause= nullptr; } /* for each key */ records= best_records; } @@ -8512,15 +8549,19 @@ best_access_path(JOIN *join, */ if (s->key_start_dependent) key_dependent= s->key_dependent; - /* Add dependencey for sub queries */ + + /* Add dependency for sub queries */ key_dependent|= s->embedded_dependent; - } + + } /* if (s->keyuse) */ + + /* Check that s->key_dependent contains all used_tables found in s->keyuse */ key_dependent&= ~PSEUDO_TABLE_BITS; DBUG_ASSERT((key_dependent & (s->key_dependent | s->embedded_dependent)) == key_dependent); - /* + /* If there is no key to access the table, but there is an equi-join predicate connecting the table with the privious tables then we consider the possibility of using hash join. @@ -8537,25 +8578,48 @@ best_access_path(JOIN *join, (!(s->table->map & join->outer_join) || join->allowed_outer_join_with_cache)) // (2) { - double join_sel= 0.1; - double refills; + double refills, cmp_time; /* Estimate the cost of the hash join access to the table */ double rnd_records= matching_candidates_in_table(s, found_constraint, use_cond_selectivity); - - tmp= s->quick ? s->quick->read_time : s->scan_time(); - double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE; - tmp= COST_ADD(tmp, cmp_time); + /* + The following cost calculation is identical to the cost calculation for + the join cache later on, except for the HASH_FANOUT + */ + if (s->quick) + { + /* + Cost of reading rows through opt_range including comparing the rows + with the attached WHERE clause. + */ + tmp= s->quick->read_time; + } + else + { + tmp= s->scan_time(); + /* + Cost of comparing the found row with the attached WHERE + This is not part of scan_time()! + */ + tmp= COST_ADD(tmp, s->records / TIME_FOR_COMPARE); + } /* We read the table as many times as join buffer becomes full. */ refills= (1.0 + floor((double) cache_record_length(join,idx) * record_count / (double) thd->variables.join_buff_size)); tmp= COST_MULT(tmp, refills); - best_time= COST_ADD(tmp, - COST_MULT((record_count*join_sel) / TIME_FOR_COMPARE, - rnd_records)); - best= tmp; + + /* + Cost of doing the hash lookup and check all matching rows with the + WHERE clause. + We assume here that, thanks to the hash, we don't have to compare all + row combinations, only a HASH_FANOUT (10%) rows in the cache. + */ + cmp_time= (rnd_records * record_count * HASH_FANOUT / TIME_FOR_COMPARE); + tmp= COST_ADD(tmp, cmp_time); + + best_cost= tmp; records= rnd_records; best_key= hj_start_key; best_ref_depends_map= 0; @@ -8565,8 +8629,8 @@ best_access_path(JOIN *join, Json_writer_object trace_access_hash(thd); trace_access_hash.add("type", "hash"); trace_access_hash.add("index", "hj-key"); - trace_access_hash.add("rnd_records", rnd_records); - trace_access_hash.add("cost", best); + trace_access_hash.add("rows", rnd_records); + trace_access_hash.add("cost", best_cost); trace_access_hash.add("chosen", true); } @@ -8606,7 +8670,7 @@ best_access_path(JOIN *join, be used for cases with small datasets, which is annoying. */ Json_writer_object trace_access_scan(thd); - if ((records >= s->found_records || best > s->read_time) && // (1) + if ((records >= s->found_records || best_cost > s->read_time) && // (1) !(best_key && best_key->key == MAX_KEY) && // (2) !(s->quick && s->quick->get_type() != QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX && // (2) @@ -8619,6 +8683,8 @@ best_access_path(JOIN *join, { // Check full join double rnd_records= matching_candidates_in_table(s, found_constraint, use_cond_selectivity); + Range_rowid_filter_cost_info *filter= 0; + DBUG_ASSERT(rnd_records <= s->records); /* Range optimizer never proposes a RANGE if it isn't better @@ -8626,7 +8692,6 @@ best_access_path(JOIN *join, Here we estimate its cost. */ - filter= 0; if (s->quick) { /* @@ -8642,9 +8707,7 @@ best_access_path(JOIN *join, access (see first else-branch below), but we don't take it into account here for range/index_merge access. Find out why this is so. */ - double cmp_time= (s->found_records - rnd_records) / TIME_FOR_COMPARE; - tmp= COST_MULT(record_count, - COST_ADD(s->quick->read_time, cmp_time)); + tmp= COST_MULT(s->quick->read_time, record_count); if ( s->quick->get_type() == QUICK_SELECT_I::QS_TYPE_RANGE) { @@ -8694,34 +8757,52 @@ best_access_path(JOIN *join, type= JT_ALL; } - if ((s->table->map & join->outer_join) || disable_jbuf) // Can't use join cache + if ((s->table->map & join->outer_join) || disable_jbuf) { + double cmp_time; /* Simple scan For each record we have to: - Read the whole table record - - Compare with the current where clause with only fields for the table + - Compare with the current where clause with only fields for the + table - Compare with the full where and skip rows which does not satisfy the join condition */ - double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE; - tmp= COST_MULT(record_count, COST_ADD(tmp,cmp_time)); + /* Calculate cost of checking the attached WHERE */ + cmp_time= s->records/TIME_FOR_COMPARE; + tmp= COST_ADD(tmp, cmp_time); + /* + If this is not the first table we have to compare the rows against + all previous row combinations + */ + if (idx != join->const_tables) + { + /* Calculate cost of checking matched rows against the join cache */ + cmp_time= rnd_records/TIME_FOR_COMPARE; + tmp= COST_ADD(tmp, cmp_time); + /* We do the above for every row in the cache */ + tmp= COST_MULT(tmp, record_count); + } } else { - double refills= (1.0 + floor((double) cache_record_length(join,idx) * - (record_count / - (double) thd->variables.join_buff_size))); + /* Scan trough join cache */ + double cmp_time, refills; + + /* Calculate cost of checking the attached WHERE */ + cmp_time= s->records / TIME_FOR_COMPARE; + tmp= COST_ADD(tmp, cmp_time); + + /* Calculate cost of refills */ + refills= (1.0 + floor((double) cache_record_length(join,idx) * + (record_count / + (double) thd->variables.join_buff_size))); tmp= COST_MULT(tmp, refills); - /* - We don't make full cartesian product between rows in the scanned - table and existing records because we skip all rows from the - scanned table, which does not satisfy join condition when - we read the table (see flush_cached_records for details). Here we - take into account cost to read and skip these records. - */ - double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE; + + /* Cost of compare matching rows against the rows in the join cache */ + cmp_time= (rnd_records * record_count / TIME_FOR_COMPARE); tmp= COST_ADD(tmp, cmp_time); } } @@ -8735,34 +8816,30 @@ best_access_path(JOIN *join, else tmp+= s->startup_cost; - /* - We estimate the cost of evaluating WHERE clause for found records - as record_count * rnd_records / TIME_FOR_COMPARE. This cost plus - tmp give us total cost of using TABLE SCAN - */ - best_filter_cmp_gain= (best_filter ? best_filter->get_cmp_gain(record_count * records) : 0); trace_access_scan.add("resulting_rows", rnd_records); trace_access_scan.add("cost", tmp); - if (best == DBL_MAX || - COST_ADD(tmp, record_count/TIME_FOR_COMPARE*rnd_records) < - (best_key->is_for_hash_join() ? best_time : - COST_ADD(best - best_filter_cmp_gain, - record_count/TIME_FOR_COMPARE*records))) + /* TODO: Document the following if */ + if (best_cost == DBL_MAX || + tmp < + (best_key->is_for_hash_join() ? best_cost : + COST_ADD(best_cost,-best_filter_cmp_gain))) { /* If the table has a range (s->quick is set) make_join_select() will ensure that this will be used */ - best= tmp; + best_cost= tmp; records= rnd_records; best_key= 0; - best_filter= 0; - if (s->quick && s->quick->get_type() == QUICK_SELECT_I::QS_TYPE_RANGE) - best_filter= filter; + /* + filter is only set if + s->quick->get_type() == QUICK_SELECT_I::QS_TYPE_RANGE + */ + best_filter= filter; /* range/index_merge/ALL/index access method are "independent", so: */ best_ref_depends_map= 0; best_uses_jbuf= MY_TEST(!disable_jbuf && !((s->table->map & @@ -8781,7 +8858,7 @@ best_access_path(JOIN *join, /* Update the cost information for the current partial plan */ pos->records_read= records; - pos->read_time= best; + pos->read_time= best_cost; pos->key= best_key; pos->type= best_type; pos->table= s; @@ -10655,14 +10732,11 @@ best_extension_by_limited_search(JOIN *join, partial_join_cardinality= (current_record_count * pushdown_cond_selectivity); - if (unlikely(thd->trace_started())) + if (unlikely(thd->trace_started()) && pushdown_cond_selectivity < 1.0) { - if (pushdown_cond_selectivity < 1.0) - { - trace_one_table.add("selectivity", pushdown_cond_selectivity); - trace_one_table.add("estimated_join_cardinality", - partial_join_cardinality); - } + trace_one_table.add("selectivity", pushdown_cond_selectivity); + trace_one_table.add("estimated_join_cardinality", + partial_join_cardinality); } if ((search_depth > 1) && @@ -14591,6 +14665,9 @@ void JOIN_TAB::cleanup() /** Estimate the time to get rows of the joined table + + Note that this doesn't take into account of checking the WHERE clause + for all found rows (TIME_FOR_COMPARE) */ double JOIN_TAB::scan_time() @@ -29629,7 +29706,7 @@ static bool get_range_limit_read_cost(const JOIN_TAB *tab, range_cond(key_part+1). */ if (kp == table->opt_range[keynr].key_parts) - ref_rows= table->opt_range[keynr].rows; + ref_rows= best_rows; else ref_rows= (ha_rows) table->key_info[keynr].actual_rec_per_key(kp-1); @@ -29794,7 +29871,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, } } else - read_time= table->file->scan_time(); + read_time= table->file->scan_time(); // TODO: Add TIME_FOR_COMPARE trace_cheaper_ordering.add("fanout", fanout); /* @@ -29998,8 +30075,15 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, to calculate the cost of accessing data rows for one index entry. */ - index_scan_time= select_limit/rec_per_key * - MY_MIN(rec_per_key, table->file->scan_time()); +#ifdef NEED_TESTING + index_scan_time= (cost_for_index_read(table->in_use, table, nr, + select_limit, + (ha_rows) tab->worst_seeks) + + select_limit / TIME_FOR_COMPARE); +#else + index_scan_time= (select_limit/rec_per_key * + MY_MIN(rec_per_key, table->file->scan_time())); +#endif double range_scan_time; if (get_range_limit_read_cost(tab, table, table_records, nr, select_limit, &range_scan_time)) diff --git a/storage/connect/mysql-test/connect/r/index.result b/storage/connect/mysql-test/connect/r/index.result index baebf1f1ebe..2197f9bcf1e 100644 --- a/storage/connect/mysql-test/connect/r/index.result +++ b/storage/connect/mysql-test/connect/r/index.result @@ -98,16 +98,16 @@ sexe genre 2 Feminin SELECT nom, prenom, genre FROM t1 NATURAL JOIN t2 LIMIT 10; nom prenom genre -ESCOURCHE BENEDICTE Feminin -VICENTE LAURENCE Feminin NICOLAS ROGER Masculin -TESSEREAU MARIE HELENE Feminin MOGADOR ALAIN Masculin CHAUSSEE ERIC DENIS Masculin MAILLOT GEORGES Masculin -CAMILLE NADINE Feminin BRUYERES JEAN MARC Masculin LONES GERARD Masculin +CROISILLES DOMINIQUE Masculin +SEYSSAUD GERARD Masculin +QUINET OLIVIER Masculin +KOMITAS YVES Masculin # # Another table # diff --git a/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result index 4adfb1bd76a..83ec42044a5 100644 --- a/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result @@ -87,7 +87,7 @@ a b c a connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t0 left join `auto_test_remote`.`ta_r_auto_inc` t1 on (t1.`a` = t0.`a`) left join `auto_test_remote`.`ta_r_3` t2 on (t2.`c` = t1.`c`) left join `auto_test_remote`.`ta_r` t3 on (t3.`b` = t2.`b`) where 1 order by t0.`a` desc +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t0 left join `auto_test_remote`.`ta_r_auto_inc` t1 on ((t1.`a` = t0.`a`) and (t0.`a` is not null)) left join `auto_test_remote`.`ta_r_3` t2 on (t2.`c` = t1.`c`) left join `auto_test_remote`.`ta_r` t3 on ((t3.`b` = t2.`b`) and (t2.`b` is not null)) where 1 order by t0.`a` desc SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result index 438f54f6ce6..ff4f211faf5 100644 --- a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result @@ -87,7 +87,7 @@ NULL NULL NULL 3 connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t1.`c` = t2.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t1.`c` = t2.`c`) and (t0.`a` = t1.`a`) and (t3.`b` is not null) and (t1.`a` is not null)) where 1 order by t3.`a` desc SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result index 5101ea5036a..02f985279f8 100644 --- a/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result @@ -87,7 +87,7 @@ NULL c 2000-01-03 00:00:00 3 connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join `auto_test_remote`.`ta_r_auto_inc` t2 on (t2.`b` = t3.`b`) left join `auto_test_remote`.`ta_r_3` t1 on (t1.`c` = t2.`c`) left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join `auto_test_remote`.`ta_r_auto_inc` t2 on ((t2.`b` = t3.`b`) and (t3.`b` is not null)) left join `auto_test_remote`.`ta_r_3` t1 on (t1.`c` = t2.`c`) left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result index 67d688e1383..840328508fa 100644 --- a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result @@ -87,7 +87,7 @@ NULL c 2000-01-03 00:00:00 3 connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t1.`c` = t2.`c`)) where 1 order by t3.`a` desc +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t1.`c` = t2.`c`) and (t3.`b` is not null)) where 1 order by t3.`a` desc SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') From 2a79abcd126c06522ad9a28eac2437c8cc818b19 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 19 Sep 2022 19:37:57 +0300 Subject: [PATCH 017/123] Fix compile on Windows --- sql/sql_select.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0243fe67605..c4380df16f0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -29698,7 +29698,7 @@ static bool get_range_limit_read_cost(const JOIN_TAB *tab, if (kp > 0) { - ha_rows ref_rows; + double ref_rows; /* Two possible cases: 1. ref(const) uses the same #key parts as range access. @@ -29708,17 +29708,17 @@ static bool get_range_limit_read_cost(const JOIN_TAB *tab, if (kp == table->opt_range[keynr].key_parts) ref_rows= best_rows; else - ref_rows= (ha_rows) table->key_info[keynr].actual_rec_per_key(kp-1); + ref_rows= table->key_info[keynr].actual_rec_per_key(kp-1); if (ref_rows > 0) { double tmp= cost_for_index_read(tab->join->thd, table, keynr, - ref_rows, + (ha_rows) ref_rows, (ha_rows) tab->worst_seeks); if (tmp < best_cost) { best_cost= tmp; - best_rows= (double)ref_rows; + best_rows= ref_rows; } } } From d9d9c90a3dd8e8fb0417bb099a8f1ef9c0608465 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 19 Sep 2022 19:59:00 +0300 Subject: [PATCH 018/123] Fix tests: avoid query plan with identical costs --- mysql-test/main/rowid_filter_innodb.result | 58 +++++++++++++++------- mysql-test/main/selectivity.result | 8 +-- mysql-test/main/selectivity.test | 6 ++- mysql-test/main/selectivity_innodb.result | 8 +-- 4 files changed, 51 insertions(+), 29 deletions(-) diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index c8220e0f5a1..7f42e3a4143 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -2247,8 +2247,8 @@ pk1 a1 b1 pk2 a2 b2 EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 -1 PRIMARY t1 ALL a1,b1 NULL NULL NULL 400 21.56 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where +1 PRIMARY t1 ref|filter a1,b1 a1|b1 5|4 test.t2.a2 36 (29%) 28.75 Using where; Using rowid filter 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t1`.`pk1` + 1 = `test`.`t2`.`pk2` + 2 @@ -2264,23 +2264,30 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 101, - "filtered": 100 + "filtered": 100, + "attached_condition": "t2.a2 is not null" } }, { - "block-nl-join": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "possible_keys": ["a1", "b1"], - "rows": 400, - "filtered": 21.5625, - "attached_condition": "t1.b1 <= (subquery#2)" + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a1", "b1"], + "key": "a1", + "key_length": "5", + "used_key_parts": ["a1"], + "ref": ["test.t2.a2"], + "rowid_filter": { + "range": { + "key": "b1", + "used_key_parts": ["b1"] + }, + "rows": 115, + "selectivity_pct": 28.75 }, - "buffer_type": "flat", - "buffer_size": "1Kb", - "join_type": "BNL", - "attached_condition": "t1.a1 = t2.a2 and t1.pk1 + 1 = t2.pk2 + 2" + "rows": 36, + "filtered": 28.75, + "attached_condition": "t1.b1 <= (subquery#2) and t1.pk1 + 1 = t2.pk2 + 2" } } ], @@ -3692,7 +3699,7 @@ fi.fh in (6311439873746261694,-397087483897438286, id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index 1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where -1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 24 14.46 Using where +1 SIMPLE fi ref|filter filt_aceid,filt_fh filt_aceid|filt_fh 8|8 test.a.id 24 (14%) 14.46 Using where; Using rowid filter Warnings: Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) set statement optimizer_switch='rowid_filter=on' for select t.id, fi.* @@ -3808,7 +3815,7 @@ fi.fh in (6311439873746261694,-397087483897438286, id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index 1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where; Using join buffer (flat, BKA join); Rowid-ordered scan -1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 24 14.46 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan +1 SIMPLE fi ref|filter filt_aceid,filt_fh filt_aceid|filt_fh 8|8 test.a.id 24 (14%) 14.46 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan; Using rowid filter Warnings: Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) set statement optimizer_switch='rowid_filter=on' for select t.id, fi.* @@ -3941,9 +3948,22 @@ ANALYZE "key_length": "8", "used_key_parts": ["aceid"], "ref": ["test.a.id"], + "rowid_filter": { + "range": { + "key": "filt_fh", + "used_key_parts": ["fh"] + }, + "rows": 81, + "selectivity_pct": 14.46428571, + "r_rows": 80, + "r_lookups": 80, + "r_selectivity_pct": 40, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, "r_loops": 1, "rows": 24, - "r_rows": 80, + "r_rows": 32, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 14.46428585, @@ -3954,7 +3974,7 @@ ANALYZE "join_type": "BKA", "mrr_type": "Rowid-ordered scan", "attached_condition": "fi.fh in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)", - "r_filtered": 40 + "r_filtered": 100 } } ] diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index 1dff67e804a..71fce3475bc 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -52,7 +52,7 @@ part, supplier, partsupp, nation, region where p_partkey = ps_partkey and s_suppkey = ps_suppkey -and p_size = 9 +and (p_size = 9 or p_size =19999) and p_type like '%TIN' and s_nationkey = n_nationkey and n_regionkey = r_regionkey @@ -72,8 +72,8 @@ and r_name = 'ASIA' order by s_acctbal desc, n_name, s_name, p_partkey; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 0.50 Using where; Using temporary; Using filesort -1 PRIMARY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using temporary; Using filesort +1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 0.63 Using where; Using join buffer (flat, BNL join) 1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 Using where 1 PRIMARY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where 1 PRIMARY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where @@ -83,7 +83,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.part.p_partkey' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `dbt3_s001`.`supplier`.`s_acctbal` AS `s_acctbal`,`dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`nation`.`n_name` AS `n_name`,`dbt3_s001`.`part`.`p_partkey` AS `p_partkey`,`dbt3_s001`.`part`.`p_mfgr` AS `p_mfgr`,`dbt3_s001`.`supplier`.`s_address` AS `s_address`,`dbt3_s001`.`supplier`.`s_phone` AS `s_phone`,`dbt3_s001`.`supplier`.`s_comment` AS `s_comment` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`part`.`p_size` = 9 and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_type` like '%TIN' and `dbt3_s001`.`partsupp`.`ps_supplycost` = <`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` +Note 1003 /* select#1 */ select `dbt3_s001`.`supplier`.`s_acctbal` AS `s_acctbal`,`dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`nation`.`n_name` AS `n_name`,`dbt3_s001`.`part`.`p_partkey` AS `p_partkey`,`dbt3_s001`.`part`.`p_mfgr` AS `p_mfgr`,`dbt3_s001`.`supplier`.`s_address` AS `s_address`,`dbt3_s001`.`supplier`.`s_phone` AS `s_phone`,`dbt3_s001`.`supplier`.`s_comment` AS `s_comment` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and (`dbt3_s001`.`part`.`p_size` = 9 or `dbt3_s001`.`part`.`p_size` = 19999) and `dbt3_s001`.`part`.`p_type` like '%TIN' and `dbt3_s001`.`partsupp`.`ps_supplycost` = <`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` set optimizer_use_condition_selectivity=4; explain extended select diff --git a/mysql-test/main/selectivity.test b/mysql-test/main/selectivity.test index 4e4513d09d6..88338a01cca 100644 --- a/mysql-test/main/selectivity.test +++ b/mysql-test/main/selectivity.test @@ -67,7 +67,9 @@ customer, lineitem, nation, orders, part, partsupp, region, supplier; --enable_query_log --echo === Q2 === - +# "or p_size =19999" is added to avoid symmetry between +# region (5 rows * 20% selectivity) = 1 and +# part (200 rows * 0.5% selectivity) = 1 set optimizer_use_condition_selectivity=5; explain extended select @@ -77,7 +79,7 @@ from where p_partkey = ps_partkey and s_suppkey = ps_suppkey - and p_size = 9 + and (p_size = 9 or p_size =19999) and p_type like '%TIN' and s_nationkey = n_nationkey and n_regionkey = r_regionkey diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index cdde80cf248..ab79d15c9a1 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -57,7 +57,7 @@ part, supplier, partsupp, nation, region where p_partkey = ps_partkey and s_suppkey = ps_suppkey -and p_size = 9 +and (p_size = 9 or p_size =19999) and p_type like '%TIN' and s_nationkey = n_nationkey and n_regionkey = r_regionkey @@ -77,8 +77,8 @@ and r_name = 'ASIA' order by s_acctbal desc, n_name, s_name, p_partkey; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 0.50 Using where; Using temporary; Using filesort -1 PRIMARY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using temporary; Using filesort +1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 0.63 Using where; Using join buffer (flat, BNL join) 1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where 1 PRIMARY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where 1 PRIMARY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where @@ -88,7 +88,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.part.p_partkey' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `dbt3_s001`.`supplier`.`s_acctbal` AS `s_acctbal`,`dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`nation`.`n_name` AS `n_name`,`dbt3_s001`.`part`.`p_partkey` AS `p_partkey`,`dbt3_s001`.`part`.`p_mfgr` AS `p_mfgr`,`dbt3_s001`.`supplier`.`s_address` AS `s_address`,`dbt3_s001`.`supplier`.`s_phone` AS `s_phone`,`dbt3_s001`.`supplier`.`s_comment` AS `s_comment` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`part`.`p_size` = 9 and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_type` like '%TIN' and `dbt3_s001`.`partsupp`.`ps_supplycost` = <`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` +Note 1003 /* select#1 */ select `dbt3_s001`.`supplier`.`s_acctbal` AS `s_acctbal`,`dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`nation`.`n_name` AS `n_name`,`dbt3_s001`.`part`.`p_partkey` AS `p_partkey`,`dbt3_s001`.`part`.`p_mfgr` AS `p_mfgr`,`dbt3_s001`.`supplier`.`s_address` AS `s_address`,`dbt3_s001`.`supplier`.`s_phone` AS `s_phone`,`dbt3_s001`.`supplier`.`s_comment` AS `s_comment` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and (`dbt3_s001`.`part`.`p_size` = 9 or `dbt3_s001`.`part`.`p_size` = 19999) and `dbt3_s001`.`part`.`p_type` like '%TIN' and `dbt3_s001`.`partsupp`.`ps_supplycost` = <`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` set optimizer_use_condition_selectivity=4; explain extended select From ec6aa2829ab88a3cde697c78355b0478ee0ff337 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 9 Sep 2022 19:09:23 +0300 Subject: [PATCH 019/123] Stabilize main.subselect_sj2* tests --- mysql-test/main/subselect_sj2.result | 10 +++++++--- mysql-test/main/subselect_sj2.test | 1 + mysql-test/main/subselect_sj2_jcl6.result | 10 +++++++--- mysql-test/main/subselect_sj2_mat.result | 10 +++++++--- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/mysql-test/main/subselect_sj2.result b/mysql-test/main/subselect_sj2.result index 52925aa030a..f81540716d1 100644 --- a/mysql-test/main/subselect_sj2.result +++ b/mysql-test/main/subselect_sj2.result @@ -106,11 +106,15 @@ primary key(pk1, pk2) insert into t3 select A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B where B.a <5; +analyze table t3 persistent for all; +Table Op Msg_type Msg_text +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status OK explain select * from t3 where b in (select a from t0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 ALL b NULL NULL NULL # -1 PRIMARY eq_ref distinct_key distinct_key 4 func # -2 MATERIALIZED t0 ALL NULL NULL NULL NULL # +1 PRIMARY ALL distinct_key NULL NULL NULL # +1 PRIMARY t3 ref b b 5 test.t0.a # +2 MATERIALIZED t0 ALL NULL NULL NULL NULL # Using where select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); a b pk1 pk2 0 0 0 0 diff --git a/mysql-test/main/subselect_sj2.test b/mysql-test/main/subselect_sj2.test index 5b9ec409c5d..6c936559ce6 100644 --- a/mysql-test/main/subselect_sj2.test +++ b/mysql-test/main/subselect_sj2.test @@ -87,6 +87,7 @@ insert into t3 select A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B where B.a <5; +analyze table t3 persistent for all; --replace_column 9 # explain select * from t3 where b in (select a from t0); select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); diff --git a/mysql-test/main/subselect_sj2_jcl6.result b/mysql-test/main/subselect_sj2_jcl6.result index 0539ab03a84..10cfc2e2546 100644 --- a/mysql-test/main/subselect_sj2_jcl6.result +++ b/mysql-test/main/subselect_sj2_jcl6.result @@ -117,11 +117,15 @@ primary key(pk1, pk2) insert into t3 select A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B where B.a <5; +analyze table t3 persistent for all; +Table Op Msg_type Msg_text +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status OK explain select * from t3 where b in (select a from t0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 ALL b NULL NULL NULL # -1 PRIMARY eq_ref distinct_key distinct_key 4 func # -2 MATERIALIZED t0 ALL NULL NULL NULL NULL # +1 PRIMARY ALL distinct_key NULL NULL NULL # +1 PRIMARY t3 ref b b 5 test.t0.a # Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +2 MATERIALIZED t0 ALL NULL NULL NULL NULL # Using where select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); a b pk1 pk2 0 0 0 0 diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result index 024cfb53960..4b269619102 100644 --- a/mysql-test/main/subselect_sj2_mat.result +++ b/mysql-test/main/subselect_sj2_mat.result @@ -108,11 +108,15 @@ primary key(pk1, pk2) insert into t3 select A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B where B.a <5; +analyze table t3 persistent for all; +Table Op Msg_type Msg_text +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status OK explain select * from t3 where b in (select a from t0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 ALL b NULL NULL NULL # -1 PRIMARY eq_ref distinct_key distinct_key 4 func # -2 MATERIALIZED t0 ALL NULL NULL NULL NULL # +1 PRIMARY ALL distinct_key NULL NULL NULL # +1 PRIMARY t3 ref b b 5 test.t0.a # +2 MATERIALIZED t0 ALL NULL NULL NULL NULL # Using where select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); a b pk1 pk2 0 0 0 0 From 766bae2b3116bb0805e3448dbfcfa892bb6cb707 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 20 Jan 2022 15:49:01 +0200 Subject: [PATCH 020/123] Make trace.add() usage uniform - Before any multiple add() calls, always use (if trace_started()). - Add unlikely() around all tests of trace_started(). - Change trace.add(); trace.add(); to trace.add().add(); - When trace.add() goes over several line, use the following formating: trace. add(xxx). add(yyy). add(zzz); This format was choosen after a discussion between Sergei Petrunia and me as it looks similar indepedent if 'trace' is an object or a pointer. It also more suitable for an editors auto-indentation. Other things: Added DBUG_ASSERT(thd->trace_started()) to a few functions that should only be called if trace is enabled. "use_roworder_index_merge: true" changed to "use_sort_index_merge: false" As the original output was often not correct. Also fixed the related 'cause' to be correct. In best_access_path() print the cost (and number of rows) before checking if it the plan should be used. This removes the need to print the cost in two places. Changed a few "read_time" tags to "cost". --- mysql-test/main/opt_trace.result | 23 +- .../main/opt_trace_index_merge_innodb.result | 1 + mysql-test/main/opt_trace_selectivity.result | 6 + sql/opt_range.cc | 328 +++++++++++------- sql/opt_split.cc | 23 +- sql/opt_subselect.cc | 35 +- sql/opt_trace.cc | 23 +- sql/rowid_filter.cc | 9 +- sql/sql_select.cc | 194 +++++++---- sql/sql_test.cc | 19 +- sql/sql_tvc.cc | 18 +- 11 files changed, 429 insertions(+), 250 deletions(-) diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index c859c1de513..331021b1948 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -1117,6 +1117,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "rows": 1, "cond_check_cost": 2.200585794, "startup_cost": 0, + "rows_after_filter": 1, "cost": 220.0585794, "chosen": true }, @@ -1166,6 +1167,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "rows": 1, "cond_check_cost": 2.200585794, "startup_cost": 0, + "rows_after_filter": 1, "cost": 220.0585794, "chosen": true }, @@ -2265,6 +2267,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "rows": 180, "cond_check_cost": 216.2743776, "startup_cost": 0, + "rows_after_filter": 180, "cost": 216.2743776, "chosen": true }, @@ -2275,6 +2278,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "rows": 21, "cond_check_cost": 25.34242739, "startup_cost": 0, + "rows_after_filter": 21, "cost": 25.34242739, "chosen": true }, @@ -2724,6 +2728,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { "rows": 1, "cond_check_cost": 1.2, "startup_cost": 0, + "rows_after_filter": 1, "cost": 4.8, "chosen": true }, @@ -3253,7 +3258,7 @@ explain extended select * from t1 where a in (select pk from t10) { { "strategy": "SJ-Materialization", "records": 3, - "read_time": 7.878564453 + "cost": 7.878564453 }, { "strategy": "DuplicateWeedout", @@ -3628,6 +3633,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "rows": 1, "cond_check_cost": 1.325585794, "startup_cost": 0, + "rows_after_filter": 1, "cost": 1.325585794, "chosen": true }, @@ -3638,6 +3644,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "rows": 1, "cond_check_cost": 1.325829876, "startup_cost": 0, + "rows_after_filter": 1, "cost": 1.325829876, "chosen": false, "cause": "cost" @@ -3649,6 +3656,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "rows": 1, "cond_check_cost": 0.326073957, "startup_cost": 0, + "rows_after_filter": 1, "cost": 0.326073957, "chosen": true }, @@ -4341,6 +4349,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "rows": 1, "cond_check_cost": 1.200585794, "startup_cost": 0, + "rows_after_filter": 1, "cost": 3.601757383, "chosen": true }, @@ -4390,6 +4399,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "rows": 2, "cond_check_cost": 1.401171589, "startup_cost": 0, + "rows_after_filter": 2, "cost": 4.203514767, "chosen": true }, @@ -5080,7 +5090,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "strategy": "SJ-Materialization", "records": 3, - "read_time": 10.81538086 + "cost": 10.81538086 }, { "strategy": "DuplicateWeedout", @@ -7976,7 +7986,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "strategy": "SJ-Materialization", "records": 27, - "read_time": 32.34101562 + "cost": 32.34101562 }, { "strategy": "DuplicateWeedout", @@ -8098,7 +8108,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "strategy": "SJ-Materialization", "records": 27, - "read_time": 46.86152344 + "cost": 46.86152344 }, { "strategy": "DuplicateWeedout", @@ -8395,7 +8405,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "strategy": "SJ-Materialization", "records": 3, - "read_time": 16.52563477 + "cost": 16.52563477 }, { "strategy": "DuplicateWeedout", @@ -9539,6 +9549,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "rows": 1, "cond_check_cost": 2.200585794, "startup_cost": 0, + "rows_after_filter": 1, "cost": 22.00585794, "chosen": true }, @@ -9769,6 +9780,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "rows": 1, "cond_check_cost": 2.200585794, "startup_cost": 0, + "rows_after_filter": 1, "cost": 22.00585794, "chosen": true }, @@ -10408,6 +10420,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "rows": 1.8367, "cond_check_cost": 2.367925794, "startup_cost": 0, + "rows_after_filter": 1.8367, "cost": 2.367925794, "chosen": true }, diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result index 0ce74504b13..495ade7cd32 100644 --- a/mysql-test/main/opt_trace_index_merge_innodb.result +++ b/mysql-test/main/opt_trace_index_merge_innodb.result @@ -214,6 +214,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "rows": 1, "cond_check_cost": 1.325146475, "startup_cost": 0, + "rows_after_filter": 1, "cost": 1.325146475, "chosen": true }, diff --git a/mysql-test/main/opt_trace_selectivity.result b/mysql-test/main/opt_trace_selectivity.result index 86290a631fd..44f4ad9bb90 100644 --- a/mysql-test/main/opt_trace_selectivity.result +++ b/mysql-test/main/opt_trace_selectivity.result @@ -51,6 +51,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "rows": 104, "cond_check_cost": 124.96562, "startup_cost": 0, + "rows_after_filter": 104, "cost": 124.96562, "chosen": true }, @@ -61,6 +62,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "rows": 340, "cond_check_cost": 408.2577963, "startup_cost": 0, + "rows_after_filter": 340, "cost": 408.2577963, "chosen": false, "cause": "cost" @@ -72,6 +74,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "rows": 632, "cond_check_cost": 758.7718449, "startup_cost": 0, + "rows_after_filter": 632, "cost": 758.7718449, "chosen": false, "cause": "cost" @@ -145,6 +148,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "rows": 6, "cond_check_cost": 7.327343464, "startup_cost": 0, + "rows_after_filter": 6, "cost": 7.327343464, "chosen": true }, @@ -155,6 +159,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "rows": 232, "cond_check_cost": 278.6156139, "startup_cost": 0, + "rows_after_filter": 232, "cost": 278.6156139, "chosen": false, "cause": "cost" @@ -166,6 +171,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "rows": 293, "cond_check_cost": 351.8394392, "startup_cost": 0, + "rows_after_filter": 293, "cost": 351.8394392, "chosen": false, "cause": "cost" diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c3850d740cd..e540f7adc6a 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2294,9 +2294,11 @@ void TRP_RANGE::trace_basic_info(PARAM *param, const KEY &cur_key= param->table->key_info[keynr_in_table]; const KEY_PART_INFO *key_part= cur_key.key_part; - trace_object->add("type", "range_scan") - .add("index", cur_key.name) - .add("rows", records); + if (unlikely(trace_object->trace_started())) + trace_object-> + add("type", "range_scan"). + add("index", cur_key.name). + add("rows", records); Json_writer_array trace_range(param->thd, "ranges"); @@ -2500,11 +2502,13 @@ void TRP_GROUP_MIN_MAX::trace_basic_info(PARAM *param, else trace_object->add_null("min_max_arg"); - trace_object->add("min_aggregate", have_min) - .add("max_aggregate", have_max) - .add("distinct_aggregate", have_agg_distinct) - .add("rows", records) - .add("cost", read_cost); + if (unlikely(trace_object->trace_started())) + trace_object-> + add("min_aggregate", have_min). + add("max_aggregate", have_max). + add("distinct_aggregate", have_agg_distinct). + add("rows", records). + add("cost", read_cost); const KEY_PART_INFO *key_part= index_info->key_part; { @@ -2734,6 +2738,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, table_info.add_table_name(head); Json_writer_object trace_range(thd, "range_analysis"); + if (unlikely(thd->trace_started())) { Json_writer_object table_rec(thd, "table_scan"); table_rec.add("rows", records).add("cost", read_time); @@ -2807,8 +2812,10 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, if (!keys_to_use.is_set(idx)) { - trace_idx_details.add("usable", false) - .add("cause", "not applicable"); + if (unlikely(trace_idx_details.trace_started())) + trace_idx_details. + add("usable", false). + add("cause", "not applicable"); continue; } if (key_info->flags & HA_FULLTEXT) @@ -2873,10 +2880,14 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, read_time= key_read_time; chosen= TRUE; } - trace_cov.add("index", head->key_info[key_for_use].name) - .add("cost", key_read_time).add("chosen", chosen); - if (!chosen) - trace_cov.add("cause", "cost"); + if (unlikely(trace_cov.trace_started())) + { + trace_cov. + add("index", head->key_info[key_for_use].name). + add("cost", key_read_time).add("chosen", chosen); + if (!chosen) + trace_cov.add("cause", "cost"); + } } double best_read_time= read_time; @@ -3091,9 +3102,10 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, Json_writer_object trace_range_plan(thd, "range_access_plan"); best_trp->trace_basic_info(¶m, &trace_range_plan); } - trace_range_summary.add("rows_for_plan", quick->records) - .add("cost_for_plan", quick->read_time) - .add("chosen", true); + trace_range_summary. + add("rows_for_plan", quick->records). + add("cost_for_plan", quick->read_time). + add("chosen", true); } free_root(&alloc,MYF(0)); // Return memory & allocator @@ -3507,11 +3519,12 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) */ table->multiply_cond_selectivity(quick_cond_selectivity); + if (unlikely(thd->trace_started())) { Json_writer_object selectivity_for_index(thd); - selectivity_for_index.add("index_name", key_info->name) - .add("selectivity_from_index", - quick_cond_selectivity); + selectivity_for_index. + add("index_name", key_info->name). + add("selectivity_from_index", quick_cond_selectivity); } /* We need to set selectivity for fields supported by indexes. @@ -3549,10 +3562,13 @@ end_of_range_loop: quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_UNION || quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE || quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT)); - Json_writer_object selectivity_for_index(thd); table->cond_selectivity= original_selectivity; - selectivity_for_index.add("use_opt_range_condition_rows_selectivity", - original_selectivity); + if (unlikely(thd->trace_started())) + { + Json_writer_object selectivity_for_index(thd); + selectivity_for_index.add("use_opt_range_condition_rows_selectivity", + original_selectivity); + } } selectivity_for_indexes.end(); @@ -3625,8 +3641,10 @@ end_of_range_loop: { rows= 0; table->reginfo.impossible_range= 1; - selectivity_for_column.add("selectivity_from_histogram", rows); - selectivity_for_column.add("cause", "impossible range"); + if (unlikely(selectivity_for_column.trace_started())) + selectivity_for_column. + add("selectivity_from_histogram", rows). + add("cause", "impossible range"); goto free_alloc; } else @@ -5269,9 +5287,10 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, } else non_cpk_scan_records += (*cur_child)->records; - trace_idx.add("index_to_merge", - param->table->key_info[keynr_in_table].name) - .add("cumulated_cost", imerge_cost); + if (unlikely(trace_idx.trace_started())) + trace_idx. + add("index_to_merge", param->table->key_info[keynr_in_table].name). + add("cumulated_cost", imerge_cost); } to_merge.end(); @@ -5303,9 +5322,10 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_UNION)) { roru_read_plans= (TABLE_READ_PLAN**)range_scans; - trace_best_disjunct.add("use_roworder_union", true) - .add("cause", - "always cheaper than non roworder retrieval"); + if (unlikely(trace_best_disjunct.trace_started())) + trace_best_disjunct. + add("use_roworder_union", true). + add("cause", "always cheaper than non roworder retrieval"); goto skip_to_ror_scan; } @@ -5326,16 +5346,21 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, { double sweep_cost= get_sweep_read_cost(param, non_cpk_scan_records); imerge_cost+= sweep_cost; - trace_best_disjunct.add("cost_sort_rowid_and_read_disk", sweep_cost); + trace_best_disjunct. + add("records", non_cpk_scan_records). + add("cost_sort_rowid_and_read_disk", sweep_cost). + add("cost", imerge_cost); } DBUG_PRINT("info",("index_merge cost with rowid-to-row scan: %g", imerge_cost)); if (imerge_cost > read_time || !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION)) { - trace_best_disjunct.add("use_roworder_index_merge", true); - trace_best_disjunct.add("cause", "cost"); - goto build_ror_index_merge; + if (unlikely(trace_best_disjunct.trace_started())) + trace_best_disjunct. + add("use_sort_index_merge", false). + add("cause", imerge_cost > read_time ? "cost" : "disabled"); + goto build_ror_index_merge; // Try roworder_index_merge } /* Add Unique operations cost */ @@ -5359,8 +5384,10 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, TIME_FOR_COMPARE_ROWID, FALSE, NULL); imerge_cost+= dup_removal_cost; - trace_best_disjunct.add("cost_duplicate_removal", dup_removal_cost) - .add("total_cost", imerge_cost); + if (unlikely(trace_best_disjunct.trace_started())) + trace_best_disjunct. + add("cost_duplicate_removal", dup_removal_cost). + add("total_cost", imerge_cost); } DBUG_PRINT("info",("index_merge total cost: %g (wanted: less then %g)", @@ -5476,8 +5503,10 @@ skip_to_ror_scan: DBUG_PRINT("info", ("ROR-union: cost %g, %zu members", roru_total_cost, n_child_scans)); - trace_best_disjunct.add("index_roworder_union_cost", roru_total_cost) - .add("members", n_child_scans); + if (unlikely(trace_best_disjunct.trace_started())) + trace_best_disjunct. + add("index_roworder_union_cost", roru_total_cost). + add("members", n_child_scans); TRP_ROR_UNION* roru; if (roru_total_cost < read_time) { @@ -5880,15 +5909,19 @@ bool prepare_search_best_index_intersect(PARAM *param, if (*index_scan == cpk_scan) { - idx_scan.add("chosen", "false") - .add("cause", "clustered index used for filtering"); + if (unlikely(idx_scan.trace_started())) + idx_scan. + add("chosen", "false"). + add("cause", "clustered index used for filtering"); continue; } if (cpk_scan && cpk_scan->used_key_parts >= used_key_parts && same_index_prefix(cpk_scan->key_info, key_info, used_key_parts)) { - idx_scan.add("chosen", "false") - .add("cause", "clustered index used for filtering"); + if (unlikely(idx_scan.trace_started())) + idx_scan. + add("chosen", "false"). + add("cause", "clustered index used for filtering"); continue; } @@ -5898,8 +5931,8 @@ bool prepare_search_best_index_intersect(PARAM *param, if (cost >= cutoff_cost) { - idx_scan.add("chosen", false); - idx_scan.add("cause", "cost"); + if (unlikely(idx_scan.trace_started())) + idx_scan.add("chosen", false).add("cause", "cost"); continue; } @@ -5918,15 +5951,18 @@ bool prepare_search_best_index_intersect(PARAM *param, } if (!*scan_ptr || cost < (*scan_ptr)->index_read_cost) { - idx_scan.add("chosen", true); - if (!*scan_ptr) - idx_scan.add("cause", "first occurrence of index prefix"); - else - idx_scan.add("cause", "better cost for same idx prefix"); + if (unlikely(idx_scan.trace_started())) + { + idx_scan.add("chosen", true); + if (!*scan_ptr) + idx_scan.add("cause", "first occurrence of index prefix"); + else + idx_scan.add("cause", "better cost for same idx prefix"); + } *scan_ptr= *index_scan; (*scan_ptr)->index_read_cost= cost; } - else + else if (unlikely(idx_scan.trace_started())) { idx_scan.add("chosen", false).add("cause", "cost"); } @@ -5989,13 +6025,14 @@ bool prepare_search_best_index_intersect(PARAM *param, ha_rows records= records_in_index_intersect_extension(&curr, *scan_ptr); (*scan_ptr)->filtered_out= records >= scan_records ? 0 : scan_records-records; - if (thd->trace_started()) + if (unlikely(thd->trace_started())) { Json_writer_object selected_idx(thd); selected_idx.add("index", key_info->name); print_keyparts(thd, key_info, (*scan_ptr)->used_key_parts); - selected_idx.add("records", (*scan_ptr)->records) - .add("filtered_records", (*scan_ptr)->filtered_out); + selected_idx. + add("records", (*scan_ptr)->records). + add("filtered_records", (*scan_ptr)->filtered_out); } } } @@ -6005,13 +6042,14 @@ bool prepare_search_best_index_intersect(PARAM *param, { KEY *key_info= (*scan_ptr)->key_info; (*scan_ptr)->filtered_out= 0; - if (thd->trace_started()) + if (unlikely(thd->trace_started())) { Json_writer_object selected_idx(thd); selected_idx.add("index", key_info->name); print_keyparts(thd, key_info, (*scan_ptr)->used_key_parts); - selected_idx.add("records", (*scan_ptr)->records) - .add("filtered_records", (*scan_ptr)->filtered_out); + selected_idx. + add("records", (*scan_ptr)->records). + add("filtered_records", (*scan_ptr)->filtered_out); } } } @@ -6544,9 +6582,11 @@ TRP_INDEX_INTERSECT *get_best_index_intersect(PARAM *param, SEL_TREE *tree, intersect_trp->range_scans= range_scans; intersect_trp->range_scans_end= cur_range; intersect_trp->filtered_scans= common.filtered_scans; - trace_idx_interect.add("rows", intersect_trp->records) - .add("cost", intersect_trp->read_cost) - .add("chosen",true); + if (unlikely(trace_idx_interect.trace_started())) + trace_idx_interect. + add("rows", intersect_trp->records). + add("cost", intersect_trp->read_cost). + add("chosen",true); } DBUG_RETURN(intersect_trp); } @@ -6562,11 +6602,12 @@ void TRP_ROR_INTERSECT::trace_basic_info(PARAM *param, THD *thd= param->thd; DBUG_ASSERT(trace_object->trace_started()); - trace_object->add("type", "index_roworder_intersect"); - trace_object->add("rows", records); - trace_object->add("cost", read_cost); - trace_object->add("covering", is_covering); - trace_object->add("clustered_pk_scan", cpk_scan != NULL); + trace_object-> + add("type", "index_roworder_intersect"). + add("rows", records). + add("cost", read_cost). + add("covering", is_covering). + add("clustered_pk_scan", cpk_scan != NULL); Json_writer_array smth_trace(thd, "intersect_of"); for (ROR_SCAN_INFO **cur_scan= first_scan; cur_scan != last_scan; @@ -6576,9 +6617,10 @@ void TRP_ROR_INTERSECT::trace_basic_info(PARAM *param, const KEY_PART_INFO *key_part= cur_key.key_part; Json_writer_object trace_isect_idx(thd); - trace_isect_idx.add("type", "range_scan"); - trace_isect_idx.add("index", cur_key.name); - trace_isect_idx.add("rows", (*cur_scan)->records); + trace_isect_idx. + add("type", "range_scan"). + add("index", cur_key.name). + add("rows", (*cur_scan)->records); Json_writer_array trace_range(thd, "ranges"); @@ -7217,16 +7259,18 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, /* S= S + first(R); R= R - first(R); */ if (!ror_intersect_add(intersect, *cur_ror_scan, &trace_idx, FALSE)) { - trace_idx.add("usable", false) - .add("cause", "does not reduce cost of intersect"); + trace_idx. + add("usable", false). + add("cause", "does not reduce cost of intersect"); cur_ror_scan++; continue; } - trace_idx.add("cumulative_total_cost", intersect->total_cost) - .add("usable", true) - .add("matching_rows_now", intersect->out_rows) - .add("intersect_covering_with_this_index", intersect->is_covering); + trace_idx. + add("cumulative_total_cost", intersect->total_cost). + add("usable", true). + add("matching_rows_now", intersect->out_rows). + add("intersect_covering_with_this_index", intersect->is_covering); *(intersect_scans_end++)= *(cur_ror_scan++); @@ -7240,8 +7284,9 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, } else { - trace_idx.add("chosen", false) - .add("cause", "does not reduce cost"); + trace_idx. + add("chosen", false). + add("cause", "does not reduce cost"); } } trace_isect_idx.end(); @@ -7249,8 +7294,9 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, if (intersect_scans_best == intersect_scans) { DBUG_PRINT("info", ("None of scans increase selectivity")); - trace_ror.add("chosen", false) - .add("cause","does not increase selectivity"); + trace_ror. + add("chosen", false). + add("cause","does not increase selectivity"); DBUG_RETURN(NULL); } @@ -7274,22 +7320,27 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, if (ror_intersect_add(intersect, cpk_scan, &trace_cpk, TRUE) && (intersect->total_cost < min_cost)) { - trace_cpk.add("clustered_pk_scan_added_to_intersect", true) - .add("cumulated_cost", intersect->total_cost); + if (trace_cpk.trace_started()) + trace_cpk. + add("clustered_pk_scan_added_to_intersect", true). + add("cumulated_cost", intersect->total_cost); intersect_best= intersect; //just set pointer here } else { - trace_cpk.add("clustered_pk_added_to_intersect", false) - .add("cause", "cost"); + if (trace_cpk.trace_started()) + trace_cpk. + add("clustered_pk_added_to_intersect", false). + add("cause", "cost"); cpk_scan= 0; // Don't use cpk_scan } } else { - trace_cpk.add("clustered_pk_added_to_intersect", false) - .add("cause", cpk_scan ? "roworder is covering" - : "no clustered pk index"); + trace_cpk. + add("clustered_pk_added_to_intersect", false). + add("cause", cpk_scan ? "roworder is covering" + : "no clustered pk index"); cpk_scan= 0; // Don't use cpk_scan } trace_cpk.end(); @@ -7319,17 +7370,20 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, DBUG_PRINT("info", ("Returning non-covering ROR-intersect plan:" "cost %g, records %lu", trp->read_cost, (ulong) trp->records)); - trace_ror.add("rows", trp->records) - .add("cost", trp->read_cost) - .add("covering", trp->is_covering) - .add("chosen", true); + if (unlikely(trace_ror.trace_started())) + trace_ror. + add("rows", trp->records). + add("cost", trp->read_cost). + add("covering", trp->is_covering). + add("chosen", true); } else { - trace_ror.add("chosen", false) - .add("cause", (read_time > min_cost) - ? "too few indexes to merge" - : "cost"); + trace_ror. + add("chosen", false). + add("cause", (read_time >= min_cost) + ? "too few indexes to merge" + : "cost"); } DBUG_PRINT("enter", ("opt_range_condition_rows: %llu", (ulonglong) param->table->opt_range_condition_rows)); @@ -7597,11 +7651,13 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, trace_ranges(&trace_range, param, idx, key, key_part); trace_range.end(); - trace_idx.add("rowid_ordered", is_ror_scan) - .add("using_mrr", !(mrr_flags & HA_MRR_USE_DEFAULT_IMPL)) - .add("index_only", read_index_only) - .add("rows", found_records) - .add("cost", cost.total_cost()); + if (unlikely(trace_idx.trace_started())) + trace_idx. + add("rowid_ordered", is_ror_scan). + add("using_mrr", !(mrr_flags & HA_MRR_USE_DEFAULT_IMPL)). + add("index_only", read_index_only). + add("rows", found_records). + add("cost", cost.total_cost()); } if ((found_records != HA_POS_ERROR) && is_ror_scan) { @@ -7619,7 +7675,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, best_buf_size= buf_size; trace_idx.add("chosen", true); } - else + else if (unlikely(trace_idx.trace_started())) { trace_idx.add("chosen", false); if (found_records == HA_POS_ERROR) @@ -11038,7 +11094,7 @@ SEL_ARG *enforce_sel_arg_weight_limit(RANGE_OPT_PARAM *param, uint keyno, uint weight2= sel_arg? sel_arg->weight : 0; - if (weight2 != weight1) + if (unlikely(weight2 != weight1 && param->thd->trace_started())) { Json_writer_object wrapper(param->thd); Json_writer_object obj(param->thd, "enforce_sel_arg_weight_limit"); @@ -11047,8 +11103,9 @@ SEL_ARG *enforce_sel_arg_weight_limit(RANGE_OPT_PARAM *param, uint keyno, else obj.add("pseudo_index", field->field_name); - obj.add("old_weight", (longlong)weight1); - obj.add("new_weight", (longlong)weight2); + obj. + add("old_weight", (longlong)weight1). + add("new_weight", (longlong)weight2); } return sel_arg; } @@ -11072,12 +11129,16 @@ bool sel_arg_and_weight_heuristic(RANGE_OPT_PARAM *param, SEL_ARG *key1, ulong max_weight= param->thd->variables.optimizer_max_sel_arg_weight; if (max_weight && key1->weight + key1->elements*key2->weight > max_weight) { - Json_writer_object wrapper(param->thd); - Json_writer_object obj(param->thd, "sel_arg_weight_heuristic"); - obj.add("key1_field", key1->field->field_name); - obj.add("key2_field", key2->field->field_name); - obj.add("key1_weight", (longlong)key1->weight); - obj.add("key2_weight", (longlong)key2->weight); + if (unlikely(param->thd->trace_started())) + { + Json_writer_object wrapper(param->thd); + Json_writer_object obj(param->thd, "sel_arg_weight_heuristic"); + obj. + add("key1_field", key1->field->field_name). + add("key2_field", key2->field->field_name). + add("key1_weight", (longlong)key1->weight). + add("key2_weight", (longlong)key2->weight); + } return true; // Discard key2 } return false; @@ -13805,7 +13866,8 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) (!join->select_distinct) && !is_agg_distinct) { - trace_group.add("chosen", false).add("cause","no group by or distinct"); + if (unlikely(trace_group.trace_started())) + trace_group.add("chosen", false).add("cause","no group by or distinct"); DBUG_RETURN(NULL); } /* Analyze the query in more detail. */ @@ -13830,8 +13892,10 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) continue; else { - trace_group.add("chosen", false) - .add("cause", "not applicable aggregate function"); + if (unlikely(trace_group.trace_started())) + trace_group. + add("chosen", false). + add("cause", "not applicable aggregate function"); DBUG_RETURN(NULL); } @@ -13843,15 +13907,19 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) min_max_arg_item= (Item_field*) expr; else if (! min_max_arg_item->eq(expr, 1)) { - trace_group.add("chosen", false) - .add("cause", "arguments different in min max function"); + if (unlikely(trace_group.trace_started())) + trace_group. + add("chosen", false). + add("cause", "arguments different in min max function"); DBUG_RETURN(NULL); } } else { - trace_group.add("chosen", false) - .add("cause", "no field item in min max function"); + if (unlikely(trace_group.trace_started())) + trace_group. + add("chosen", false). + add("cause", "no field item in min max function"); DBUG_RETURN(NULL); } } @@ -13860,8 +13928,10 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) /* Check (SA7). */ if (is_agg_distinct && (have_max || have_min)) { - trace_group.add("chosen", false) - .add("cause", "have both agg distinct and min max"); + if (unlikely(trace_group.trace_started())) + trace_group. + add("chosen", false). + add("cause", "have both agg distinct and min max"); DBUG_RETURN(NULL); } @@ -13873,8 +13943,10 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) { if (item->real_item()->type() != Item::FIELD_ITEM) { - trace_group.add("chosen", false) - .add("cause", "distinct field is expression"); + if (unlikely(trace_group.trace_started())) + trace_group. + add("chosen", false). + add("cause", "distinct field is expression"); DBUG_RETURN(NULL); } } @@ -13886,8 +13958,10 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) { if ((*tmp_group->item)->real_item()->type() != Item::FIELD_ITEM) { - trace_group.add("chosen", false) - .add("cause", "group field is expression"); + if (unlikely(trace_group.trace_started())) + trace_group. + add("chosen", false). + add("cause", "group field is expression"); DBUG_RETURN(NULL); } elements_in_group++; @@ -14313,8 +14387,10 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) Field::itMBR : Field::itRAW, &has_min_max_fld, &has_other_fld)) { - trace_group.add("usable", false) - .add("cause", "unsupported predicate on agg attribute"); + if (unlikely(trace_group.trace_started())) + trace_group. + add("usable", false). + add("cause", "unsupported predicate on agg attribute"); DBUG_RETURN(NULL); } @@ -14323,8 +14399,10 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) */ if (is_agg_distinct && table->file->is_clustering_key(index)) { - trace_group.add("usable", false) - .add("cause", "index is clustered"); + if (unlikely(trace_group.trace_started())) + trace_group. + add("usable", false). + add("cause", "index is clustered"); DBUG_RETURN(NULL); } diff --git a/sql/opt_split.cc b/sql/opt_split.cc index 86ed442814c..74e9d2c65b5 100644 --- a/sql/opt_split.cc +++ b/sql/opt_split.cc @@ -1014,11 +1014,12 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count, { Json_writer_object wrapper(thd); Json_writer_object find_trace(thd, "best_splitting"); - find_trace.add("table", best_table->alias.c_ptr()); - find_trace.add("key", best_table->key_info[best_key].name); - find_trace.add("record_count", record_count); - find_trace.add("cost", spl_plan->cost); - find_trace.add("unsplit_cost", spl_opt_info->unsplit_cost); + find_trace. + add("table", best_table->alias.c_ptr()). + add("key", best_table->key_info[best_key].name). + add("record_count", record_count). + add("cost", spl_plan->cost). + add("unsplit_cost", spl_opt_info->unsplit_cost); } memcpy((char *) spl_plan->best_positions, (char *) join->best_positions, @@ -1047,10 +1048,14 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count, startup_cost= record_count * spl_plan->cost; records= (ha_rows) (records * spl_plan->split_sel); - Json_writer_object trace(thd, "lateral_derived"); - trace.add("startup_cost", startup_cost); - trace.add("splitting_cost", spl_plan->cost); - trace.add("records", records); + if (unlikely(thd->trace_started())) + { + Json_writer_object trace(thd, "lateral_derived"); + trace. + add("startup_cost", startup_cost). + add("splitting_cost", spl_plan->cost). + add("records", records); + } } else startup_cost= spl_opt_info->unsplit_cost; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 6ec32ae0e73..52d6a784e15 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -910,8 +910,10 @@ bool subquery_types_allow_materialization(THD* thd, Item_in_subselect *in_subs) outer, converted_from_in_predicate)) { - trace_transform.add("possible", false); - trace_transform.add("cause", "types mismatch"); + if (unlikely(trace_transform.trace_started())) + trace_transform. + add("possible", false). + add("cause", "types mismatch"); DBUG_RETURN(FALSE); } } @@ -933,8 +935,10 @@ bool subquery_types_allow_materialization(THD* thd, Item_in_subselect *in_subs) { in_subs->types_allow_materialization= TRUE; in_subs->sjm_scan_allowed= all_are_fields; - trace_transform.add("sjm_scan_allowed", all_are_fields) - .add("possible", true); + if (unlikely(trace_transform.trace_started())) + trace_transform. + add("sjm_scan_allowed", all_are_fields). + add("possible", true); DBUG_PRINT("info",("subquery_types_allow_materialization: ok, allowed")); DBUG_RETURN(TRUE); } @@ -1294,8 +1298,10 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) OPT_TRACE_TRANSFORM(thd, trace_wrapper, trace_transform, in_subq->get_select_lex()->select_number, "IN (SELECT)", "semijoin"); - trace_transform.add("converted_to_semi_join", false) - .add("cause", "subquery attached to the ON clause"); + if (unlikely(trace_transform.trace_started())) + trace_transform. + add("converted_to_semi_join", false). + add("cause", "subquery attached to the ON clause"); break; } @@ -1307,9 +1313,10 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) if (join->table_count + in_subq->unit->first_select()->join->table_count >= MAX_TABLES) { - trace_transform.add("converted_to_semi_join", false); - trace_transform.add("cause", - "table in parent join now exceeds MAX_TABLES"); + if (unlikely(trace_transform.trace_started())) + trace_transform. + add("converted_to_semi_join", false). + add("cause", "table in parent join now exceeds MAX_TABLES"); break; } if (convert_subq_to_sj(join, in_subq)) @@ -3147,8 +3154,9 @@ bool Sj_materialization_picker::check_qep(JOIN *join, *strategy= SJ_OPT_MATERIALIZE; if (unlikely(trace.trace_started())) { - trace.add("records", *record_count); - trace.add("read_time", *read_time); + trace. + add("records", *record_count). + add("cost", *read_time); } return TRUE; } @@ -3329,8 +3337,9 @@ bool LooseScan_picker::check_qep(JOIN *join, *handled_fanout= first->table->emb_sj_nest->sj_inner_tables; if (unlikely(trace.trace_started())) { - trace.add("records", *record_count); - trace.add("read_time", *read_time); + trace. + add("records", *record_count). + add("read_time", *read_time); } return TRUE; } diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc index 8e723036b97..2536b1a0a87 100644 --- a/sql/opt_trace.cc +++ b/sql/opt_trace.cc @@ -149,7 +149,7 @@ void opt_trace_disable_if_no_security_context_access(THD *thd) return; } Opt_trace_context *const trace= &thd->opt_trace; - if (!thd->trace_started()) + if (unlikely(!thd->trace_started())) { /* @@optimizer_trace has "enabled=on" but trace is not started. @@ -201,7 +201,7 @@ void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp) if (likely(!(thd->variables.optimizer_trace & Opt_trace_context::FLAG_ENABLED)) || thd->system_thread || - !thd->trace_started()) + likely(!thd->trace_started())) return; Opt_trace_context *const trace= &thd->opt_trace; @@ -235,7 +235,7 @@ void opt_trace_disable_if_no_tables_access(THD *thd, TABLE_LIST *tbl) if (likely(!(thd->variables.optimizer_trace & Opt_trace_context::FLAG_ENABLED)) || thd->system_thread || - !thd->trace_started()) + likely(!thd->trace_started())) return; Opt_trace_context *const trace= &thd->opt_trace; @@ -296,7 +296,7 @@ void opt_trace_disable_if_no_view_access(THD *thd, TABLE_LIST *view, if (likely(!(thd->variables.optimizer_trace & Opt_trace_context::FLAG_ENABLED)) || thd->system_thread || - !thd->trace_started()) + likely(!thd->trace_started())) return; Opt_trace_context *const trace= &thd->opt_trace; @@ -605,6 +605,7 @@ void Json_writer::add_table_name(const TABLE *table) void trace_condition(THD * thd, const char *name, const char *transform_type, Item *item, const char *table_name) { + DBUG_ASSERT(thd->trace_started()); Json_writer_object trace_wrapper(thd); Json_writer_object trace_cond(thd, transform_type); trace_cond.add("condition", name); @@ -620,8 +621,9 @@ void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab) Json_writer_object table_records(thd); table_records.add_table_name(tab); Json_writer_object table_rec(thd, "table_scan"); - table_rec.add("rows", tab->found_records) - .add("cost", tab->read_time); + table_rec. + add("rows", tab->found_records). + add("cost", tab->read_time); } @@ -690,10 +692,11 @@ void print_best_access_for_table(THD *thd, POSITION *pos, DBUG_ASSERT(thd->trace_started()); Json_writer_object obj(thd, "chosen_access_method"); - obj.add("type", type == JT_ALL ? "scan" : join_type_str[type]); - obj.add("records", pos->records_read); - obj.add("cost", pos->read_time); - obj.add("uses_join_buffering", pos->use_join_buffer); + obj. + add("type", type == JT_ALL ? "scan" : join_type_str[type]). + add("records", pos->records_read). + add("cost", pos->read_time). + add("uses_join_buffering", pos->use_join_buffer); if (pos->range_rowid_filter_info) { uint key_no= pos->range_rowid_filter_info->get_key_no(); diff --git a/sql/rowid_filter.cc b/sql/rowid_filter.cc index 8cd2a5aeddb..3ed9a989345 100644 --- a/sql/rowid_filter.cc +++ b/sql/rowid_filter.cc @@ -423,6 +423,7 @@ void TABLE::init_cost_info_for_usable_range_rowid_filters(THD *thd) void TABLE::trace_range_rowid_filters(THD *thd) const { + DBUG_ASSERT(thd->trace_started()); if (!range_rowid_filter_cost_info_elems) return; @@ -440,10 +441,12 @@ void TABLE::trace_range_rowid_filters(THD *thd) const void Range_rowid_filter_cost_info::trace_info(THD *thd) { + DBUG_ASSERT(thd->trace_started()); Json_writer_object js_obj(thd); - js_obj.add("key", table->key_info[key_no].name); - js_obj.add("build_cost", cost_of_building_range_filter); - js_obj.add("rows", est_elements); + js_obj. + add("key", table->key_info[key_no].name). + add("build_cost", cost_of_building_range_filter). + add("rows", est_elements); } /** diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c4380df16f0..df4ce2325ea 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -538,9 +538,10 @@ static void trace_table_dependencies(THD *thd, { TABLE_LIST *table_ref= join_tabs[i].tab_list; Json_writer_object trace_one_table(thd); - trace_one_table.add_table_name(&join_tabs[i]); - trace_one_table.add("row_may_be_null", - (bool)table_ref->table->maybe_null); + trace_one_table. + add_table_name(&join_tabs[i]). + add("row_may_be_null", + (bool)table_ref->table->maybe_null); const table_map map= table_ref->get_map(); DBUG_ASSERT(map < (1ULL << table_count)); for (uint j= 0; j < table_count; j++) @@ -1742,7 +1743,7 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num, } } - if (thd->trace_started()) + if (unlikely(thd->trace_started())) { Json_writer_object trace_wrapper(thd); opt_trace_print_expanded_query(thd, select_lex, &trace_wrapper); @@ -5487,7 +5488,7 @@ make_join_statistics(JOIN *join, List &tables_list, } } - if (thd->trace_started()) + if (unlikely(thd->trace_started())) trace_table_dependencies(thd, stat, join->table_count); if (join->conds || outer_join) @@ -5508,7 +5509,7 @@ make_join_statistics(JOIN *join, List &tables_list, skip_unprefixed_keyparts)) goto error; DBUG_EXECUTE("opt", print_keyuse_array(keyuse_array);); - if (thd->trace_started()) + if (unlikely(thd->trace_started())) print_keyuse_array_for_trace(thd, keyuse_array); } @@ -5957,13 +5958,13 @@ make_join_statistics(JOIN *join, List &tables_list, delete select; else { - if (thd->trace_started()) + if (unlikely(thd->trace_started())) add_table_scan_values_to_trace(thd, s); } } else { - if (thd->trace_started()) + if (unlikely(thd->trace_started())) add_table_scan_values_to_trace(thd, s); } } @@ -8083,8 +8084,10 @@ best_access_path(JOIN *join, */ records= 1.0; type= JT_FT; - trace_access_idx.add("access_type", join_type_str[type]) - .add("full-text index", keyinfo->name); + if (unlikely(trace_access_idx.trace_started())) + trace_access_idx. + add("access_type", join_type_str[type]). + add("full-text index", keyinfo->name); } else { @@ -8109,8 +8112,10 @@ best_access_path(JOIN *join, DBUG_ASSERT(join->eq_ref_tables & table->map); /* TODO: Adjust cost for covering and clustering key */ type= JT_EQ_REF; - trace_access_idx.add("access_type", join_type_str[type]) - .add("index", keyinfo->name); + if (unlikely(trace_access_idx.trace_started())) + trace_access_idx. + add("access_type", join_type_str[type]). + add("index", keyinfo->name); if (!found_ref && table->opt_range_keys.is_set(key)) tmp= adjust_quick_cost(table->opt_range[key].cost, 1); else @@ -8126,8 +8131,10 @@ best_access_path(JOIN *join, else { type= JT_REF; - trace_access_idx.add("access_type", join_type_str[type]) - .add("index", keyinfo->name); + if (unlikely(trace_access_idx.trace_started())) + trace_access_idx. + add("access_type", join_type_str[type]). + add("index", keyinfo->name); if (!found_ref) { /* We found a const key */ /* @@ -8157,8 +8164,10 @@ best_access_path(JOIN *join, } /* quick_range couldn't use key! */ records= (double) s->records/rec; - trace_access_idx.add("used_range_estimates", false) - .add("reason", "not available"); + if (unlikely(trace_access_idx.trace_started())) + trace_access_idx. + add("used_range_estimates", false). + add("reason", "not available"); } else { @@ -8193,16 +8202,19 @@ best_access_path(JOIN *join, records= (double) table->opt_range[key].rows; trace_access_idx.add("used_range_estimates", "clipped down"); } - else + else if (unlikely(trace_access_idx.trace_started())) { - trace_access_idx.add("used_range_estimates", false); if (table->opt_range_keys.is_set(key)) { - trace_access_idx.add("reason", "not better than ref estimates"); + trace_access_idx. + add("used_range_estimates",false). + add("reason", "not better than ref estimates"); } else { - trace_access_idx.add("reason", "not available"); + trace_access_idx. + add("used_range_estimates", false). + add("reason", "not available"); } } } @@ -8214,8 +8226,10 @@ best_access_path(JOIN *join, else { type = ref_or_null_part ? JT_REF_OR_NULL : JT_REF; - trace_access_idx.add("access_type", join_type_str[type]) - .add("index", keyinfo->name); + if (unlikely(trace_access_idx.trace_started())) + trace_access_idx. + add("access_type", join_type_str[type]). + add("index", keyinfo->name); /* Use as much key-parts as possible and a uniq key is better than a not unique key @@ -8506,16 +8520,21 @@ best_access_path(JOIN *join, } } tmp= COST_ADD(tmp, records_after_filter/TIME_FOR_COMPARE); - trace_access_idx. - add("rows", records). - add("cond_check_cost",tmp). - add("startup_cost", startup_cost); + if (unlikely(trace_access_idx.trace_started())) + trace_access_idx. + add("rows", records). + add("cond_check_cost",tmp). + add("startup_cost", startup_cost); tmp= COST_MULT(tmp, record_count); tmp= COST_ADD(tmp, startup_cost); + + if (unlikely(trace_access_idx.trace_started())) + trace_access_idx.add("rows_after_filter", records_after_filter).add("cost", tmp); + if (tmp + 0.0001 < best_cost) { - trace_access_idx.add("cost", tmp).add("chosen", true); + trace_access_idx.add("chosen", true); best_cost= tmp; best_records= records; best_key= start_key; @@ -8524,10 +8543,11 @@ best_access_path(JOIN *join, best_filter= filter; best_type= type; } - else if (thd->trace_started()) + else if (unlikely(thd->trace_started())) { - trace_access_idx.add("cost",tmp).add("chosen", false) - .add("cause", cause ? cause : "cost"); + trace_access_idx. + add("chosen", false). + add("cause", cause ? cause : "cost"); } } /* for each key */ records= best_records; @@ -8627,11 +8647,14 @@ best_access_path(JOIN *join, best_filter= 0; best_type= JT_HASH; Json_writer_object trace_access_hash(thd); - trace_access_hash.add("type", "hash"); - trace_access_hash.add("index", "hj-key"); - trace_access_hash.add("rows", rnd_records); - trace_access_hash.add("cost", best_cost); - trace_access_hash.add("chosen", true); + if (unlikely(trace_access_hash.trace_started())) + trace_access_hash. + add("type", "hash"). + add("index", "hj-key"). + add("rows", rnd_records). + add("refills", refills). + add("cost", best_cost). + add("chosen", true); } /* @@ -8819,8 +8842,10 @@ best_access_path(JOIN *join, best_filter_cmp_gain= (best_filter ? best_filter->get_cmp_gain(record_count * records) : 0); - trace_access_scan.add("resulting_rows", rnd_records); - trace_access_scan.add("cost", tmp); + if (unlikely(trace_access_scan.trace_started())) + trace_access_scan. + add("resulting_rows", rnd_records). + add("cost", tmp); /* TODO: Document the following if */ if (best_cost == DBL_MAX || @@ -8851,9 +8876,11 @@ best_access_path(JOIN *join, } else { - trace_access_scan.add("type", "scan"); - trace_access_scan.add("chosen", false); - trace_access_scan.add("cause", "cost"); + if (unlikely(trace_access_scan.trace_started())) + trace_access_scan. + add("type", "scan"). + add("chosen", false). + add("cause", "cost"); } /* Update the cost information for the current partial plan */ @@ -10605,10 +10632,11 @@ best_extension_by_limited_search(JOIN *join, current_record_count / TIME_FOR_COMPARE)); - if (unlikely(thd->trace_started())) + if (unlikely(trace_one_table.trace_started())) { - trace_one_table.add("rows_for_plan", current_record_count); - trace_one_table.add("cost_for_plan", current_read_time); + trace_one_table. + add("rows_for_plan", current_record_count). + add("cost_for_plan", current_read_time); } optimize_semi_joins(join, remaining_tables, idx, ¤t_record_count, ¤t_read_time, loose_scan_pos); @@ -12514,8 +12542,10 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) trace_const_cond.add("condition_on_constant_tables", const_cond); if (const_cond->is_expensive()) { - trace_const_cond.add("evaluated", "false") - .add("cause", "expensive cond"); + if (unlikely(trace_const_cond.trace_started())) + trace_const_cond. + add("evalualted", "false"). + add("cause", "expensive cond"); } else { @@ -12527,8 +12557,10 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) if (!const_cond_result) { DBUG_PRINT("info",("Found impossible WHERE condition")); - trace_const_cond.add("evaluated", "true") - .add("found", "impossible where"); + if (unlikely(trace_const_cond.trace_started())) + trace_const_cond. + add("evalualted", "true"). + add("found", "impossible where"); join->exec_const_cond= NULL; DBUG_RETURN(1); } @@ -12631,9 +12663,13 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) tab->table->intersect_keys.is_set(tab->ref.key)))) { /* Range uses longer key; Use this instead of ref on key */ - Json_writer_object ref_to_range(thd); - ref_to_range.add("ref_to_range", true); - ref_to_range.add("cause", "range uses longer key"); + if (unlikely(thd->trace_started())) + { + Json_writer_object ref_to_range(thd); + ref_to_range. + add("ref_to_range", true). + add("cause", "range uses longer key"); + } tab->type=JT_ALL; use_quick_range=1; tab->use_quick=1; @@ -13144,8 +13180,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) continue; Item *const cond = tab->select_cond; Json_writer_object trace_one_table(thd); - trace_one_table.add_table_name(tab); - trace_one_table.add("attached", cond); + trace_one_table. + add_table_name(tab). + add("attached", cond); } } } @@ -18395,8 +18432,11 @@ optimize_cond(JOIN *join, COND *conds, Json_writer_object trace_wrapper(thd); Json_writer_object trace_cond(thd, "condition_processing"); - trace_cond.add("condition", join->conds == conds ? "WHERE" : "HAVING") - .add("original_condition", conds); + + if (unlikely(trace_cond.trace_started())) + trace_cond. + add("condition", join->conds == conds ? "WHERE" : "HAVING"). + add("original_condition", conds); Json_writer_array trace_steps(thd, "steps"); DBUG_EXECUTE("where", print_where(conds, "original", QT_ORDINARY);); @@ -18404,10 +18444,13 @@ optimize_cond(JOIN *join, COND *conds, ignore_on_conds, cond_equal, MY_TEST(flags & OPT_LINK_EQUAL_FIELDS)); DBUG_EXECUTE("where",print_where(conds,"after equal_items", QT_ORDINARY);); + + if (unlikely(thd->trace_started())) { Json_writer_object equal_prop_wrapper(thd); - equal_prop_wrapper.add("transformation", "equality_propagation") - .add("resulting_condition", conds); + equal_prop_wrapper. + add("transformation", "equality_propagation"). + add("resulting_condition", conds); } /* change field = field to field = const for each found field = const */ @@ -18417,20 +18460,24 @@ optimize_cond(JOIN *join, COND *conds, Remove all and-levels where CONST item != CONST item */ DBUG_EXECUTE("where",print_where(conds,"after const change", QT_ORDINARY);); + if (unlikely(thd->trace_started())) { Json_writer_object const_prop_wrapper(thd); - const_prop_wrapper.add("transformation", "constant_propagation") - .add("resulting_condition", conds); + const_prop_wrapper. + add("transformation", "constant_propagation"). + add("resulting_condition", conds); } conds= conds->remove_eq_conds(thd, cond_value, true); if (conds && conds->type() == Item::COND_ITEM && ((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC) *cond_equal= &((Item_cond_and*) conds)->m_cond_equal; + if (unlikely(thd->trace_started())) { Json_writer_object cond_removal_wrapper(thd); - cond_removal_wrapper.add("transformation", "trivial_condition_removal") - .add("resulting_condition", conds); + cond_removal_wrapper. + add("transformation", "trivial_condition_removal"). + add("resulting_condition", conds); } DBUG_EXECUTE("info",print_where(conds,"after remove", QT_ORDINARY);); } @@ -30105,15 +30152,19 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, HA_POS_ERROR; if (is_best_covering && !is_covering) { - possible_key.add("chosen", false); - possible_key.add("cause", "covering index already found"); + if (unlikely(possible_key.trace_started())) + possible_key. + add("chosen", false). + add("cause", "covering index already found"); continue; } if (is_covering && refkey_select_limit < select_limit) { - possible_key.add("chosen", false); - possible_key.add("cause", "ref estimates better"); + if (unlikely(possible_key.trace_started())) + possible_key. + add("chosen", false). + add("cause", "ref estimates better"); continue; } if (table->opt_range_keys.is_set(nr)) @@ -30153,8 +30204,9 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, } else { - possible_key.add("usable", false); - possible_key.add("cause", "cost"); + possible_key. + add("usable", false). + add("cause", "cost"); } } else @@ -30168,13 +30220,15 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, { if (keys.is_set(nr)) { - possible_key.add("can_resolve_order", false); - possible_key.add("cause", "order can not be resolved by key"); + possible_key. + add("can_resolve_order", false). + add("cause", "order can not be resolved by key"); } else { - possible_key.add("can_resolve_order", false); - possible_key.add("cause", "not usable index for the query"); + possible_key. + add("can_resolve_order", false). + add("cause", "not usable index for the query"); } } } diff --git a/sql/sql_test.cc b/sql/sql_test.cc index b85b37b1726..f50452a9d6c 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -698,14 +698,15 @@ void print_keyuse_array_for_trace(THD *thd, DYNAMIC_ARRAY *keyuse_array) { keyuse_elem.add("index", keyuse->table->key_info[keyuse->key].name); } - keyuse_elem.add("field", (keyuse->keypart == FT_KEYPART) ? "": - (keyuse->is_for_hash_join() ? - keyuse->table->field[keyuse->keypart] - ->field_name.str : - keyuse->table->key_info[keyuse->key] - .key_part[keyuse->keypart] - .field->field_name.str)); - keyuse_elem.add("equals",keyuse->val); - keyuse_elem.add("null_rejecting",keyuse->null_rejecting); + keyuse_elem. + add("field", (keyuse->keypart == FT_KEYPART) ? "": + (keyuse->is_for_hash_join() ? + keyuse->table->field[keyuse->keypart] + ->field_name.str : + keyuse->table->key_info[keyuse->key] + .key_part[keyuse->keypart] + .field->field_name.str)). + add("equals",keyuse->val). + add("null_rejecting",keyuse->null_rejecting); } } diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index 066d6b7483d..9745997f60d 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -953,8 +953,10 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd, if (!length || length > tmp_table_max_key_length() || args[0]->cols() > tmp_table_max_key_parts()) { - trace_conv.add("done", false); - trace_conv.add("reason", "key is too long"); + if (unlikely(trace_conv.trace_started())) + trace_conv. + add("done", false). + add("reason", "key is too long"); return this; } @@ -962,15 +964,19 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd, { if (!args[i]->const_item()) { - trace_conv.add("done", false); - trace_conv.add("reason", "non-constant element in the IN-list"); + if (unlikely(trace_conv.trace_started())) + trace_conv. + add("done", false). + add("reason", "non-constant element in the IN-list"); return this; } if (cmp_row_types(args[i], args[0])) { - trace_conv.add("done", false); - trace_conv.add("reason", "type mismatch"); + if (unlikely(trace_conv.trace_started())) + trace_conv. + add("done", false). + add("reason", "type mismatch"); return this; } } From e6205c966d8c4e1e56a031b0f2df92cd3c0956c5 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 21 Oct 2021 19:40:58 +0300 Subject: [PATCH 021/123] Split cost calculations into fetch and total This patch causes no changes in costs or result files. Changes: - Store row compare cost separately in Cost_estimate::comp_cost - Store cost of fetching rows separately in OPT_RANGE - Use range->fetch_cost instead of adjust_quick_cost(total_cost) This was done to simplify cost calculation in sql_select.cc: - We can use range->fetch_cost directly without having to call adjust_quick_cost(). adjust_quick_cost() is now removed. Other things: - Removed some not used functions in Cost_estimate --- sql/handler.h | 36 +++++++++++++++++++++++++----------- sql/multi_range_read.cc | 13 ++++++++----- sql/opt_range.cc | 4 +++- sql/sql_select.cc | 28 +++------------------------- sql/table.h | 3 +++ 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/sql/handler.h b/sql/handler.h index 2b5e41d1bdd..536c09a4e4d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2780,6 +2780,7 @@ public: double cpu_cost; /* total cost of operations in CPU */ double idx_cpu_cost; /* cost of operations in CPU for index */ double import_cost; /* cost of remote operations */ + double comp_cost; /* Cost of comparing found rows with WHERE clause */ double mem_cost; /* cost of used memory */ static constexpr double IO_COEFF= 1; @@ -2793,6 +2794,15 @@ public: } double total_cost() const + { + return IO_COEFF*io_count*avg_io_cost + + IO_COEFF*idx_io_count*idx_avg_io_cost + + CPU_COEFF*(cpu_cost + idx_cpu_cost + comp_cost) + + MEM_COEFF*mem_cost + IMPORT_COEFF*import_cost; + } + + /* Cost of fetching a row */ + double fetch_cost() const { return IO_COEFF*io_count*avg_io_cost + IO_COEFF*idx_io_count*idx_avg_io_cost + @@ -2800,6 +2810,16 @@ public: MEM_COEFF*mem_cost + IMPORT_COEFF*import_cost; } + /* + Cost of comparing the row with the WHERE clause + Note that fetch_cost() + compare_cost() == total_cost() + */ + double compare_cost() const + { + return CPU_COEFF*comp_cost; + } + + double index_only_cost() { return IO_COEFF*idx_io_count*idx_avg_io_cost + @@ -2814,14 +2834,15 @@ public: bool is_zero() const { return io_count == 0.0 && idx_io_count == 0.0 && cpu_cost == 0.0 && - import_cost == 0.0 && mem_cost == 0.0; + import_cost == 0.0 && mem_cost == 0.0 && comp_cost == 0.0; } void reset() { avg_io_cost= 1.0; idx_avg_io_cost= 1.0; - io_count= idx_io_count= cpu_cost= idx_cpu_cost= mem_cost= import_cost= 0.0; + io_count= idx_io_count= cpu_cost= idx_cpu_cost= mem_cost= import_cost= + comp_cost= 0.0; } void multiply(double m) @@ -2831,6 +2852,7 @@ public: idx_io_count *= m; idx_cpu_cost *= m; import_cost *= m; + comp_cost *= m; /* Don't multiply mem_cost */ } @@ -2855,6 +2877,7 @@ public: cpu_cost += cost->cpu_cost; idx_cpu_cost += cost->idx_cpu_cost; import_cost += cost->import_cost; + comp_cost+= cost->comp_cost; } void add_io(double add_io_cnt, double add_avg_cost) @@ -2869,15 +2892,6 @@ public: } } - /// Add to CPU cost - void add_cpu(double add_cpu_cost) { cpu_cost+= add_cpu_cost; } - - /// Add to import cost - void add_import(double add_import_cost) { import_cost+= add_import_cost; } - - /// Add to memory cost - void add_mem(double add_mem_cost) { mem_cost+= add_mem_cost; } - /* To be used when we go from old single value-based cost calculations to the new Cost_estimate-based. diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 0316caf9fdd..6c34db0c6b3 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -329,15 +329,18 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, uint limited_ranges= (uint) MY_MIN((ulonglong) n_ranges, io_blocks); cost->cpu_cost= read_time(keyno, limited_ranges, total_rows); } - cost->cpu_cost+= (rows2double(total_rows) / TIME_FOR_COMPARE + + cost->comp_cost= (rows2double(total_rows) / TIME_FOR_COMPARE + MULTI_RANGE_READ_SETUP_COST); } DBUG_PRINT("statistics", ("key: %s rows: %llu total_cost: %.3f io_blocks: %llu " - "idx_io_count: %.3f cpu_cost: %.3f io_count: %.3f", + "idx_io_count: %.3f cpu_cost: %.3f io_count: %.3f " + "compare_cost: %.3f", table->s->keynames.type_names[keyno], - (ulonglong) total_rows, cost->total_cost(), (ulonglong) io_blocks, - cost->idx_io_count, cost->cpu_cost, cost->io_count)); + (ulonglong) total_rows, cost->total_cost(), + (ulonglong) io_blocks, + cost->idx_io_count, cost->cpu_cost, cost->io_count, + cost->comp_cost)); DBUG_RETURN(total_rows); } @@ -409,7 +412,7 @@ ha_rows handler::multi_range_read_info(uint keyno, uint n_ranges, uint n_rows, { cost->cpu_cost= read_time(keyno, n_ranges, (uint)n_rows); } - cost->cpu_cost+= rows2double(n_rows) / TIME_FOR_COMPARE; + cost->comp_cost= rows2double(n_rows) / TIME_FOR_COMPARE; return 0; } diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e540f7adc6a..00b83f3759c 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -11764,7 +11764,9 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only, param->table->opt_range_condition_rows= MY_MIN(param->table->opt_range_condition_rows, rows); range->rows= rows; - range->cost= cost->total_cost(); + range->fetch_cost= cost->fetch_cost(); + /* Same as total cost */ + range->cost= range->fetch_cost + cost->compare_cost(); if (param->table->file->is_clustering_key(keynr)) range->index_only_cost= 0; else diff --git a/sql/sql_select.cc b/sql/sql_select.cc index df4ce2325ea..294d7852560 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7834,26 +7834,6 @@ double cost_for_index_read(const THD *thd, const TABLE *table, uint key, } -/* - Adjust cost from table->quick_costs calculated by - multi_range_read_info_const() to be comparable with cost_for_index_read() - - This functions is needed because best_access_path() doesn't add - TIME_FOR_COMPARE to it's costs until very late. - Preferably we should fix so that all costs are comparably. - (All compared costs should include TIME_FOR_COMPARE for all found - rows). -*/ - -double adjust_quick_cost(double quick_cost, ha_rows records) -{ - double cost= (quick_cost - MULTI_RANGE_READ_SETUP_COST - - rows2double(records)/TIME_FOR_COMPARE); - DBUG_ASSERT(cost > 0.0); - return cost; -} - - /** Find the best access path for an extension of a partial execution plan and add this path to the plan. @@ -8117,7 +8097,7 @@ best_access_path(JOIN *join, add("access_type", join_type_str[type]). add("index", keyinfo->name); if (!found_ref && table->opt_range_keys.is_set(key)) - tmp= adjust_quick_cost(table->opt_range[key].cost, 1); + tmp= table->opt_range[key].fetch_cost; else tmp= table->file->avg_io_cost(); /* @@ -8158,8 +8138,7 @@ best_access_path(JOIN *join, { records= (double) table->opt_range[key].rows; trace_access_idx.add("used_range_estimates", true); - tmp= adjust_quick_cost(table->opt_range[key].cost, - table->opt_range[key].rows); + tmp= table->opt_range[key].fetch_cost; goto got_cost2; } /* quick_range couldn't use key! */ @@ -8285,8 +8264,7 @@ best_access_path(JOIN *join, table->opt_range[key].ranges == 1 + MY_TEST(ref_or_null_part)) //(C3) { records= (double) table->opt_range[key].rows; - tmp= adjust_quick_cost(table->opt_range[key].cost, - table->opt_range[key].rows); + tmp= table->opt_range[key].fetch_cost; trace_access_idx.add("used_range_estimates", true); goto got_cost2; } diff --git a/sql/table.h b/sql/table.h index 877af624837..5340a4968bd 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1392,7 +1392,10 @@ public: uint key_parts; uint ranges; ha_rows rows; + /* Cost of fetching and comparing the row aginst the WHERE clause */ double cost; + /* Cost of comparing row with WHERE clause. Included in 'cost' */ + double fetch_cost; /* If there is a range access by i-th index then the cost of index only access for it is stored in index_only_costs[i] From 034aedadf25a9981d8dd94f6042666b68fa7d2a4 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 21 Aug 2022 05:53:54 +0300 Subject: [PATCH 022/123] Added optimizer_costs.h which includes all optimizer costs This makes it easier to see how costs changes over commits --- sql/CMakeLists.txt | 1 + sql/handler.h | 1 + sql/optimizer_costs.h | 70 +++++++++++++++++++++++++++++++++++++++++++ sql/sql_const.h | 50 ------------------------------- 4 files changed, 72 insertions(+), 50 deletions(-) create mode 100644 sql/optimizer_costs.h diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 9b3beae637d..d45ab2adde1 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -174,6 +174,7 @@ SET (SQL_SOURCE sql_tvc.cc sql_tvc.h opt_split.cc rowid_filter.cc rowid_filter.h + optimizer_costs.h opt_trace.cc table_cache.cc encryption.cc temporary_tables.cc json_table.cc diff --git a/sql/handler.h b/sql/handler.h index 536c09a4e4d..4a59dc4107b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -26,6 +26,7 @@ #endif #include "sql_const.h" +#include "optimizer_costs.h" #include "sql_basic_types.h" #include "mysqld.h" /* server_id */ #include "sql_plugin.h" /* plugin_ref, st_plugin_int, plugin */ diff --git a/sql/optimizer_costs.h b/sql/optimizer_costs.h new file mode 100644 index 00000000000..574c0116c54 --- /dev/null +++ b/sql/optimizer_costs.h @@ -0,0 +1,70 @@ +#ifndef OPTIMIZER_COSTS_INCLUDED +#define OPTIMIZER_COSTS_INCLUDED +/* + Copyright (c) 2022, MariaDB AB + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; version 2 of + the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA +*/ + +/* This file includes costs variables used by the optimizer */ + +/** + The following is used to decide if MySQL should use table scanning + instead of reading with keys. The number says how many evaluation of the + WHERE clause is comparable to reading one extra row from a table. +*/ +#define TIME_FOR_COMPARE 5.0 // 5 WHERE compares == one read +#define TIME_FOR_COMPARE_IDX 20.0 + +#define IDX_BLOCK_COPY_COST ((double) 1 / TIME_FOR_COMPARE) +#define IDX_LOOKUP_COST ((double) 1 / 8) +#define MULTI_RANGE_READ_SETUP_COST (IDX_BLOCK_COPY_COST/10) + +/** + Number of comparisons of table rowids equivalent to reading one row from a + table. +*/ +#define TIME_FOR_COMPARE_ROWID (TIME_FOR_COMPARE*100) + +/* cost1 is better that cost2 only if cost1 + COST_EPS < cost2 */ +#define COST_EPS 0.001 + +/* + For sequential disk seeks the cost formula is: + DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip + + The cost of average seek + DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0. +*/ +#define DISK_SEEK_BASE_COST ((double)0.9) + +#define BLOCKS_IN_AVG_SEEK 128 + +#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK) + +/* + Subquery materialization-related constants +*/ +#define HEAP_TEMPTABLE_LOOKUP_COST 0.05 +#define DISK_TEMPTABLE_LOOKUP_COST 1.0 +#define SORT_INDEX_CMP_COST 0.02 + +#define COST_MAX (DBL_MAX * (1.0 - DBL_EPSILON)) + +#define COST_ADD(c,d) (COST_MAX - (d) > (c) ? (c) + (d) : COST_MAX) + +#define COST_MULT(c,f) (COST_MAX / (f) > (c) ? (c) * (f) : COST_MAX) + +#endif /* OPTIMIZER_COSTS_INCLUDED */ diff --git a/sql/sql_const.h b/sql/sql_const.h index 490b870d768..474a745efd1 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -199,41 +199,6 @@ #define MIN_ROWS_TO_USE_TABLE_CACHE 100 #define MIN_ROWS_TO_USE_BULK_INSERT 100 -/** - The following is used to decide if MySQL should use table scanning - instead of reading with keys. The number says how many evaluation of the - WHERE clause is comparable to reading one extra row from a table. -*/ -#define TIME_FOR_COMPARE 5.0 // 5 WHERE compares == one read -#define TIME_FOR_COMPARE_IDX 20.0 - -#define IDX_BLOCK_COPY_COST ((double) 1 / TIME_FOR_COMPARE) -#define IDX_LOOKUP_COST ((double) 1 / 8) -#define MULTI_RANGE_READ_SETUP_COST (IDX_BLOCK_COPY_COST/10) - -/** - Number of comparisons of table rowids equivalent to reading one row from a - table. -*/ -#define TIME_FOR_COMPARE_ROWID (TIME_FOR_COMPARE*100) - -/* cost1 is better that cost2 only if cost1 + COST_EPS < cost2 */ -#define COST_EPS 0.001 - -/* - For sequential disk seeks the cost formula is: - DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip - - The cost of average seek - DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0. -*/ -#define DISK_SEEK_BASE_COST ((double)0.9) - -#define BLOCKS_IN_AVG_SEEK 128 - -#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK) - - /** Number of rows in a reference table when refereed through a not unique key. This value is only used when we don't know anything about the key @@ -241,21 +206,6 @@ */ #define MATCHING_ROWS_IN_OTHER_TABLE 10 -/* - Subquery materialization-related constants -*/ -#define HEAP_TEMPTABLE_LOOKUP_COST 0.05 -#define DISK_TEMPTABLE_LOOKUP_COST 1.0 -#define SORT_INDEX_CMP_COST 0.02 - - -#define COST_MAX (DBL_MAX * (1.0 - DBL_EPSILON)) - -#define COST_ADD(c,d) (COST_MAX - (d) > (c) ? (c) + (d) : COST_MAX) - -#define COST_MULT(c,f) (COST_MAX / (f) > (c) ? (c) * (f) : COST_MAX) - - #define MY_CHARSET_BIN_MB_MAXLEN 1 /** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */ From b6215b9b20b55911ca06c4cee1fa6ebdd4e8e1eb Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 1 Nov 2021 12:34:24 +0200 Subject: [PATCH 023/123] Update row and key fetch cost models to take into account data copy costs Before this patch, when calculating the cost of fetching and using a row/key from the engine, we took into account the cost of finding a row or key from the engine, but did not consistently take into account index only accessed, clustered key or covered keys for all access paths. The cost of the WHERE clause (TIME_FOR_COMPARE) was not consistently considered in best_access_path(). TIME_FOR_COMPARE was used in calculation in other places, like greedy_search(), but was in some cases (like scans) done an a different number of rows than was accessed. The cost calculation of row and index scans didn't take into account the number of rows that where accessed, only the number of accepted rows. When using a filter, the cost of index_only_reads and cost of accessing and disregarding 'filtered rows' where not taken into account, which made filters cost less than there actually where. To remedy the above, the following key & row fetch related costs has been added: - The cost of fetching and using a row is now split into different costs: - key + Row fetch cost (as before) but multiplied with the variable 'optimizer_cache_cost' (default to 0.5). This allows the user to tell the optimizer the likehood of finding the key and row in the engine cache. - ROW_COPY_COST, The cost copying a row from the engine to the sql layer or creating a row from the join_cache to the record buffer. Mostly affects table scan costs. - ROW_LOOKUP_COST, the cost of fetching a row by rowid. - KEY_COPY_COST the cost of finding the next key and copying it from the engine to the SQL layer. This is used when we calculate the cost index only reads. It makes index scans more expensive than before if they cover a lot of rows. (main.index_merge_myisam) - KEY_LOOKUP_COST, the cost of finding the first key in a range. This replaces the old define IDX_LOOKUP_COST, but with a higher cost. - KEY_NEXT_FIND_COST, the cost of finding the next key (and rowid). when doing a index scan and comparing the rowid to the filter. Before this cost was assumed to be 0. All of the above constants/variables are now tuned to be somewhat in proportion of executing complexity to each other. There is tuning need for these in the future, but that can wait until the above are made user variables as that will make tuning much easier. To make the usage of the above easy, there are new (not virtual) cost calclation functions in handler: - ha_read_time(), like read_time(), but take optimizer_cache_cost into account. - ha_read_and_copy_time(), like ha_read_time() but take into account ROW_COPY_TIME - ha_read_and_compare_time(), like ha_read_and_copy_time() but take TIME_FOR_COMPARE into account. - ha_rnd_pos_time(). Read row with row id, taking ROW_COPY_COST into account. This is used with filesort where we don't need to execute the WHERE clause again. - ha_keyread_time(), like keyread_time() but take optimizer_cache_cost into account. - ha_keyread_and_copy_time(), like ha_keyread_time(), but add KEY_COPY_COST. - ha_key_scan_time(), like key_scan_time() but take optimizer_cache_cost nto account. - ha_key_scan_and_compare_time(), like ha_key_scan_time(), but add KEY_COPY_COST & TIME_FOR_COMPARE. I also added some setup costs for doing different types of scans and creating temporary tables (on disk and in memory). This encourages the optimizer to not use these for simple 'a few row' lookups if there are adequate key lookup strategies. - TABLE_SCAN_SETUP_COST, cost of starting a table scan. - INDEX_SCAN_SETUP_COST, cost of starting an index scan. - HEAP_TEMPTABLE_CREATE_COST, cost of creating in memory temporary table. - DISK_TEMPTABLE_CREATE_COST, cost of creating an on disk temporary table. When calculating cost of fetching ranges, we had a cost of IDX_LOOKUP_COST (0.125) for doing a key div for a new range. This is now replaced with 'io_cost * KEY_LOOKUP_COST (1.0) * optimizer_cache_cost', which matches the cost we use for 'ref' and other key lookups. The effect is that the cost is now a bit higher when we have many ranges for a key. Allmost all calculation with TIME_FOR_COMPARE is now done in best_access_path(). 'JOIN::read_time' now includes the full cost for finding the rows in the table. In the result files, many of the changes are now again close to what they where before the "Update cost for hash and cached joins" commit, as that commit didn't fix the filter cost (too complex to do everything in one commit). The above changes showed a lot of a lot of inconsistencies in optimizer cost calculation. The main objective with the other changes was to do calculation as similar (and accurate) as possible and to make different plans more comparable. Detailed list of changes: - Calculate index_only_cost consistently and correctly for all scan and ref accesses. The row fetch_cost and index_only_cost now takes into account clustered keys, covered keys and index only accesses. - cost_for_index_read now returns both full cost and index_only_cost - Fixed cost calculation of get_sweep_read_cost() to match other similar costs. This is bases on the assumption that data is more often stored on SSD than a hard disk. - Replaced constant 2.0 with new define TABLE_SCAN_SETUP_COST. - Some scan cost estimates did not take into account TIME_FOR_COMPARE. Now all scan costs takes this into account. (main.show_explain) - Added session variable optimizer_cache_hit_ratio (default 50%). By adjusting this on can reduce or increase the cost of index or direct record lookups. The effect of the default is that key lookups is now a bit cheaper than before. See usage of 'optimizer_cache_cost' in handler.h. - JOIN_TAB::scan_time() did not take into account index only scans, which produced a wrong cost when index scan was used. Changed JOIN_TAB:::scan_time() to take into consideration clustered and covered keys. The values are now cached and we only have to call this function once. Other calls are changed to use the cached values. Function renamed to JOIN_TAB::estimate_scan_time(). - Fixed that most index cost calculations are done the same way and more close to 'range' calculations. The cost is now lower than before for small data sets and higher for large data sets as we take into account how many keys are read (main.opt_trace_selectivity, main.limit_rows_examined). - Ensured that index_scan_cost() == range(scan_of_all_rows_in_table_using_one_range) + MULTI_RANGE_READ_INFO_CONST. One effect of this is that if there is choice of doing a full index scan and a range-index scan over almost the whole table then index scan will be preferred (no range-read setup cost). (innodb.innodb, main.show_explain, main.range) - Fixed the EQ_REF and REF takes into account clustered and covered keys. This changes some plans to use covered or clustered indexes as these are much cheaper. (main.subselect_mat_cost, main.state_tables_innodb, main.limit_rows_examined) - Rowid filter setup cost and filter compare cost now takes into account fetching and checking the rowid (KEY_NEXT_FIND_COST). (main.partition_pruning heap.heap_btree main.log_state) - Added KEY_NEXT_FIND_COST to Range_rowid_filter_cost_info::lookup_cost to account of the time to find and check the next key value against the container - Introduced ha_keyread_time(rows) that takes into account finding the next row and copying the key value to 'record' (KEY_COPY_COST). - Introduced ha_key_scan_time() for calculating an index scan over all rows. - Added IDX_LOOKUP_COST to keyread_time() as a startup cost. - Added index_only_fetch_cost() as a convenience function to OPT_RANGE. - keyread_time() cost is slightly reduced to prefer shorter keys. (main.index_merge_myisam) - All of the above caused some index_merge combinations to be rejected because of cost (main.index_intersect). In some cases 'ref' where replaced with index_merge because of the low cost calculation of get_sweep_read_cost(). - Some index usage moved from PRIMARY to a covering index. (main.subselect_innodb) - Changed cost calculation of filter to take KEY_LOOKUP_COST and TIME_FOR_COMPARE into account. See sql_select.cc::apply_filter(). filter parameters and costs are now written to optimizer_trace. - Don't use matchings_records_in_range() to try to estimate the number of filtered rows for ranges. The reason is that we want to ensure that 'range' is calculated similar to 'ref'. There is also more work needed to calculate the selectivity when using ranges and ranges and filtering. This causes filtering column in EXPLAIN EXTENDED to be 100.00 for some cases where range cannot use filtering. (main.rowid_filter) - Introduced ha_scan_time() that takes into account the CPU cost of finding the next row and copying the row from the engine to 'record'. This causes costs of table scan to slightly increase and some test to changed their plan from ALL to RANGE or ALL to ref. (innodb.innodb_mysql, main.select_pkeycache) In a few cases where scan time of very small tables have lower cost than a ref or range, things changed from ref/range to ALL. (main.myisam, main.func_group, main.limit_rows_examined, main.subselect2) - Introduced ha_scan_and_compare_time() which is like ha_scan_time() but also adds the cost of the where clause (TIME_FOR_COMPARE). - Added small cost for creating temporary table for materialization. This causes some very small tables to use scan instead of materialization. - Added checking of the WHERE clause (TIME_FOR_COMPARE) of the accepted rows to ROR costs in get_best_ror_intersect() - Removed '- 0.001' from 'join->best_read' and optimize_straight_join() to ensure that the 'Last_query_cost' status variable contains the same value as the one that was calculated by the optimizer. - Take avg_io_cost() into account in handler::keyread_time() and handler::read_time(). This should have no effect as it's 1.0 by default, except for heap that overrides these functions. - Some 'ref_or_null' accesses changed to 'range' because of cost adjustments (main.order_by) - Added scan type "scan_with_join_cache" for optimizer_trace. This is just to show in the trace what kind of scan was used. - When using 'scan_with_join_cache' take into account number of preceding tables (as have to restore all fields for all previous table combination when checking the where clause) The new cost added is: (row_combinations * ROW_COPY_COST * number_of_cached_tables). This increases the cost of join buffering in proportion of the number of tables in the join buffer. One effect is that full scans are now done earlier as the cost is then smaller. (main.join_outer_innodb, main.greedy_optimizer) - Removed the usage of 'worst_seeks' in cost_for_index_read as it caused wrong plans to be created; It prefered JT_EQ_REF even if it would be much more expensive than a full table scan. A related issue was that worst_seeks only applied to full lookup, not to clustered or index only lookups, which is not consistent. This caused some plans to use index scan instead of eq_ref (main.union) - Changed federated block size from 4096 to 1500, which is the typical size of an IO packet. - Added costs for reading rows to Federated. Needed as there is no caching of rows in the federated engine. - Added ha_innobase::rnd_pos_time() cost function. - A lot of extra things added to optimizer trace - More costs, especially for materialization and index_merge. - Make lables more uniform - Fixed a lot of minor bugs - Added 'trace_started()' around a lot of trace blocks. - When calculating ORDER BY with LIMIT cost for using an index the cost did not take into account the number of row retrivals that has to be done or the cost of comparing the rows with the WHERE clause. The cost calculated would be just a fraction of the real cost. Now we calculate the cost as we do for ranges and 'ref'. - 'Using index for group-by' is used a bit more than before as now take into account the WHERE clause cost when comparing with 'ref' and prefer the method with fewer row combinations. (main.group_min_max). Bugs fixed: - Fixed that we don't calculate TIME_FOR_COMPARE twice for some plans, like in optimize_straight_join() and greedy_search() - Fixed bug in save_explain_data where we could test for the wrong index when displaying 'Using index'. This caused some old plans to show 'Using index'. (main.subselect_innodb, main.subselect2) - Fixed bug in get_best_ror_intersect() where 'min_cost' was not updated, and the cost we compared with was not the one that was used. - Fixed very wrong cost calculation for priority queues in check_if_pq_applicable(). (main.order_by now correctly uses priority queue) - When calculating cost of EQ_REF or REF, we added the cost of comparing the WHERE clause with the found rows, not all row combinations. This made ref and eq_ref to be regarded way to cheap compared to other access methods. - FORCE INDEX cost calculation didn't take into account clustered or covered indexes. - JT_EQ_REF cost was estimated as avg_io_cost(), which is half the cost of a JT_REF key. This may be true for InnoDB primary key, but not for other unique keys or other engines. Now we use handler function to calculate the cost, which allows us to handle consistently clustered, covered keys and not covered keys. - ha_start_keyread() didn't call extra_opt() if keyread was already enabled but still changed the 'keyread' variable (which is wrong). Fixed by not doing anything if keyread is already enabled. - multi_range_read_info_cost() didn't take into account io_cost when calculating the cost of ranges. - fix_semijoin_strategies_for_picked_join_order() used the wrong record_count when calling best_access_path() for SJ_OPT_FIRST_MATCH and SJ_OPT_LOOSE_SCAN. - Hash joins didn't provide correct best_cost to the upper level, which means that the cost for hash_joins more expensive than calculated in best_access_path (a difference of 10x * TIME_OF_COMPARE). This is fixed in the new code thanks to that we now include TIME_OF_COMPARE cost in 'read_time'. Other things: - Added some 'if (thd->trace_started())' to speed up code - Removed not used function Cost_estimate::is_zero() - Simplified testing of HA_POS_ERROR in get_best_ror_intersect(). (No cost changes) - Moved ha_start_keyread() from join_read_const_table() to join_read_const() to enable keyread for all types of JT_CONST tables. - Made a few very short functions inline in handler.h Notes: - In main.rowid_filter the join order of order and lineitem is swapped. This is because the cost of doing a range fetch of lineitem(98 rows) is almost as big as the whole join of order,lineitem. The filtering will also ensure that we only have to do very small key fetches of the rows in lineitem. - main.index_merge_myisam had a few changes where we are now using less keys for index_merge. This is because index scans are now more expensive than before. - handler->optimizer_cache_cost is updated in ha_external_lock(). This ensures that it is up to date per statements. Not an optimal solution (for locked tables), but should be ok for now. - 'DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a' does not take cost of filesort into consideration when table scan is chosen. (main.myisam_explain_non_select_all) - perfschema.table_aggregate_global_* has changed because an update on a table with 1 row will now use table scan instead of key lookup. TODO in upcomming commits: - Fix selectivity calculation for ranges with and without filtering and when there is a ref access but scan is chosen. For this we have to store the lowest known value for 'accepted_records' in the OPT_RANGE structure. - Change that records_read does not include filtered rows. - test_if_cheaper_ordering() needs to be updated to properly calculate costs. This will fix tests like main.order_by_innodb, main.single_delete_update - Extend get_range_limit_read_cost() to take into considering cost_for_index_read() if there where no quick keys. This will reduce the computed cost for ORDER BY with LIMIT in some cases. (main.innodb_ext_key) - Fix that we take into account selectivity when counting the number of rows we have to read when considering using a index table scan to resolve ORDER BY. - Add new calculation for rnd_pos_time() where we take into account the benefit of reading multiple rows from the same page. --- mysql-test/include/ctype_numconv.inc | 1 + mysql-test/include/last_query_cost.inc | 5 + mysql-test/include/world.inc | 2 + mysql-test/main/costs.result | 91 + mysql-test/main/costs.test | 75 + mysql-test/main/cte_nonrecursive.result | 8 +- mysql-test/main/cte_recursive.result | 6 +- mysql-test/main/ctype_binary.result | 1 + mysql-test/main/ctype_cp1251.result | 1 + mysql-test/main/ctype_latin1.result | 1 + mysql-test/main/ctype_ucs.result | 5 +- mysql-test/main/ctype_utf8.result | 1 + mysql-test/main/derived.result | 2 +- mysql-test/main/derived_cond_pushdown.result | 28 +- mysql-test/main/derived_cond_pushdown.test | 2 +- mysql-test/main/derived_opt.result | 2 +- mysql-test/main/derived_split_innodb.result | 8 +- mysql-test/main/derived_view.result | 14 +- mysql-test/main/derived_view.test | 2 + mysql-test/main/desc_index_range.result | 4 +- mysql-test/main/distinct.result | 2 +- mysql-test/main/explain.result | 25 +- mysql-test/main/explain.test | 3 +- mysql-test/main/explain_innodb.result | 2 +- mysql-test/main/explain_json.result | 36 +- mysql-test/main/explain_json.test | 4 +- mysql-test/main/func_group.result | 9 +- mysql-test/main/func_in.result | 16 +- mysql-test/main/greedy_optimizer.result | 109 +- mysql-test/main/greedy_optimizer.test | 22 +- mysql-test/main/group_by.result | 4 +- mysql-test/main/group_min_max.result | 26 +- mysql-test/main/index_intersect.result | 19 +- mysql-test/main/index_intersect.test | 1 - mysql-test/main/index_intersect_innodb.result | 23 +- mysql-test/main/index_merge_myisam.result | 8 +- mysql-test/main/innodb_ext_key,off.rdiff | 35 +- mysql-test/main/innodb_ext_key.result | 12 +- mysql-test/main/join.result | 24 +- mysql-test/main/join.test | 10 +- mysql-test/main/join_cache.result | 92 +- mysql-test/main/join_cache.test | 65 +- mysql-test/main/join_nested.result | 24 +- mysql-test/main/join_nested.test | 1 + mysql-test/main/join_nested_jcl6.result | 36 +- mysql-test/main/join_outer.result | 6 +- mysql-test/main/join_outer.test | 2 +- mysql-test/main/join_outer_innodb.result | 4 +- mysql-test/main/join_outer_jcl6.result | 6 +- mysql-test/main/key.result | 13 +- mysql-test/main/key.test | 3 + mysql-test/main/key_cache.result | 32 +- mysql-test/main/limit_rows_examined.result | 4 +- mysql-test/main/long_unique.result | 18 +- mysql-test/main/long_unique.test | 1 + mysql-test/main/multi_update.result | 4 +- mysql-test/main/myisam.result | 7 +- mysql-test/main/myisam.test | 5 + .../main/myisam_explain_non_select_all.result | 52 +- mysql-test/main/myisam_icp.result | 8 +- mysql-test/main/myisam_icp.test | 2 +- mysql-test/main/mysqld--help.result | 6 + mysql-test/main/negation_elimination.result | 6 +- mysql-test/main/null_key.result | 8 +- mysql-test/main/null_key.test | 7 + mysql-test/main/opt_trace.result | 2990 ++++++++++++----- mysql-test/main/opt_trace_index_merge.result | 146 +- .../main/opt_trace_index_merge_innodb.result | 33 +- mysql-test/main/opt_trace_security.result | 40 +- mysql-test/main/opt_trace_selectivity.result | 67 +- mysql-test/main/opt_trace_selectivity.test | 2 + mysql-test/main/opt_trace_ucs2.result | 2 +- mysql-test/main/opt_tvc.result | 43 +- mysql-test/main/opt_tvc.test | 2 +- mysql-test/main/order_by.result | 30 +- mysql-test/main/order_by.test | 10 + mysql-test/main/order_by_innodb.result | 26 +- mysql-test/main/order_by_innodb.test | 8 +- mysql-test/main/order_by_sortkey.result | 11 + mysql-test/main/order_by_sortkey.test | 5 + mysql-test/main/partition_pruning.result | 28 +- mysql-test/main/partition_pruning.test | 6 +- mysql-test/main/partition_range.result | 4 +- mysql-test/main/ps_1general.result | 2 +- mysql-test/main/ps_1general.test | 4 +- mysql-test/main/range.result | 185 +- mysql-test/main/range.test | 15 +- mysql-test/main/range_innodb.result | 7 +- mysql-test/main/range_innodb.test | 4 + mysql-test/main/range_mrr_icp.result | 91 +- mysql-test/main/range_notembedded.result | 10 +- mysql-test/main/range_notembedded.test | 1 + mysql-test/main/range_vs_index_merge.result | 4 +- mysql-test/main/range_vs_index_merge.test | 2 +- .../main/range_vs_index_merge_innodb.result | 6 +- mysql-test/main/rowid_filter.result | 508 +-- mysql-test/main/rowid_filter.test | 7 + mysql-test/main/rowid_filter_innodb.result | 326 +- mysql-test/main/select.result | 22 +- mysql-test/main/select.test | 8 +- mysql-test/main/select_jcl6.result | 34 +- mysql-test/main/select_pkeycache.result | 22 +- mysql-test/main/select_safe.result | 4 +- mysql-test/main/selectivity.result | 6 +- mysql-test/main/selectivity_innodb.result | 59 +- mysql-test/main/selectivity_no_engine.result | 4 +- mysql-test/main/show_explain.result | 4 +- mysql-test/main/show_explain_json.result | 6 +- mysql-test/main/single_delete_update.result | 26 +- mysql-test/main/single_delete_update.test | 2 + mysql-test/main/stat_tables.result | 13 +- mysql-test/main/stat_tables.test | 2 + mysql-test/main/stat_tables_innodb.result | 15 +- mysql-test/main/status.result | 10 +- mysql-test/main/subselect.result | 58 +- mysql-test/main/subselect.test | 8 +- mysql-test/main/subselect2.result | 10 +- mysql-test/main/subselect3.result | 10 +- mysql-test/main/subselect3_jcl6.result | 6 +- mysql-test/main/subselect4.result | 23 +- mysql-test/main/subselect_exists2in.result | 10 +- .../main/subselect_exists2in_costmat.result | 4 +- .../main/subselect_exists2in_costmat.test | 1 + mysql-test/main/subselect_extra.result | 4 +- mysql-test/main/subselect_innodb.result | 9 +- mysql-test/main/subselect_mat.result | 52 +- mysql-test/main/subselect_mat.test | 3 +- mysql-test/main/subselect_mat_cost.result | 14 +- mysql-test/main/subselect_mat_cost.test | 6 +- .../main/subselect_mat_cost_bugs.result | 6 +- .../main/subselect_no_exists_to_in.result | 58 +- mysql-test/main/subselect_no_mat.result | 56 +- mysql-test/main/subselect_no_opts.result | 32 +- mysql-test/main/subselect_no_scache.result | 58 +- mysql-test/main/subselect_no_semijoin.result | 32 +- mysql-test/main/subselect_sj.result | 120 +- mysql-test/main/subselect_sj.test | 14 +- mysql-test/main/subselect_sj2.result | 41 +- mysql-test/main/subselect_sj2.test | 2 - mysql-test/main/subselect_sj2_jcl6.result | 40 +- mysql-test/main/subselect_sj2_jcl6.test | 2 +- mysql-test/main/subselect_sj2_mat.result | 60 +- mysql-test/main/subselect_sj_jcl6.result | 94 +- mysql-test/main/subselect_sj_mat.result | 78 +- mysql-test/main/subselect_sj_nonmerged.result | 12 +- mysql-test/main/table_elim.result | 11 +- mysql-test/main/table_value_constr.result | 6 +- mysql-test/main/table_value_constr.test | 1 + mysql-test/main/tmp_table_count-7586.result | 2 + mysql-test/main/tmp_table_count-7586.test | 2 + mysql-test/main/type_blob.result | 2 +- mysql-test/main/type_datetime.result | 6 +- mysql-test/main/user_var.result | 4 +- mysql-test/main/view.test | 2 + mysql-test/main/xtradb_mrr.result | 6 + mysql-test/main/xtradb_mrr.test | 3 + .../compat/oracle/r/table_value_constr.result | 6 +- .../compat/oracle/t/table_value_constr.test | 1 + mysql-test/suite/gcol/inc/gcol_keys.inc | 6 + mysql-test/suite/gcol/inc/gcol_select.inc | 8 +- .../suite/gcol/r/gcol_keys_innodb.result | 6 +- .../suite/gcol/r/gcol_keys_myisam.result | 6 +- .../suite/gcol/r/gcol_select_innodb.result | 4 +- .../suite/gcol/r/gcol_select_myisam.result | 12 +- mysql-test/suite/heap/heap.result | 2 +- mysql-test/suite/heap/heap_btree.result | 4 + mysql-test/suite/heap/heap_btree.test | 2 + mysql-test/suite/innodb/r/innodb.result | 16 +- mysql-test/suite/innodb/r/innodb_mysql.result | 12 +- mysql-test/suite/innodb/r/mdev-14846.result | 14 +- .../suite/innodb/r/temporary_table.result | 2 +- .../r/temporary_table_optimization.result | 2 +- mysql-test/suite/innodb/t/innodb.test | 6 + mysql-test/suite/innodb/t/mdev-14846.test | 6 +- .../suite/innodb_fts/r/fulltext_misc.result | 10 +- mysql-test/suite/json/t/json_table.test | 1 + mysql-test/suite/maria/icp.result | 2 +- .../optimizer_unfixed_bugs/r/bug45221.result | 2 +- .../r/table_aggregate_global_2u_2t.result | 190 +- .../r/table_aggregate_global_2u_3t.result | 190 +- .../r/table_aggregate_global_4u_2t.result | 190 +- .../r/table_aggregate_global_4u_3t.result | 190 +- .../r/table_aggregate_hist_2u_2t.result | 354 +- .../r/table_aggregate_hist_2u_3t.result | 354 +- .../r/table_aggregate_hist_4u_2t.result | 354 +- .../r/table_aggregate_hist_4u_3t.result | 354 +- .../r/table_aggregate_thread_2u_2t.result | 314 +- .../r/table_aggregate_thread_2u_3t.result | 314 +- .../r/table_aggregate_thread_4u_2t.result | 314 +- .../r/table_aggregate_thread_4u_3t.result | 314 +- .../r/table_io_aggregate_global_2u_2t.result | 190 +- .../r/table_io_aggregate_global_2u_3t.result | 190 +- .../r/table_io_aggregate_global_4u_2t.result | 190 +- .../r/table_io_aggregate_global_4u_3t.result | 190 +- .../r/table_io_aggregate_hist_2u_2t.result | 354 +- .../r/table_io_aggregate_hist_2u_3t.result | 354 +- .../r/table_io_aggregate_hist_4u_2t.result | 354 +- .../r/table_io_aggregate_hist_4u_3t.result | 354 +- .../r/table_io_aggregate_thread_2u_2t.result | 314 +- .../r/table_io_aggregate_thread_2u_3t.result | 314 +- .../r/table_io_aggregate_thread_4u_2t.result | 314 +- .../r/table_io_aggregate_thread_4u_3t.result | 314 +- .../r/sysvars_server_notembedded.result | 10 + .../pr_statement_performance_analyzer.result | 7 +- .../t/pr_statement_performance_analyzer.test | 5 +- .../suite/vcol/r/vcol_select_myisam.result | 4 +- sql/filesort.cc | 13 +- sql/ha_partition.cc | 9 + sql/handler.cc | 33 +- sql/handler.h | 216 +- sql/multi_range_read.cc | 60 +- sql/my_json_writer.h | 2 +- sql/mysqld.cc | 5 +- sql/opt_range.cc | 234 +- sql/opt_split.cc | 22 +- sql/opt_subselect.cc | 303 +- sql/opt_subselect.h | 4 +- sql/opt_trace.cc | 7 +- sql/optimizer_costs.h | 94 +- sql/rowid_filter.cc | 76 +- sql/rowid_filter.h | 30 +- sql/set_var.cc | 1 - sql/set_var.h | 1 - sql/sql_base.cc | 1 + sql/sql_class.h | 9 +- sql/sql_select.cc | 793 +++-- sql/sql_select.h | 31 +- sql/sys_vars.cc | 44 +- sql/table.cc | 6 + sql/table.h | 44 +- .../mysql-test/connect/r/mysql_index.result | 13 +- .../mysql-test/connect/t/mysql_index.test | 3 +- storage/federated/ha_federated.cc | 14 +- storage/federated/ha_federated.h | 18 +- storage/federatedx/ha_federatedx.cc | 14 +- storage/federatedx/ha_federatedx.h | 17 +- storage/heap/ha_heap.cc | 4 +- storage/heap/ha_heap.h | 18 +- storage/innobase/handler/ha_innodb.cc | 22 + storage/innobase/handler/ha_innodb.h | 2 + ...mization_count_skip_index_not_equal.result | 2 +- .../mysql-test/spider/r/partition_mrr.result | 52 +- .../mysql-test/spider/t/partition_mrr.test | 1 + 243 files changed, 9309 insertions(+), 6820 deletions(-) create mode 100644 mysql-test/include/last_query_cost.inc create mode 100644 mysql-test/main/costs.result create mode 100644 mysql-test/main/costs.test diff --git a/mysql-test/include/ctype_numconv.inc b/mysql-test/include/ctype_numconv.inc index 6c7ac3b69fe..00364fd3406 100644 --- a/mysql-test/include/ctype_numconv.inc +++ b/mysql-test/include/ctype_numconv.inc @@ -1739,6 +1739,7 @@ CREATE TABLE t1 ( date_column DATE DEFAULT NULL, KEY(date_column)); INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01'); +INSERT INTO t1 VALUES (3,'2012-09-01'),(4,'2012-10-01'),(5,'2012-10-01'); EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL; EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; diff --git a/mysql-test/include/last_query_cost.inc b/mysql-test/include/last_query_cost.inc new file mode 100644 index 00000000000..a18fd9e4c04 --- /dev/null +++ b/mysql-test/include/last_query_cost.inc @@ -0,0 +1,5 @@ +--disable_query_log +--disable_column_names +show status like 'last_query_cost'; +--enable_column_names +--enable_query_log diff --git a/mysql-test/include/world.inc b/mysql-test/include/world.inc index 1e81c5c1aa7..a6f877ce0cd 100644 --- a/mysql-test/include/world.inc +++ b/mysql-test/include/world.inc @@ -4,6 +4,7 @@ # Table Country +BEGIN; INSERT IGNORE INTO Country VALUES ('AFG','Afghanistan',652090.00,22720000,1), ('NLD','Netherlands',41526.00,15864000,5), @@ -5339,5 +5340,6 @@ INSERT INTO CountryLanguage VALUES ('CHN','Dong',0.2), ('RUS','Belorussian',0.3), ('USA','Portuguese',0.2); +COMMIT; ANALYZE TABLE Country, City, CountryLanguage; diff --git a/mysql-test/main/costs.result b/mysql-test/main/costs.result new file mode 100644 index 00000000000..879d586790b --- /dev/null +++ b/mysql-test/main/costs.result @@ -0,0 +1,91 @@ +create table t1 (a int primary key, b int, c int, d int, e int, key ba (b,a), key bda (b,d,a), key cba (c,b,a), key cb (c,b), key d (d)) engine=aria; +insert into t1 select seq,seq,seq,seq,seq from seq_1_to_10; +insert into t1 values(20,2,2,2,2),(21,3,4,5,6); +# +# Get different scan costs +# +explain select sum(e) as "table_scan" from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 12 +Last_query_cost 5.500000 +explain select sum(a) as "index scan" from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 12 Using index +Last_query_cost 3.202929 +# +# Range scans should be used if we don't examine all rows in the table +# +explain select count(a) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Last_query_cost 0.000000 +explain select count(*) from t1 where a > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 12 Using where; Using index +Last_query_cost 3.202929 +explain select count(*) from t1 where a > 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 12 Using where; Using index +Last_query_cost 3.202929 +explain select count(*) from t1 where a > 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 11 Using where; Using index +Last_query_cost 2.997685 +# +# Shorter indexes are prefered over longer indexs +# +explain select sum(a+b) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL ba 9 NULL 12 Using index +Last_query_cost 3.204394 +explain select count(*) from t1 where b between 5 and 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ba,bda ba 5 NULL 6 Using where; Using index +Last_query_cost 1.872197 +explain select sum(b+c) from t1 where b between 5 and 6 and c between 5 and 6; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ba,bda,cba,cb cb 10 NULL 2 Using where; Using index +Last_query_cost 0.970781 +# Cost of 'd' should be slightly smaller as key 'ba' is longer than 'd' +explain select count(*) from t1 where b > 6; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ba,bda ba 5 NULL 5 Using where; Using index +Last_query_cost 1.646831 +explain select count(*) from t1 where d > 6; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range d d 5 NULL 5 Using where; Using index +Last_query_cost 1.646343 +# +# Check covering index usage +# +explain select a,b,c from t1 where a=b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL cba 14 NULL 12 Using where; Using index +Last_query_cost 3.205859 +# +# Prefer ref keys over ranges +# +explain select count(*) from t1 where b=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref ba,bda ba 5 const 2 Using index +Last_query_cost 0.950732 +explain select count(*) from t1 where b=2 and c=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref ba,bda,cba,cb cb 10 const,const 2 Using index +Last_query_cost 0.950781 +explain select count(*) from t1 where b=3 and c between 3 and 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ba,bda,cba,cb cb 10 NULL 2 Using where; Using index +Last_query_cost 0.970781 +# +# Prefer eq keys over ref keys +# +explain select a,b,e from t1 where a=10 or a=11; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition +Last_query_cost 2.520488 +explain select a,b,e from t1 where d=10 or d=11; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range d d 5 NULL 2 Using index condition +Last_query_cost 2.520537 +drop table t1; diff --git a/mysql-test/main/costs.test b/mysql-test/main/costs.test new file mode 100644 index 00000000000..6dcc41b57a3 --- /dev/null +++ b/mysql-test/main/costs.test @@ -0,0 +1,75 @@ +# +# Test of cost calcuations. This test is using the Aria engine as the cost +# calculations are stable for it. +# +--source include/have_sequence.inc + +create table t1 (a int primary key, b int, c int, d int, e int, key ba (b,a), key bda (b,d,a), key cba (c,b,a), key cb (c,b), key d (d)) engine=aria; +insert into t1 select seq,seq,seq,seq,seq from seq_1_to_10; +insert into t1 values(20,2,2,2,2),(21,3,4,5,6); + +--echo # +--echo # Get different scan costs +--echo # + +explain select sum(e) as "table_scan" from t1; +--source include/last_query_cost.inc +explain select sum(a) as "index scan" from t1; +--source include/last_query_cost.inc + +--echo # +--echo # Range scans should be used if we don't examine all rows in the table +--echo # +explain select count(a) from t1; +--source include/last_query_cost.inc +explain select count(*) from t1 where a > 0; +--source include/last_query_cost.inc +explain select count(*) from t1 where a > 1; +--source include/last_query_cost.inc +explain select count(*) from t1 where a > 2; +--source include/last_query_cost.inc + +--echo # +--echo # Shorter indexes are prefered over longer indexs +--echo # +explain select sum(a+b) from t1; +--source include/last_query_cost.inc +explain select count(*) from t1 where b between 5 and 10; +--source include/last_query_cost.inc +explain select sum(b+c) from t1 where b between 5 and 6 and c between 5 and 6; +--source include/last_query_cost.inc + +--echo # Cost of 'd' should be slightly smaller as key 'ba' is longer than 'd' +explain select count(*) from t1 where b > 6; +--source include/last_query_cost.inc +explain select count(*) from t1 where d > 6; +--source include/last_query_cost.inc + + +--echo # +--echo # Check covering index usage +--echo # +explain select a,b,c from t1 where a=b; +--source include/last_query_cost.inc + +--echo # +--echo # Prefer ref keys over ranges +--echo # + +explain select count(*) from t1 where b=2; +--source include/last_query_cost.inc +explain select count(*) from t1 where b=2 and c=2; +--source include/last_query_cost.inc +explain select count(*) from t1 where b=3 and c between 3 and 4; +--source include/last_query_cost.inc + +--echo # +--echo # Prefer eq keys over ref keys +--echo # + +explain select a,b,e from t1 where a=10 or a=11; +--source include/last_query_cost.inc +explain select a,b,e from t1 where d=10 or d=11; +--source include/last_query_cost.inc + +drop table t1; diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result index f7871d4f929..7ad246941ae 100644 --- a/mysql-test/main/cte_nonrecursive.result +++ b/mysql-test/main/cte_nonrecursive.result @@ -418,8 +418,8 @@ t2.c in (with t as (select * from t1 where t1.a<5) select t2.c from t2,t where t2.c=t.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where 3 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) explain @@ -430,8 +430,8 @@ from t2,(select * from t1 where t1.a<5) as t where t2.c=t.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) # two different definitions of t: one in the with clause of the main query, @@ -461,8 +461,8 @@ t.c in (with t as (select * from t1 where t1.a<5) select t2.c from t2,t where t2.c=t.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 4 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where 4 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) explain @@ -472,8 +472,8 @@ t.c in (select t2.c from t2, (select * from t1 where t1.a<5) as t where t2.c=t.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where 3 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) # another with table tt is defined in the with clause of a subquery diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index a754b923ecf..a7b73b80845 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -4565,9 +4565,9 @@ id select_type table type possible_keys key key_len ref rows Extra 4 RECURSIVE UNION ALL NULL NULL NULL NULL 2 5 RECURSIVE UNION ALL NULL NULL NULL NULL 2 NULL UNION RESULT ALL NULL NULL NULL NULL NULL -2 DERIVED h ALL NULL NULL NULL NULL 12 -2 DERIVED ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) -2 DERIVED w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (incremental, BNL join) +2 DERIVED h ALL NULL NULL NULL NULL 12 Using where +2 DERIVED ref key0 key0 5 test.h.id 2 +2 DERIVED w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) prepare stmt from "with recursive ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, w_id, w_name, w_dob, w_father, w_mother) diff --git a/mysql-test/main/ctype_binary.result b/mysql-test/main/ctype_binary.result index 24fc961e17d..1dd5f93ad17 100644 --- a/mysql-test/main/ctype_binary.result +++ b/mysql-test/main/ctype_binary.result @@ -2763,6 +2763,7 @@ id INT(11) DEFAULT NULL, date_column DATE DEFAULT NULL, KEY(date_column)); INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01'); +INSERT INTO t1 VALUES (3,'2012-09-01'),(4,'2012-10-01'),(5,'2012-10-01'); EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition diff --git a/mysql-test/main/ctype_cp1251.result b/mysql-test/main/ctype_cp1251.result index a341d9ce471..475058dc2bb 100644 --- a/mysql-test/main/ctype_cp1251.result +++ b/mysql-test/main/ctype_cp1251.result @@ -3175,6 +3175,7 @@ id INT(11) DEFAULT NULL, date_column DATE DEFAULT NULL, KEY(date_column)); INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01'); +INSERT INTO t1 VALUES (3,'2012-09-01'),(4,'2012-10-01'),(5,'2012-10-01'); EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition diff --git a/mysql-test/main/ctype_latin1.result b/mysql-test/main/ctype_latin1.result index 5be12e91b68..4088530fc0f 100644 --- a/mysql-test/main/ctype_latin1.result +++ b/mysql-test/main/ctype_latin1.result @@ -3484,6 +3484,7 @@ id INT(11) DEFAULT NULL, date_column DATE DEFAULT NULL, KEY(date_column)); INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01'); +INSERT INTO t1 VALUES (3,'2012-09-01'),(4,'2012-10-01'),(5,'2012-10-01'); EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition diff --git a/mysql-test/main/ctype_ucs.result b/mysql-test/main/ctype_ucs.result index ce0d695797b..ce8e1c2e83b 100644 --- a/mysql-test/main/ctype_ucs.result +++ b/mysql-test/main/ctype_ucs.result @@ -1569,7 +1569,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 23 NULL 1 Using where; Using index EXPLAIN SELECT * FROM t1 WHERE a LIKE 'c%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 23 NULL 31 Using where; Using index +1 SIMPLE t1 index a a 23 NULL 31 Using where; Using index SELECT * FROM t1 WHERE a LIKE 'c%'; a ca @@ -1585,7 +1585,7 @@ ch ALTER TABLE t1 MODIFY a VARCHAR(10) CHARACTER SET ucs2 COLLATE ucs2_croatian_ci; EXPLAIN SELECT * FROM t1 WHERE a LIKE 'd%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 23 NULL 31 Using where; Using index +1 SIMPLE t1 index a a 23 NULL 31 Using where; Using index SELECT hex(concat('d',_ucs2 0x017E,'%')); hex(concat('d',_ucs2 0x017E,'%')) 0064017E0025 @@ -4368,6 +4368,7 @@ id INT(11) DEFAULT NULL, date_column DATE DEFAULT NULL, KEY(date_column)); INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01'); +INSERT INTO t1 VALUES (3,'2012-09-01'),(4,'2012-10-01'),(5,'2012-10-01'); EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition diff --git a/mysql-test/main/ctype_utf8.result b/mysql-test/main/ctype_utf8.result index 5986ea3ac81..6d50a6cee2e 100644 --- a/mysql-test/main/ctype_utf8.result +++ b/mysql-test/main/ctype_utf8.result @@ -5235,6 +5235,7 @@ id INT(11) DEFAULT NULL, date_column DATE DEFAULT NULL, KEY(date_column)); INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01'); +INSERT INTO t1 VALUES (3,'2012-09-01'),(4,'2012-10-01'),(5,'2012-10-01'); EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result index 268b111cd77..6f6fccf35d9 100644 --- a/mysql-test/main/derived.result +++ b/mysql-test/main/derived.result @@ -237,7 +237,7 @@ count(*) explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 2 -1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 THEMAX.E2 1 Using where +1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 2 DERIVED A ALL NULL NULL NULL NULL 2 Using where 3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where drop table t1; diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index a17580d9943..9be0a96ef77 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -19188,7 +19188,7 @@ DROP TABLE t1; CREATE TABLE t1 (pk1 INT PRIMARY KEY, f INT) ENGINE=Aria; INSERT INTO t1 VALUES (1,0),(2,0); CREATE TABLE t2 (pk2 INT PRIMARY KEY) ENGINE=Aria; -INSERT INTO t2 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (1),(2),(3),(11),(12),(13); CREATE VIEW v2 AS SELECT pk2, COUNT(*) AS cnt FROM t2 GROUP BY pk2; SELECT * FROM t1 INNER JOIN v2 ON pk1 = pk2 WHERE f <> 5; pk1 f pk2 cnt @@ -19506,8 +19506,8 @@ explain extended select id, a from t1 where id in (select id from v1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 20 100.00 1 PRIMARY ref key0 key0 4 test.t1.id 2 100.00 FirstMatch(t1) -3 LATERAL DERIVED t1 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 100.00 -3 LATERAL DERIVED t2 ref ro_id ro_id 4 test.t1.id 1 100.00 Using where +3 DERIVED t1 ALL PRIMARY NULL NULL NULL 20 100.00 Using temporary; Using filesort +3 DERIVED t2 ref ro_id ro_id 4 test.t1.id 1 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`v1`) where `v1`.`id` = `test`.`t1`.`id` select id, a from t1 @@ -19544,10 +19544,10 @@ group by t1.id) dt); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 20 100.00 1 PRIMARY ref key0 key0 4 test.t1.id 2 100.00 FirstMatch(t1) -3 LATERAL DERIVED t1 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 100.00 -3 LATERAL DERIVED t2 ref ro_id ro_id 4 test.t1.id 1 100.00 Using where +3 DERIVED t1 ALL PRIMARY NULL NULL NULL 20 100.00 Using temporary; Using filesort +3 DERIVED t2 ref ro_id ro_id 4 test.t1.id 1 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`ro_id` = `test`.`t1`.`id` and `test`.`t2`.`flag` = 1) where `test`.`t1`.`id` = `test`.`t1`.`id` group by `test`.`t1`.`id`) `dt`) where `dt`.`id` = `test`.`t1`.`id` +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`ro_id` = `test`.`t1`.`id` and `test`.`t2`.`flag` = 1) where 1 group by `test`.`t1`.`id`) `dt`) where `dt`.`id` = `test`.`t1`.`id` drop view v1; drop table t1,t2; # @@ -20061,7 +20061,7 @@ JOIN (SELECT t1_id FROM t2 WHERE reporting_person = 1 GROUP BY t1_id) tx ON tx.t1_id = t1.id WHERE t1.id BETWEEN 200 AND 100000; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 range t1_id t1_id 5 NULL 47 Using where; Using index +1 PRIMARY t3 index t1_id t1_id 15 NULL 47 Using where; Using index 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.t1_id 1 Using index 1 PRIMARY ref key0 key0 5 test.t3.t1_id 2 2 LATERAL DERIVED t2 ref t1_id t1_id 5 test.t1.id 3 Using index condition; Using where @@ -20080,11 +20080,11 @@ EXPLAIN { "table": { "table_name": "t3", - "access_type": "range", + "access_type": "index", "possible_keys": ["t1_id"], "key": "t1_id", - "key_length": "5", - "used_key_parts": ["t1_id"], + "key_length": "15", + "used_key_parts": ["t1_id", "YEAR", "quarter"], "rows": 47, "filtered": 100, "attached_condition": "t3.t1_id between 200 and 100000 and t3.t1_id is not null", @@ -20416,8 +20416,8 @@ WHERE charges.to_ledger_id = 2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY charges ALL PRIMARY,fk_charge_from_ledger,fk_charge_to_ledger NULL NULL NULL 20 Using where 1 PRIMARY ref key0 key0 17 test.charges.from_ledger_id,test.charges.id 4 -2 DERIVED transaction_items ALL fk_items_transaction NULL NULL NULL 40 Using temporary; Using filesort -2 DERIVED transactions eq_ref PRIMARY PRIMARY 8 test.transaction_items.transaction_id 1 +2 DERIVED transactions ALL PRIMARY NULL NULL NULL 40 Using temporary; Using filesort +2 DERIVED transaction_items ref fk_items_transaction fk_items_transaction 8 test.transactions.id 1 INSERT INTO charges (id, from_ledger_id, to_ledger_id, amount) VALUES (101, 4, 2, 100), (102, 7, 2, 200); set optimizer_switch='split_materialized=on'; @@ -20608,8 +20608,8 @@ WHERE charges.to_ledger_id = 2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY charges ALL fk_charge_to_ledger NULL NULL NULL 20 Using where 1 PRIMARY ref key0 key0 18 test.charges.from_ledger_id,test.charges.id 4 -2 DERIVED transaction_items ALL fk_items_transaction NULL NULL NULL 40 Using temporary; Using filesort -2 DERIVED transactions eq_ref PRIMARY PRIMARY 8 test.transaction_items.transaction_id 1 +2 DERIVED transactions ALL PRIMARY NULL NULL NULL 40 Using temporary; Using filesort +2 DERIVED transaction_items ref fk_items_transaction fk_items_transaction 8 test.transactions.id 1 set optimizer_switch='split_materialized=default'; DROP TABLE transaction_items; DROP TABLE transactions; diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index 39e82210e4c..a09fd1b59e3 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -3324,7 +3324,7 @@ CREATE TABLE t1 (pk1 INT PRIMARY KEY, f INT) ENGINE=Aria; INSERT INTO t1 VALUES (1,0),(2,0); CREATE TABLE t2 (pk2 INT PRIMARY KEY) ENGINE=Aria; -INSERT INTO t2 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (1),(2),(3),(11),(12),(13); CREATE VIEW v2 AS SELECT pk2, COUNT(*) AS cnt FROM t2 GROUP BY pk2; diff --git a/mysql-test/main/derived_opt.result b/mysql-test/main/derived_opt.result index cf0c1cb617f..4033f381458 100644 --- a/mysql-test/main/derived_opt.result +++ b/mysql-test/main/derived_opt.result @@ -111,7 +111,7 @@ count(*) explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY A ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.A.E2 1 Using where +1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where drop table t1; create table t1 (a int); diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index 7a680d3a0df..be3de7dbc02 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -21,7 +21,7 @@ WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ref c1,n1_c1_n2 c1 1 const 2 Using index condition; Using where; Using temporary; Using filesort 1 PRIMARY ref key0 key0 8 test.t1.n1,test.t1.n2 2 -2 LATERAL DERIVED t1 ref c1,n1_c1_n2 n1_c1_n2 4 test.t1.n1 1 Using where; Using index +2 DERIVED t1 ref c1,n1_c1_n2 c1 1 const 2 Using index condition; Using where; Using temporary; Using filesort SELECT t1.n1 FROM t1, (SELECT n1, n2 FROM t1 WHERE c1 = 'a' GROUP BY n1) as t WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1; n1 @@ -175,8 +175,8 @@ t1.a = dt.a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a,a_2 a_2 10 NULL 6 Using where; Using index 1 PRIMARY ref key0 key0 5 test.t1.a 2 -3 LATERAL DERIVED t1 ref a,a_2 a 5 test.t1.a 1 Using where; Using temporary; Using filesort -3 LATERAL DERIVED t2 ref c c 5 test.t1.b 1 Using index +3 DERIVED t1 index a,a_2 a_2 10 NULL 6 Using where; Using index; Using temporary; Using filesort +3 DERIVED t2 ref c c 5 test.t1.b 1 Using index DROP TABLE t1, t2; # # Bug mdev-25714: usage non-splitting covering index is cheaper than @@ -210,7 +210,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 1 PRIMARY t1 ref idx idx 4 test.t2.id 1 1 PRIMARY ref key0 key0 9 test.t2.id,test.t1.id 2 -2 DERIVED t3 ref idx1,idx2 idx1 4 const 5 Using where; Using index +2 LATERAL DERIVED t3 ref idx1,idx2 idx2 4 test.t1.itemid 1 Using index condition; Using where select t1.id, t1.itemid, dt.id, t2.id from t1, (select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index b86cd1c42cc..a64894441c8 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -1881,14 +1881,14 @@ WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM t3 t); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY t unique_subquery PRIMARY,c PRIMARY 4 func 1 Using where +2 DEPENDENT SUBQUERY t index_subquery PRIMARY,c c 8 func,func 2 Using index; Using where EXPLAIN SELECT * FROM t1 , t2 WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,c PRIMARY 4 func 1 Using where +2 DEPENDENT SUBQUERY t3 index_subquery PRIMARY,c c 8 func,func 2 Using index; Using where SELECT * FROM t1 , t2 WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t); b a @@ -1931,8 +1931,8 @@ WHERE t3.b IN (SELECT v1.b FROM v1, t2 WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 system NULL NULL NULL NULL 1 -1 PRIMARY ref key1 key1 8 const,const 0 Start temporary -1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY ref key1 key1 8 const,const 0 FirstMatch(t3) 3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where SELECT * FROM t3 WHERE t3.b IN (SELECT v1.b FROM v1, t2 @@ -2439,10 +2439,14 @@ CREATE TABLE t2 (a int, INDEX(a)); INSERT INTO t2 VALUES (1), (2); INSERT INTO t1 SELECT a FROM (SELECT a FROM test.t1) AS s1 NATURAL JOIN t2 AS s2; +INSERT INTO t1 SELECT a FROM (SELECT a FROM test.t1) AS s1 NATURAL JOIN +t2 AS s2; SELECT * FROM t1; a 1 1 +1 +1 DELETE FROM t1; INSERT INTO t1 VALUES (1); PREPARE stmt FROM " @@ -2459,6 +2463,8 @@ SELECT * FROM t1; a 1 1 +1 +1 drop table t1,t2; set optimizer_switch=@save968720_optimizer_switch; # diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index caccc7dafa1..c511b8febc9 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -1417,6 +1417,8 @@ INSERT INTO t1 VALUES (1); CREATE TABLE t2 (a int, INDEX(a)); INSERT INTO t2 VALUES (1), (2); +INSERT INTO t1 SELECT a FROM (SELECT a FROM test.t1) AS s1 NATURAL JOIN +t2 AS s2; INSERT INTO t1 SELECT a FROM (SELECT a FROM test.t1) AS s1 NATURAL JOIN t2 AS s2; SELECT * FROM t1; diff --git a/mysql-test/main/desc_index_range.result b/mysql-test/main/desc_index_range.result index 6b1f2e31c31..a540efe33d6 100644 --- a/mysql-test/main/desc_index_range.result +++ b/mysql-test/main/desc_index_range.result @@ -146,7 +146,7 @@ CREATE TABLE t1 (p int NOT NULL, a int NOT NULL, PRIMARY KEY (p,a desc)); insert into t1 select 2,seq from seq_0_to_1000; EXPLAIN select MIN(a) from t1 where p = 2 group by p; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY PRIMARY 4 const 1000 Using index +1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 1001 Using where; Using index select json_detailed(json_extract(trace, '$**.potential_group_range_indexes')) from information_schema.optimizer_trace; json_detailed(json_extract(trace, '$**.potential_group_range_indexes')) @@ -194,7 +194,7 @@ test.t1 analyze status OK # Must use ROR-intersect: explain select * from t1 where b = 255 AND a IS NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge a,b b,a 5,5 NULL 1 Using intersect(b,a); Using where; Using index +1 SIMPLE t1 ref a,b b 5 const 2 Using where select * from t1 where b = 255 AND a IS NULL; pk a b 10000 NULL 255 diff --git a/mysql-test/main/distinct.result b/mysql-test/main/distinct.result index b422d3b286e..3064e062781 100644 --- a/mysql-test/main/distinct.result +++ b/mysql-test/main/distinct.result @@ -175,7 +175,7 @@ explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using temporary 1 SIMPLE t3 ref a a 5 test.t1.b 2 Using index -1 SIMPLE t2 index a a 4 NULL 5 Using where; Using index; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref a a 4 test.t1.a 2 Using index; Distinct SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; a 1 diff --git a/mysql-test/main/explain.result b/mysql-test/main/explain.result index 8db5e9f51ac..a5ad9fad4ba 100644 --- a/mysql-test/main/explain.result +++ b/mysql-test/main/explain.result @@ -325,7 +325,7 @@ DROP TABLE t1; # Bug#56814 Explain + subselect + fulltext crashes server # CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, -FULLTEXT KEY(f1),UNIQUE(f1)); +FULLTEXT KEY `fulltext` (f1), UNIQUE `unique` (f1)); INSERT INTO t1 VALUES ('test'); EXPLAIN SELECT 1 FROM t1 WHERE 1 > ALL((SELECT t1.f1 FROM t1 JOIN t1 a ON (MATCH(t1.f1) AGAINST ("")) @@ -333,7 +333,9 @@ WHERE t1.f1 GROUP BY t1.f1)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 2 SUBQUERY a system NULL NULL NULL NULL 1 -2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY t1 index unique,fulltext unique 8 NULL 1 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'test' PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE 1 > ALL((SELECT t1.f1 FROM t1 RIGHT OUTER JOIN t1 a @@ -343,12 +345,16 @@ EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 2 SUBQUERY a system NULL NULL NULL NULL 1 -2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY t1 index unique,fulltext unique 8 NULL 1 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'test' EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 2 SUBQUERY a system NULL NULL NULL NULL 1 -2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY t1 index unique,fulltext unique 8 NULL 1 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'test' DEALLOCATE PREPARE stmt; PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 @@ -359,12 +365,15 @@ EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 2 SUBQUERY a system NULL NULL NULL NULL 1 -2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY t1 index unique,fulltext unique 8 NULL 1 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'test' +INSERT into t1 values('test1'),('test2'),('test3'),('test4'),('test5'); EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 system NULL NULL NULL NULL 1 -2 SUBQUERY a system NULL NULL NULL NULL 1 -2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +1 PRIMARY t1 index NULL unique 8 NULL 6 Using index +2 SUBQUERY t1 fulltext unique,fulltext fulltext 0 1 Using where +2 SUBQUERY a index NULL unique 8 NULL 6 Using index DEALLOCATE PREPARE stmt; DROP TABLE t1; End of 5.1 tests. diff --git a/mysql-test/main/explain.test b/mysql-test/main/explain.test index 36595ba727c..0e4a3b8c2c0 100644 --- a/mysql-test/main/explain.test +++ b/mysql-test/main/explain.test @@ -254,7 +254,7 @@ DROP TABLE t1; --echo # CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, -FULLTEXT KEY(f1),UNIQUE(f1)); +FULLTEXT KEY `fulltext` (f1), UNIQUE `unique` (f1)); INSERT INTO t1 VALUES ('test'); EXPLAIN SELECT 1 FROM t1 @@ -279,6 +279,7 @@ PREPARE stmt FROM WHERE t1.f1 GROUP BY t1.f1))'; EXECUTE stmt; +INSERT into t1 values('test1'),('test2'),('test3'),('test4'),('test5'); EXECUTE stmt; DEALLOCATE PREPARE stmt; diff --git a/mysql-test/main/explain_innodb.result b/mysql-test/main/explain_innodb.result index 0bdd5a44985..fe51e45e35d 100644 --- a/mysql-test/main/explain_innodb.result +++ b/mysql-test/main/explain_innodb.result @@ -15,6 +15,6 @@ explain SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 DERIVED t1 range NULL id 53 NULL 1 Using index for group-by +2 DERIVED t1 index NULL id 53 NULL 1 Using index SET GLOBAL slow_query_log = @sql_tmp; drop table t1; diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index 3c3c0688ab8..fde96bc1a14 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -728,6 +728,19 @@ EXPLAIN "filtered": 100 } }, + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL" + } + }, { "table": { "table_name": "", @@ -756,19 +769,6 @@ EXPLAIN } } } - }, - { - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "1Kb", - "join_type": "BNL" - } } ] } @@ -930,9 +930,9 @@ drop table t0; # MDEV-7265: "Full scan on NULL key", the join case # CREATE TABLE t1 (a INT, KEY(a)); -INSERT INTO t1 VALUES (1),(2); +INSERT INTO t1 VALUES (1),(2),(5),(6),(7); CREATE TABLE t2 (b INT); -INSERT INTO t2 VALUES (3),(4); +INSERT INTO t2 VALUES (3),(4),(9),(10),(11); EXPLAIN FORMAT=JSON SELECT * FROM t1 AS outer_t1 WHERE a <> ALL ( SELECT a FROM t1, t2 WHERE b <> outer_t1.a ); EXPLAIN { @@ -946,7 +946,7 @@ EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], - "rows": 2, + "rows": 5, "filtered": 100, "attached_condition": "!(outer_t1.a,(subquery#2))", "using_index": true @@ -969,7 +969,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["func"], - "rows": 2, + "rows": 3, "filtered": 100, "attached_condition": "trigcond((outer_t1.a) = t1.a or t1.a is null)", "using_index": true @@ -981,7 +981,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", - "rows": 2, + "rows": 5, "filtered": 100 }, "buffer_type": "flat", diff --git a/mysql-test/main/explain_json.test b/mysql-test/main/explain_json.test index 17e2da4754c..baf1aa988a2 100644 --- a/mysql-test/main/explain_json.test +++ b/mysql-test/main/explain_json.test @@ -163,10 +163,10 @@ drop table t0; --echo # CREATE TABLE t1 (a INT, KEY(a)); -INSERT INTO t1 VALUES (1),(2); +INSERT INTO t1 VALUES (1),(2),(5),(6),(7); CREATE TABLE t2 (b INT); -INSERT INTO t2 VALUES (3),(4); +INSERT INTO t2 VALUES (3),(4),(9),(10),(11); EXPLAIN FORMAT=JSON SELECT * FROM t1 AS outer_t1 WHERE a <> ALL ( SELECT a FROM t1, t2 WHERE b <> outer_t1.a ); diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result index 8f9c27eeb86..5d9b1df58ba 100644 --- a/mysql-test/main/func_group.result +++ b/mysql-test/main/func_group.result @@ -607,7 +607,7 @@ id select_type table type possible_keys key key_len ref rows Extra explain select min(a1) from t1 where (a1 < 'KKK' or a1 > 'KKK'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 3 NULL 14 Using where; Using index +1 SIMPLE t1 index PRIMARY PRIMARY 3 NULL 15 Using where; Using index explain select max(a3) from t1 where a2 < 2 and a3 < 'SEA'; id select_type table type possible_keys key key_len ref rows Extra @@ -652,7 +652,7 @@ id select_type table type possible_keys key key_len ref rows Extra explain select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range k2 k2 4 NULL 6 Using where; Using index +1 SIMPLE t2 index k2 k2 4 NULL 7 Using where; Using index 1 SIMPLE t1 index NULL PRIMARY 3 NULL 15 Using index; Using join buffer (flat, BNL join) drop table t1, t2; create table t1 (a char(10)); @@ -1336,7 +1336,7 @@ INSERT INTO t2 ( a, b, c ) VALUES ( 1, NULL, 2 ), ( 1, 3, 4 ), ( 1, 4, 4 ), ( 2, NULL, 2 ), ( 2, 3, 4 ), ( 2, 4, 4 ); EXPLAIN SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref a a 5 const 3 +1 SIMPLE t2 ALL a NULL NULL NULL 6 Using where SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1; MIN(b) MIN(c) 3 2 @@ -1856,9 +1856,8 @@ NULL EXPLAIN EXTENDED SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT a,b FROM t2 WHERE b<5) and a<10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; FirstMatch 1 PRIMARY t1 range a a 4 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = 1 and `test`.`t2`.`b` = 2 and `test`.`t1`.`a` < 10 SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT a,b FROM t2 WHERE b<5) and a<10; diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result index 175e23ec65f..13eb9501599 100644 --- a/mysql-test/main/func_in.result +++ b/mysql-test/main/func_in.result @@ -521,7 +521,7 @@ a b explain select f1 from t1 where f1 in ('a','b'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range t1f1_idx t1f1_idx 2 NULL 2 Using where; Using index +1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index select f1 from t1 where f1 in (2,1); f1 1 @@ -957,7 +957,7 @@ a # Conversion to equality is impossible due to different values EXPLAIN SELECT * FROM t1 WHERE a IN (1,1,2); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a IN (1,NULL,1); a 1 @@ -1030,7 +1030,7 @@ a b # No conversion due to different values EXPLAIN SELECT * FROM t2 WHERE (a,b) IN ((2,'def'),(2,'def'),(2,'XYZ')); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range PRIMARY PRIMARY 16 NULL 2 Using where; Using index +1 SIMPLE t2 index PRIMARY PRIMARY 16 NULL 3 Using where; Using index SELECT * FROM t2 WHERE (a,b) IN ((2,'def'),(2,'def'),(2,NULL)); a b 2 def @@ -1078,7 +1078,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 const PRIMARY PRIMARY 4 const 1 Using index EXECUTE stmt USING 2,3,4; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index +1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index DEALLOCATE PREPARE stmt; DROP TABLE t1, t2, t3; # Nested joins @@ -1104,7 +1104,7 @@ AND t3.a IN (1,2); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) -1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (incremental, BNL join) +1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index; Using join buffer (incremental, BNL join) 1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join) # Conversion to equalities EXPLAIN SELECT * FROM t1 LEFT JOIN ((t2, t3) LEFT JOIN t4 ON t2.a = t4.a) @@ -1118,7 +1118,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT * FROM t1 LEFT JOIN ((t2, t3) LEFT JOIN t4 ON t2.a = t4.a) ON t1.a = t2.a WHERE t1.a IN (1,3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where 1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t3 index NULL PRIMARY 4 NULL 4 Using index @@ -1131,7 +1131,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 EXPLAIN SELECT * FROM v1 WHERE a IN (1,2,3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using index condition +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where 1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 # Stored procedures CREATE PROCEDURE p1(pa INT, pb INT) @@ -1141,7 +1141,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 CALL p1(2,1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where DROP TABLE t1, t2, t3, t4; DROP VIEW v1; DROP PROCEDURE p1; diff --git a/mysql-test/main/greedy_optimizer.result b/mysql-test/main/greedy_optimizer.result index 7e1220d3904..f424b5036a0 100644 --- a/mysql-test/main/greedy_optimizer.result +++ b/mysql-test/main/greedy_optimizer.result @@ -127,7 +127,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 @@ -139,7 +139,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -151,7 +151,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1559.791393 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -163,7 +163,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1559.791393 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -175,7 +175,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1563.335143 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -187,7 +187,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1563.335143 set optimizer_prune_level=0; select @@optimizer_prune_level; @@optimizer_prune_level @@ -202,24 +202,24 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 2705.237037 +Last_query_cost 2693.038350 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 2705.237037 +Last_query_cost 2693.038350 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where @@ -231,7 +231,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 701.018727 +Last_query_cost 751.472751 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where @@ -243,7 +243,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 701.018727 +Last_query_cost 751.472751 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where @@ -255,7 +255,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 701.018727 +Last_query_cost 760.922751 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where @@ -267,7 +267,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 701.018727 +Last_query_cost 760.922751 set optimizer_search_depth=1; select @@optimizer_search_depth; @@optimizer_search_depth @@ -283,7 +283,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 @@ -295,7 +295,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where @@ -307,7 +307,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1678.037037 +Last_query_cost 2068.798851 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where @@ -319,7 +319,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1678.037037 +Last_query_cost 2068.798851 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where @@ -331,7 +331,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1678.037037 +Last_query_cost 2073.523851 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where @@ -343,7 +343,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1678.037037 +Last_query_cost 2073.523851 set optimizer_search_depth=62; select @@optimizer_search_depth; @@optimizer_search_depth @@ -354,24 +354,24 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 2705.237037 +Last_query_cost 2693.038350 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 2705.237037 +Last_query_cost 2693.038350 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where @@ -383,7 +383,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 701.018727 +Last_query_cost 751.472751 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where @@ -395,7 +395,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 701.018727 +Last_query_cost 751.472751 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where @@ -407,7 +407,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 701.018727 +Last_query_cost 760.922751 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where @@ -419,7 +419,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 701.018727 +Last_query_cost 760.922751 set optimizer_prune_level=2; select @@optimizer_prune_level; @@optimizer_prune_level @@ -439,7 +439,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 @@ -451,7 +451,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -463,7 +463,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1559.791393 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -475,7 +475,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1559.791393 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -487,7 +487,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1563.335143 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -499,7 +499,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1563.335143 set optimizer_search_depth=1; select @@optimizer_search_depth; @@optimizer_search_depth @@ -515,7 +515,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 @@ -527,7 +527,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where @@ -539,7 +539,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1678.037037 +Last_query_cost 2068.798851 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where @@ -551,7 +551,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1678.037037 +Last_query_cost 2068.798851 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where @@ -563,7 +563,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1678.037037 +Last_query_cost 2073.523851 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where @@ -575,7 +575,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1678.037037 +Last_query_cost 2073.523851 set optimizer_search_depth=62; select @@optimizer_search_depth; @@optimizer_search_depth @@ -591,7 +591,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 @@ -603,7 +603,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 3350.237037 +Last_query_cost 2696.338350 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -615,7 +615,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1559.791393 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -627,7 +627,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1559.791393 explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -639,7 +639,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1563.335143 explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 @@ -651,7 +651,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 1276.787037 +Last_query_cost 1563.335143 drop table t1,t2,t3,t4,t5,t6,t7; CREATE TABLE t1 (a int, b int, d int, i int); INSERT INTO t1 VALUES (1,1,1,1); @@ -802,6 +802,9 @@ WHERE t100.K=t10.I AND t10000.K=t10.I; COUNT(*) 9 +##### +# Expect all variants of EQ joining t100 & t10000 with T10 +# to have same cost # handler_reads: flush status; EXPLAIN SELECT COUNT(*) FROM t10,t100,t10000 WHERE t100.K=t10.I @@ -909,6 +912,12 @@ AND t10000.K=t10.K; COUNT(*) 9 ### NOTE: Handler_reads: 31, expected: 30 ### +##### +## EQ_REF Should be executed before table scan(ALL) +## - Independent of #records in table being EQ_REF-joined +##### +##### +# Expect: Join EQ_REF(t100) before ALL(t10000) flush status; EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000 WHERE t100.K=t10.I @@ -948,6 +957,8 @@ WHERE t100.K=t10.I AND t10000.I=t10.I; COUNT(*) 9000 +##### +# Expect: Join EQ_REF(t10000) before ALL(t100) (star-join) flush status; EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100 WHERE t100.I=t10.I @@ -2902,7 +2913,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 AS x JOIN t1 ON t1.K=x.I JOIN t2 ON t2.K=x.I JOI DROP TABLE t100, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49, t50, t51, t52, t53, t54, t55, t56, t57, t58, t59, t60, t61; show status like "optimizer%"; Variable_name Value -Optimizer_join_prefixes_check_calls 57916 +Optimizer_join_prefixes_check_calls 60210 SET OPTIMIZER_SEARCH_DEPTH = DEFAULT; # # Bug found when testing greedy optimizer tests @@ -2917,8 +2928,8 @@ explain SELECT * FROM t1 AS alias1 WHERE alias1.col_varchar_key IN (SELECT COUNT(*) FROM t1 AS SQ3_alias2 JOIN t1 AS SQ3_alias3 ON (SQ3_alias3.col_varchar_key = SQ3_alias2.col_varchar_key AND SQ3_alias3.pk = SQ3_alias2.pk)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 index NULL col_varchar_key 20 NULL 2 Using where; Using index -2 DEPENDENT SUBQUERY SQ3_alias2 index PRIMARY,col_varchar_key col_varchar_key 20 NULL 2 Using index -2 DEPENDENT SUBQUERY SQ3_alias3 eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.SQ3_alias2.pk 1 Using where +2 DEPENDENT SUBQUERY SQ3_alias2 index PRIMARY,col_varchar_key col_varchar_key 20 NULL 2 Using where; Using index +2 DEPENDENT SUBQUERY SQ3_alias3 ref PRIMARY,col_varchar_key col_varchar_key 11 test.SQ3_alias2.col_varchar_key 1 Using where; Using index drop table t1; # # This triggered an assert failure while testing diff --git a/mysql-test/main/greedy_optimizer.test b/mysql-test/main/greedy_optimizer.test index 2a830c70677..f2731087cd8 100644 --- a/mysql-test/main/greedy_optimizer.test +++ b/mysql-test/main/greedy_optimizer.test @@ -441,9 +441,9 @@ WHERE t100.K=t10.I AND t10000.K=t10.I; --source include/check_qep.inc -##### -# Expect all variants of EQ joining t100 & t10000 with T10 -# to have same cost # handler_reads: +--echo ##### +--echo # Expect all variants of EQ joining t100 & t10000 with T10 +--echo # to have same cost # handler_reads: let $query= SELECT COUNT(*) FROM t10,t100,t10000 WHERE t100.K=t10.I @@ -493,12 +493,12 @@ WHERE t100.K=t10.I --source include/check_qep.inc -##### -## EQ_REF Should be executed before table scan(ALL) -## - Independent of #records in table being EQ_REF-joined -##### -##### -# Expect: Join EQ_REF(t100) before ALL(t10000) +--echo ##### +--echo ## EQ_REF Should be executed before table scan(ALL) +--echo ## - Independent of #records in table being EQ_REF-joined +--echo ##### +--echo ##### +--echo # Expect: Join EQ_REF(t100) before ALL(t10000) let $query= SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000 WHERE t100.K=t10.I @@ -517,8 +517,8 @@ WHERE t100.K=t10.I AND t10000.I=t10.I; --source include/check_qep.inc -##### -# Expect: Join EQ_REF(t10000) before ALL(t100) (star-join) +--echo ##### +--echo # Expect: Join EQ_REF(t10000) before ALL(t100) (star-join) let $query= SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100 WHERE t100.I=t10.I diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index 443c399275f..f60f9ca106c 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -2457,7 +2457,7 @@ test.t1 analyze status OK EXPLAIN SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref b b 4 const 6 Using where; Using index; Using temporary +1 SIMPLE t1 range b b 9 NULL 2 Using where; Using index for group-by; Using temporary SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; MIN(a) b @@ -2465,7 +2465,7 @@ MIN(a) b EXPLAIN SELECT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref b b 4 const 6 Using where; Using index +1 SIMPLE t1 range b b 9 NULL 2 Using where; Using index for group-by SELECT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; MIN(a) b diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index 74685df683e..c1030cf9271 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -2080,7 +2080,7 @@ id select_type table type possible_keys key key_len ref rows Extra explain extended select a1,a2,min(b),max(b) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 96.30 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2` explain extended select a1,a2,b,min(c),max(c) from t1 @@ -2100,7 +2100,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 96.30 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; @@ -2368,11 +2368,11 @@ CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)); INSERT INTO t2 SELECT a,b,b FROM t1; explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a,b a 10 NULL 6 Using where; Using index +1 SIMPLE t1 range a,b a 10 NULL 2 Using where; Using index for group-by insert into t1 select 1,seq from seq_1_to_100; explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a,b a 10 NULL 6 Using where; Using index +1 SIMPLE t1 range a,b a 10 NULL 2 Using where; Using index for group-by analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected @@ -2460,7 +2460,7 @@ EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1 AS t1_outer; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index -2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index +2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra @@ -2470,31 +2470,31 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index +2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL distinct_key NULL NULL NULL 2 1 PRIMARY t1_outer ref a a 5 .max(b) 3 Using index -2 MATERIALIZED t1 range a a 5 NULL 5 Using where; Using index +2 MATERIALIZED t1 range a a 5 NULL 2 Using where; Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer range NULL a 5 NULL 6 Using index for group-by -2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index +2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2 ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) AND t1_outer1.b = t1_outer2.b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer (flat, BNL join) -2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index +2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index 2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index -3 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index +3 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by CREATE TABLE t3 LIKE t1; FLUSH STATUS; INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a; @@ -3794,7 +3794,7 @@ CREATE INDEX break_it ON t1 (a, b); EXPLAIN SELECT distinct a, b FROM t1 where a = '3' ORDER BY b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref break_it break_it 5 const 6 Using where; Using index; Using filesort +1 SIMPLE t1 range break_it break_it 10 NULL 2 Using where; Using index for group-by; Using filesort SELECT distinct a, b FROM t1 where a = '3' ORDER BY b; a b 3 1 @@ -4036,10 +4036,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away explain select min(a) from t1 where a between "a" and "Cafeeeeeeeeeeeeeeeeeeeeeeeeee"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 13 NULL 2 Using where; Using index +1 SIMPLE t1 index a a 13 NULL 2 Using where; Using index explain select min(a) from t1 where a between "abbbbbbbbbbbbbbbbbbbb" and "Cafe2"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 13 NULL 2 Using where; Using index +1 SIMPLE t1 index a a 13 NULL 2 Using where; Using index drop table t1; # # MDEV-15433: Optimizer does not use group by optimization with distinct diff --git a/mysql-test/main/index_intersect.result b/mysql-test/main/index_intersect.result index 3ec98216479..79cd7a32c1a 100644 --- a/mysql-test/main/index_intersect.result +++ b/mysql-test/main/index_intersect.result @@ -75,7 +75,7 @@ EXPLAIN SELECT * FROM City WHERE Name LIKE 'M%' AND Population > 300000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range Population,Name Name 35 NULL # Using index condition; Using where +1 SIMPLE City index_merge Population,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where EXPLAIN SELECT * FROM City WHERE Name LIKE 'M%' AND Population > 7000000; @@ -355,9 +355,6 @@ COUNT(*) SELECT COUNT(*) FROM City WHERE Country LIKE 'C%'; COUNT(*) 551 -SELECT COUNT(*) FROM City WHERE Country LIKE 'B%'; -COUNT(*) -339 SELECT COUNT(*) FROM City WHERE Country LIKE 'J%'; COUNT(*) 256 @@ -370,7 +367,7 @@ EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where +1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%'; @@ -476,7 +473,7 @@ EXPLAIN SELECT * FROM City WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge PRIMARY,Population,Country Country,PRIMARY 3,4 NULL # Using sort_intersect(Country,PRIMARY); Using where +1 SIMPLE City range PRIMARY,Population,Country Country 3 NULL # Using index condition; Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 3701 AND 4000 AND Population > 1000000 @@ -488,7 +485,7 @@ SELECT * FROM City WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000 AND Country BETWEEN 'S' AND 'Z' ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where +1 SIMPLE City index_merge PRIMARY,Population,Country Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where SELECT * FROM City USE INDEX () WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%'; ID Name Country Population @@ -715,18 +712,18 @@ EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range Population,Country,Name Name 35 NULL # Using index condition; Using where +1 SIMPLE City index_merge Population,Country,Name Name,Country 35,3 NULL # Using sort_intersect(Name,Country); Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where +1 SIMPLE City index_merge PRIMARY,Population,Country Population,PRIMARY 4,4 NULL # Using sort_intersect(Population,PRIMARY); Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000 AND Country BETWEEN 'S' AND 'Z'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where +1 SIMPLE City index_merge PRIMARY,Population,Country Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where SELECT * FROM City WHERE Name LIKE 'C%' AND Population > 1000000; ID Name Country Population @@ -966,7 +963,7 @@ EXPLAIN SELECT * FROM t1 WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,f4 f4 35 NULL # Using index condition; Using where +1 SIMPLE t1 index_merge PRIMARY,f4 f4,PRIMARY 35,4 NULL # Using sort_intersect(f4,PRIMARY); Using where SELECT * FROM t1 WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ; f1 f4 f5 diff --git a/mysql-test/main/index_intersect.test b/mysql-test/main/index_intersect.test index 26937fd5eef..d6208f67a92 100644 --- a/mysql-test/main/index_intersect.test +++ b/mysql-test/main/index_intersect.test @@ -120,7 +120,6 @@ SELECT COUNT(*) FROM City WHERE Name BETWEEN 'G' AND 'K'; SELECT COUNT(*) FROM City WHERE Population > 1000000; SELECT COUNT(*) FROM City WHERE Population > 500000; SELECT COUNT(*) FROM City WHERE Country LIKE 'C%'; -SELECT COUNT(*) FROM City WHERE Country LIKE 'B%'; SELECT COUNT(*) FROM City WHERE Country LIKE 'J%'; diff --git a/mysql-test/main/index_intersect_innodb.result b/mysql-test/main/index_intersect_innodb.result index 44407dbcd30..5ee4f88fddd 100644 --- a/mysql-test/main/index_intersect_innodb.result +++ b/mysql-test/main/index_intersect_innodb.result @@ -81,12 +81,12 @@ EXPLAIN SELECT * FROM City WHERE Name LIKE 'M%' AND Population > 300000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range Population,Name Name 35 NULL # Using index condition; Using where +1 SIMPLE City index_merge Population,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where EXPLAIN SELECT * FROM City WHERE Name LIKE 'M%' AND Population > 7000000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where +1 SIMPLE City range Population,Name Population 4 NULL # Using index condition; Using where SELECT * FROM City USE INDEX () WHERE Name LIKE 'C%' AND Population > 1000000; ID Name Country Population @@ -341,8 +341,8 @@ ID Name Country Population SELECT * FROM City WHERE Name LIKE 'M%' AND Population > 7000000; ID Name Country Population -1024 Mumbai (Bombay) IND 10500000 3580 Moscow RUS 8389200 +1024 Mumbai (Bombay) IND 10500000 SELECT COUNT(*) FROM City WHERE Name BETWEEN 'M' AND 'N'; COUNT(*) 301 @@ -361,9 +361,6 @@ COUNT(*) SELECT COUNT(*) FROM City WHERE Country LIKE 'C%'; COUNT(*) 551 -SELECT COUNT(*) FROM City WHERE Country LIKE 'B%'; -COUNT(*) -339 SELECT COUNT(*) FROM City WHERE Country LIKE 'J%'; COUNT(*) 256 @@ -371,17 +368,17 @@ EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL # Using sort_intersect(Population,Name,Country); Using where +1 SIMPLE City index_merge Population,Country,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where +1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range Population,Name,Country Name # NULL # Using index condition; Using where +1 SIMPLE City index_merge Population,Name,Country Name,Population,Country # NULL # Using sort_intersect(Name,Population,Country); Using where SELECT * FROM City USE INDEX () WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%'; ID Name Country Population @@ -482,13 +479,13 @@ EXPLAIN SELECT * FROM City WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where +1 SIMPLE City range PRIMARY,Population,Country Country 7 NULL # Using index condition; Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 3701 AND 4000 AND Population > 1000000 AND Country BETWEEN 'S' AND 'Z'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where +1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population 4,4 NULL # Using sort_intersect(PRIMARY,Population); Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000 @@ -721,7 +718,7 @@ EXPLAIN SELECT * FROM City WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range Population,Country,Name Name 35 NULL # Using index condition; Using where +1 SIMPLE City index_merge Population,Country,Name Name,Population,Country 35,4,3 NULL # Using sort_intersect(Name,Population,Country); Using where EXPLAIN SELECT * FROM City WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%'; @@ -732,7 +729,7 @@ SELECT * FROM City WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000 AND Country BETWEEN 'S' AND 'Z'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY,Population,Country PRIMARY 4 NULL # Using where +1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where SELECT * FROM City WHERE Name LIKE 'C%' AND Population > 1000000; ID Name Country Population diff --git a/mysql-test/main/index_merge_myisam.result b/mysql-test/main/index_merge_myisam.result index 1ecc1ded83a..7d10500d34d 100644 --- a/mysql-test/main/index_merge_myisam.result +++ b/mysql-test/main/index_merge_myisam.result @@ -683,7 +683,7 @@ key1 key2 key3 key4 filler1 -1 -1 100 100 key4-key3 explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 2 Using intersect(key1,key2,key3); Using where; Using index +1 SIMPLE t1 index_merge key1,key2,key3 key1,key2 5,5 NULL 77 Using intersect(key1,key2); Using where select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; key1 key2 key3 100 100 100 @@ -768,7 +768,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a sta_swt21a 12 const,const,const 971 explain select * from t1 where st_b=1 and swt1b=1 and swt2b=1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref stb_swt1a_2b,stb_swt1b,st_b stb_swt1a_2b 8 const,const 3879 Using where +1 SIMPLE t1 ref stb_swt1a_2b,stb_swt1b,st_b stb_swt1b 8 const,const 3885 Using where explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL 58 Using intersect(sta_swt12a,stb_swt1a_2b); Using where @@ -910,7 +910,7 @@ INSERT INTO t1 (key1, key2, filler) SELECT seq/4, seq/8, 'filler-data' FROM seq_30_to_0; explain select pk from t1 where key1 = 1 and key2 = 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref key1,key2 key1 5 const 4 Using where +1 SIMPLE t1 index_merge key1,key2 key1,key2 5,4 NULL 1 Using intersect(key1,key2); Using where select pk from t1 where key2 = 1 and key1 = 1; pk 26 @@ -1487,7 +1487,7 @@ EXPLAIN SELECT t1.f1 FROM t1 WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 -2 SUBQUERY t2 ref f2,f3 f3 2 const 2 Using index condition; Using where +2 SUBQUERY t2 index_merge f2,f3 f3,f2 2,5 NULL 1 Using intersect(f3,f2); Using where; Using index DROP TABLE t1,t2; create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff index b334d006737..274d1cc47e4 100644 --- a/mysql-test/main/innodb_ext_key,off.rdiff +++ b/mysql-test/main/innodb_ext_key,off.rdiff @@ -1,17 +1,20 @@ ---- innodb_ext_key.result -+++ innodb_ext_key,off.result +--- main/innodb_ext_key.result ++++ main/innodb_ext_key,off.reject @@ -9,7 +9,7 @@ explain select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 8 const,const 1 Using index -+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 const 6 Using where; Using index ++1 SIMPLE lineitem index_merge PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey,i_l_shipdate 4,4 NULL 1 Using intersect(i_l_orderkey,i_l_shipdate); Using where; Using index flush status; select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01'; count(*) -@@ -19,7 +19,7 @@ +@@ -17,9 +17,9 @@ + show status like 'handler_read%'; + Variable_name Value Handler_read_first 0 - Handler_read_key 1 +-Handler_read_key 1 ++Handler_read_key 2 Handler_read_last 0 -Handler_read_next 1 +Handler_read_next 6 @@ -95,13 +98,16 @@ where l_shipdate='1992-07-01' and l_orderkey=130; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away -+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 const 6 Using where; Using index ++1 SIMPLE lineitem index_merge PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey,i_l_shipdate 4,4 NULL 1 Using intersect(i_l_orderkey,i_l_shipdate); Using where; Using index flush status; select max(l_linenumber) from lineitem where l_shipdate='1992-07-01' and l_orderkey=130; -@@ -145,7 +145,7 @@ +@@ -143,9 +143,9 @@ + show status like 'handler_read%'; + Variable_name Value Handler_read_first 0 - Handler_read_key 1 +-Handler_read_key 1 ++Handler_read_key 2 Handler_read_last 0 -Handler_read_next 0 +Handler_read_next 6 @@ -249,7 +255,7 @@ drop table t1,t2,t3; # # Bug mdev-4340: performance regression with extended_keys=on -@@ -714,13 +714,13 @@ +@@ -725,13 +725,13 @@ select * from t1 force index(index_date_updated) where index_date_updated= 10 and index_id < 800; id select_type table type possible_keys key key_len ref rows Extra @@ -265,7 +271,7 @@ drop table t0,t1,t2; # # MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' -@@ -768,11 +768,12 @@ +@@ -766,13 +766,14 @@ { "table": { "table_name": "t1", @@ -279,9 +285,12 @@ + "used_key_parts": ["f2"], + "ref": ["const"], "rows": 1, - "filtered": 100, +- "filtered": 50, ++ "filtered": 100, "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", -@@ -805,8 +806,8 @@ + "attached_condition": "t1.f1 <= '3'" + } +@@ -799,8 +800,8 @@ "access_type": "range", "possible_keys": ["k1"], "key": "k1", @@ -290,5 +299,5 @@ + "key_length": "3007", + "used_key_parts": ["pk1", "f2"], "rows": 1, - "filtered": 100, + "filtered": 50, "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result index 18a3d147bf3..62b143726b2 100644 --- a/mysql-test/main/innodb_ext_key.result +++ b/mysql-test/main/innodb_ext_key.result @@ -386,8 +386,8 @@ WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t index a,b b 7 NULL 10 Using index 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t.a 1 Using index -1 PRIMARY t1 ref b b 3 test.t.b 2 Using index; Start temporary -1 PRIMARY t2 index NULL PRIMARY 4 NULL 11 Using index; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t1 ref b b 3 test.t.b 2 Using index +1 PRIMARY t2 index NULL PRIMARY 4 NULL 11 Using index; FirstMatch(t2) SELECT a FROM t1 AS t, t2 WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b); a @@ -638,14 +638,14 @@ test.t2 analyze status Engine-independent statistics collected test.t2 analyze status OK explain select a from t1 where b is null order by a desc limit 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index b PRIMARY 8 NULL 2 Using where +1 SIMPLE t1 range b b 9 NULL 3 Using where; Using filesort select a from t1 where b is null order by a desc limit 2; a 3 2 explain select a from t2 where b is null order by a desc limit 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range b b 9 NULL 3 Using where; Using filesort +1 SIMPLE t2 index b PRIMARY 8 NULL 2 Using where select a from t2 where b is null order by a desc limit 2; a 3 @@ -774,7 +774,7 @@ EXPLAIN "key_length": "3070", "used_key_parts": ["f2", "pk1"], "rows": 1, - "filtered": 100, + "filtered": 50, "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", "attached_condition": "t1.f1 <= '3'" } @@ -808,7 +808,7 @@ EXPLAIN "key_length": "3011", "used_key_parts": ["pk1", "f2", "pk2"], "rows": 1, - "filtered": 100, + "filtered": 50, "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", "attached_condition": "t1.f1 <= '3'" } diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result index 8f75105c30d..b56f35f475e 100644 --- a/mysql-test/main/join.result +++ b/mysql-test/main/join.result @@ -880,7 +880,7 @@ select @a:= A.a + 10*(B.a + 10*C.a), @a, 'filler' from t1 A, t1 B, t1 C; insert into t3 select * from t2 where a < 800; explain select * from t2,t3 where t2.a < 200 and t2.b=t3.b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL a,b NULL NULL NULL 1000 Using where +1 SIMPLE t2 range a,b a 5 NULL 198 Using index condition; Using where 1 SIMPLE t3 ref b b 5 test.t2.b 1 drop table t1, t2, t3; create table t1 (a int); @@ -892,13 +892,14 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 6.016090 +Last_query_cost 3.508545 select 'The cost of accessing t1 (dont care if it changes' '^'; The cost of accessing t1 (dont care if it changes The cost of accessing t1 (dont care if it changes^ select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z; Z vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv +set @@optimizer_cache_hit_ratio=0; explain select * from t1, t2 A, t2 B where A.a = t1.a and B.a=A.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where @@ -906,10 +907,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE B eq_ref PRIMARY PRIMARY 4 test.A.b 1 show status like 'Last_query_cost'; Variable_name Value -Last_query_cost 34.016090 -select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z; +Last_query_cost 48.527829 +select '^^: The above should be ~= 40 + cost(select * from t1). Value less than 40 is an error' Z; Z -^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error +^^: The above should be ~= 40 + cost(select * from t1). Value less than 40 is an error +set @@optimizer_cache_hit_ratio=default; drop table t1, t2; CREATE TABLE t1 (a INT PRIMARY KEY, b INT); CREATE TABLE t2 (c INT PRIMARY KEY, d INT); @@ -1274,20 +1276,24 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK test.t2 analyze status Engine-independent statistics collected test.t2 analyze status OK +explain SELECT * FROM t1 JOIN t2 ON t1.v = t2.v WHERE t2.v IS NULL ORDER BY 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL ix2 NULL NULL NULL 2 Using where; Using temporary; Using filesort +1 SIMPLE t1 ref ix1 ix1 5 test.t2.v 1 FLUSH STATUS; SELECT * FROM t1 JOIN t2 ON t1.v = t2.v WHERE t2.v IS NULL ORDER BY 1; pk v pk v SHOW STATUS LIKE 'Handler_read_%'; Variable_name Value Handler_read_first 0 -Handler_read_key 14 +Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 -Handler_read_rnd_next 1 +Handler_read_rnd_next 4 DROP TABLE t1, t2; End of 5.1 tests # @@ -1473,8 +1479,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE DU system dog_id NULL NULL NULL 1 1 SIMPLE D system PRIMARY NULL NULL NULL 1 1 SIMPLE DSAR system NULL NULL NULL NULL 1 -1 SIMPLE DSA ref PRIMARY PRIMARY 4 const 3 Using where; Using index -1 SIMPLE DT ALL t_id NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE DT ALL t_id NULL NULL NULL 2 Using where +1 SIMPLE DSA ref PRIMARY PRIMARY 8 const,test.DT.t_id,func 1 Using index SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id; diff --git a/mysql-test/main/join.test b/mysql-test/main/join.test index 88f30540589..a3756af023a 100644 --- a/mysql-test/main/join.test +++ b/mysql-test/main/join.test @@ -697,12 +697,11 @@ select 'The cost of accessing t1 (dont care if it changes' '^'; select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z; +set @@optimizer_cache_hit_ratio=0; explain select * from t1, t2 A, t2 B where A.a = t1.a and B.a=A.b; show status like 'Last_query_cost'; -select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z; - - - +select '^^: The above should be ~= 40 + cost(select * from t1). Value less than 40 is an error' Z; +set @@optimizer_cache_hit_ratio=default; drop table t1, t2; # @@ -957,6 +956,9 @@ INSERT INTO t1 VALUES (3,'b'),(4,NULL),(5,'c'),(6,'cc'),(7,'d'), (8,'dd'),(9,'e'),(10,'ee'); INSERT INTO t2 VALUES (2,NULL); ANALYZE TABLE t1,t2; +# This will ensure that status tables are read now and not part of the later +# Handler_read% counts +explain SELECT * FROM t1 JOIN t2 ON t1.v = t2.v WHERE t2.v IS NULL ORDER BY 1; FLUSH STATUS; SELECT * FROM t1 JOIN t2 ON t1.v = t2.v WHERE t2.v IS NULL ORDER BY 1; SHOW STATUS LIKE 'Handler_read_%'; diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index 3c9d1f020b9..fe40178a8da 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -53,6 +53,7 @@ set join_cache_level=1; show variables like 'join_cache_level'; Variable_name Value join_cache_level 1 +# Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -60,6 +61,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City ALL NULL NULL NULL NULL 4079 Using where; Using join buffer (flat, BNL join) +# Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -79,6 +81,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -91,6 +94,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage ALL NULL NULL NULL NULL 984 Using where; Using join buffer (flat, BNL join) 1 SIMPLE City ALL NULL NULL NULL NULL 4079 Using where; Using join buffer (flat, BNL join) +# Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -131,6 +135,7 @@ set join_cache_level=2; show variables like 'join_cache_level'; Variable_name Value join_cache_level 2 +# join_cache_level 2, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -138,6 +143,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City ALL NULL NULL NULL NULL 4079 Using where; Using join buffer (flat, BNL join) +# join_cache_level 2, Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -157,6 +163,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# join_cache_level 2, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -169,6 +176,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage ALL NULL NULL NULL NULL 984 Using where; Using join buffer (flat, BNL join) 1 SIMPLE City ALL NULL NULL NULL NULL 4079 Using where; Using join buffer (incremental, BNL join) +# join_cache_level 2, Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -209,6 +217,7 @@ set join_cache_level=3; show variables like 'join_cache_level'; Variable_name Value join_cache_level 3 +# join_cache_level 3, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -216,6 +225,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# join_cache_level 3, Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -235,6 +245,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# join_cache_level 3, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -247,6 +258,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage hash_ALL NULL #hash#$hj 3 world.Country.Code 984 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# join_cache_level 3, Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -287,6 +299,7 @@ set join_cache_level=4; show variables like 'join_cache_level'; Variable_name Value join_cache_level 4 +# join_cache_level 4, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -294,6 +307,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# join_cache_level 4, Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -313,6 +327,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# join_cache_level 4, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -325,6 +340,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage hash_ALL NULL #hash#$hj 3 world.Country.Code 984 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (incremental, BNLH join) +# join_cache_level 4, Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -361,6 +377,7 @@ Ludwigshafen am Rhein Germany German Lungtan Taiwan Min L´Hospitalet de Llobregat Spain Spanish Lázaro Cárdenas Mexico Spanish +# join_cache_level 4, Query 5 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND City.Population > 5000000 @@ -379,6 +396,7 @@ Canada 31147000 NULL NULL Cuba 11201000 NULL NULL Côte d?Ivoire 14786000 NULL NULL Czech Republic 10278100 NULL NULL +# join_cache_level 4, Query 6 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND @@ -404,6 +422,7 @@ Czech Republic 10278100 NULL NULL CREATE INDEX City_Population ON City(Population); CREATE INDEX City_Name ON City(Name); ANALYZE TABLE City; +# After Analyze, Query 1 EXPLAIN SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City @@ -412,6 +431,7 @@ WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City hash_range City_Population #hash#$hj:City_Population 3:4 world.Country.Code 24 Using where; Rowid-ordered scan; Using join buffer (flat, BNLH join) +# After Analyze, Query 2 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND City.Population > 5000000 @@ -430,6 +450,7 @@ Canada 31147000 NULL NULL Cuba 11201000 NULL NULL Côte d?Ivoire 14786000 NULL NULL Czech Republic 10278100 NULL NULL +# After Analyze, Query 3 EXPLAIN SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City @@ -439,6 +460,7 @@ WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City hash_index_merge City_Population,City_Name #hash#$hj:City_Population,City_Name 3:4,35 world.Country.Code 96 Using sort_union(City_Population,City_Name); Using where; Using join buffer (flat, BNLH join) +# After Analyze, Query 4 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND @@ -471,6 +493,7 @@ join_buffer_size 256 show variables like 'join_cache_level'; Variable_name Value join_cache_level 1 +# join_cache_level 1, Join_buffer_size, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -478,6 +501,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City ALL NULL NULL NULL NULL 4079 Using where; Using join buffer (flat, BNL join) +# join_cache_level 1, Join_buffer_size, Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -497,6 +521,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# join_cache_level 1, Join_buffer_size, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -509,6 +534,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage ALL NULL NULL NULL NULL 984 Using where; Using join buffer (flat, BNL join) 1 SIMPLE City ALL NULL NULL NULL NULL 4079 Using where; Using join buffer (flat, BNL join) +# join_cache_level 1, Join_buffer_size, Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -549,6 +575,7 @@ set join_cache_level=2; show variables like 'join_cache_level'; Variable_name Value join_cache_level 2 +# join_cache_level 2, Join_buffer_size, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -556,6 +583,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City ALL NULL NULL NULL NULL 4079 Using where; Using join buffer (flat, BNL join) +# join_cache_level 2, Join_buffer_size, Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -575,6 +603,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# join_cache_level 2, Join_buffer_size, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -587,6 +616,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage ALL NULL NULL NULL NULL 984 Using where; Using join buffer (flat, BNL join) 1 SIMPLE City ALL NULL NULL NULL NULL 4079 Using where; Using join buffer (incremental, BNL join) +# join_cache_level 2, Join_buffer_size, Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -627,6 +657,7 @@ set join_cache_level=3; show variables like 'join_cache_level'; Variable_name Value join_cache_level 3 +# join_cache_level 3, Join_buffer_size, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -634,6 +665,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# join_cache_level 3, Join_buffer_size, Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -653,6 +685,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# join_cache_level 3, Join_buffer_size, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -665,6 +698,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage hash_ALL NULL #hash#$hj 3 world.Country.Code 984 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# join_cache_level 3, Join_buffer_size, Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -705,6 +739,7 @@ set join_cache_level=4; show variables like 'join_cache_level'; Variable_name Value join_cache_level 4 +# join_cache_level 4, Join_buffer_size, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -712,6 +747,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# join_cache_level 4, Join_buffer_size, Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -731,6 +767,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# join_cache_level 4, Join_buffer_size, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -743,6 +780,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage hash_ALL NULL #hash#$hj 3 world.Country.Code 984 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (incremental, BNLH join) +# join_cache_level 4, Join_buffer_size, Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -816,6 +854,7 @@ set join_cache_level=3; show variables like 'join_cache_level'; Variable_name Value join_cache_level 3 +# Part 2, join_cache_level=3, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -823,6 +862,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Rowid-ordered scan 1 SIMPLE City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# Part 2, join_cache_level=3, Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -842,6 +882,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# Part 2, join_cache_level=3, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -853,7 +894,8 @@ LENGTH(Language) < LENGTH(City.Name) - 2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City ALL Country NULL NULL NULL 4079 Using where 1 SIMPLE Country hash_ALL PRIMARY #hash#PRIMARY 3 world.City.Country 239 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE CountryLanguage hash_ALL|filter PRIMARY,Percentage #hash#PRIMARY|Percentage 3|4 world.City.Country 984 (19%) Using where; Using join buffer (flat, BNLH join); Using rowid filter +1 SIMPLE CountryLanguage hash_range PRIMARY,Percentage #hash#PRIMARY:Percentage 3:4 world.City.Country 185 Using where; Rowid-ordered scan; Using join buffer (flat, BNLH join) +# Part 2, join_cache_level=3, Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -890,6 +932,7 @@ Ludwigshafen am Rhein Germany German Lungtan Taiwan Min L´Hospitalet de Llobregat Spain Spanish Lázaro Cárdenas Mexico Spanish +# Part 2, join_cache_level=3, Query 5 EXPLAIN SELECT Name FROM City WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND @@ -897,6 +940,7 @@ City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Rowid-ordered scan 1 PRIMARY City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# Part 2, join_cache_level=3, Query 6 SELECT Name FROM City WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND City.Population > 100000; @@ -916,6 +960,7 @@ Kaunas Klaipeda ?iauliai Panevezys +# Part 2, join_cache_level=3, Query 7 EXPLAIN SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.Percentage) FROM Country LEFT JOIN CountryLanguage ON @@ -925,6 +970,7 @@ Country.Population > 10000000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage hash_ALL PRIMARY #hash#PRIMARY 33 world.Country.Code,const 984 Using where; Using join buffer (flat, BNLH join) +# Part 2, join_cache_level=3, Query 8 SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.Percentage) FROM Country LEFT JOIN CountryLanguage ON (CountryLanguage.Country=Country.Code AND Language='English') @@ -1016,6 +1062,7 @@ set join_cache_level=4; show variables like 'join_cache_level'; Variable_name Value join_cache_level 4 +# Part 2, join_cache_level=4, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND @@ -1023,6 +1070,7 @@ Country.Name LIKE 'L%' AND City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Rowid-ordered scan 1 SIMPLE City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# Part 2, join_cache_level=4, Query 2 SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; @@ -1042,6 +1090,7 @@ Tripoli Lebanon Tripoli Libyan Arab Jamahiriya Vientiane Laos Vilnius Lithuania +# Part 2, join_cache_level=4, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -1053,7 +1102,8 @@ LENGTH(Language) < LENGTH(City.Name) - 2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City ALL Country NULL NULL NULL 4079 Using where 1 SIMPLE Country hash_ALL PRIMARY #hash#PRIMARY 3 world.City.Country 239 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE CountryLanguage hash_ALL|filter PRIMARY,Percentage #hash#PRIMARY|Percentage 3|4 world.City.Country 984 (19%) Using where; Using join buffer (incremental, BNLH join); Using rowid filter +1 SIMPLE CountryLanguage hash_range PRIMARY,Percentage #hash#PRIMARY:Percentage 3:4 world.City.Country 185 Using where; Rowid-ordered scan; Using join buffer (incremental, BNLH join) +# Part 2, join_cache_level=4, Query 4 SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -1090,6 +1140,7 @@ Ludwigshafen am Rhein Germany German Lungtan Taiwan Min L´Hospitalet de Llobregat Spain Spanish Lázaro Cárdenas Mexico Spanish +# Part 2, join_cache_level=4, Query 5 EXPLAIN SELECT Name FROM City WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND @@ -1097,6 +1148,7 @@ City.Population > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Rowid-ordered scan 1 PRIMARY City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join) +# Part 2, join_cache_level=4, Query 6 SELECT Name FROM City WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND City.Population > 100000; @@ -1116,6 +1168,7 @@ Kaunas Klaipeda ?iauliai Panevezys +# Part 2, join_cache_level=4, Query 7 EXPLAIN SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.Percentage) FROM Country LEFT JOIN CountryLanguage ON @@ -1125,6 +1178,7 @@ Country.Population > 10000000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where 1 SIMPLE CountryLanguage hash_ALL PRIMARY #hash#PRIMARY 33 world.Country.Code,const 984 Using where; Using join buffer (flat, BNLH join) +# Part 2, join_cache_level=4, Query 8 SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.Percentage) FROM Country LEFT JOIN CountryLanguage ON (CountryLanguage.Country=Country.Code AND Language='English') @@ -1209,6 +1263,7 @@ Belarus NULL Venezuela NULL Russian Federation NULL Vietnam NULL +# Part 2, join_cache_level=4, Query 9 EXPLAIN SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City @@ -1217,6 +1272,7 @@ WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country range Name Name 52 NULL # Using index condition; Using where; Rowid-ordered scan 1 SIMPLE City hash_range Population,Country #hash#Country:Population 3:4 world.Country.Code # Using where; Rowid-ordered scan; Using join buffer (flat, BNLH join) +# Part 2, join_cache_level=4, Query 10 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND City.Population > 5000000 @@ -1236,6 +1292,7 @@ Cuba 11201000 NULL NULL Côte d?Ivoire 14786000 NULL NULL Czech Republic 10278100 NULL NULL CREATE INDEX City_Name ON City(Name); +# Part 2, join_cache_level=4, City_Name, Query 1 EXPLAIN SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City @@ -1245,6 +1302,7 @@ WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE Country range Name Name 52 NULL 17 Using index condition; Using where; Rowid-ordered scan 1 SIMPLE City hash_index_merge Population,Country,City_Name #hash#Country:Population,City_Name 3:4,35 world.Country.Code 96 Using sort_union(Population,City_Name); Using where; Using join buffer (flat, BNLH join) +# Part 2, join_cache_level=4, City_Name, Query 2 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND @@ -2104,7 +2162,7 @@ LENGTH(Language) < LENGTH(City.Name) - 2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City ALL Country NULL NULL NULL 4079 Using where 1 SIMPLE Country hash_ALL PRIMARY #hash#PRIMARY 3 world.City.Country 239 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE CountryLanguage hash_ALL|filter PRIMARY,Percentage #hash#PRIMARY|Percentage 3|4 world.City.Country 984 (19%) Using where; Using join buffer (flat, BNLH join); Using rowid filter +1 SIMPLE CountryLanguage hash_range PRIMARY,Percentage #hash#PRIMARY:Percentage 3:4 world.City.Country 185 Using where; Rowid-ordered scan; Using join buffer (flat, BNLH join) SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -2208,7 +2266,7 @@ LENGTH(Language) < LENGTH(City.Name) - 2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City ALL Country NULL NULL NULL 4079 Using where 1 SIMPLE Country hash_ALL PRIMARY #hash#PRIMARY 3 world.City.Country 239 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE CountryLanguage hash_ALL|filter PRIMARY,Percentage #hash#PRIMARY|Percentage 3|4 world.City.Country 984 (19%) Using where; Using join buffer (incremental, BNLH join); Using rowid filter +1 SIMPLE CountryLanguage hash_range PRIMARY,Percentage #hash#PRIMARY:Percentage 3:4 world.City.Country 185 Using where; Rowid-ordered scan; Using join buffer (incremental, BNLH join) SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage WHERE City.Country=Country.Code AND @@ -3075,7 +3133,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaidformatid 4 test.t9.metaid 1 Using index condition; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t4 eq_ref PRIMARY,t4_formatclassid,t4_formats_idx PRIMARY 4 test.t3.formatid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t1 ref t1_affiliateid,t1_metaid t1_affiliateid 4 const 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t1 ALL t1_affiliateid,t1_metaid NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join) SELECT t1.uniquekey, t1.xml AS affiliateXml, t8.name AS artistName, t8.artistid, t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, @@ -3191,7 +3249,7 @@ Warning 1292 Truncated incorrect join_buffer_size value: '32' set join_cache_level=8; EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx idx 5 NULL 3 Using index condition; Using where; Rowid-ordered scan +1 SIMPLE t1 ALL idx NULL NULL NULL 7 Using where 1 SIMPLE t2 ref idx idx 5 test.t1.a 2 Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; a b a b @@ -3371,8 +3429,8 @@ set join_cache_level=6; set join_buffer_size=1024; EXPLAIN SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 2050 Using where -1 SIMPLE t2 ref idx idx 5 test.t1.a 640 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ALL idx NULL NULL NULL 1280 Using where +1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t2.b 2050 Using where; Using join buffer (flat, BNLH join) SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; AVG(c) 5.0000 @@ -4969,8 +5027,8 @@ FROM ((t1 LEFT JOIN (t2 JOIN t3 ON t2.a2 = t3.a3) ON t2.b2 = t1.a1) LEFT JOIN t4 ON t4.a4 <> 0) LEFT JOIN t5 ON t5.a5 = t2.a2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 -1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 1 Using where -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.a2 1 Using index +1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 1 Using where; Using index +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.a3 1 Using where 1 SIMPLE t4 ALL NULL NULL NULL NULL 1 Using where 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t2.a2 1 Using where SELECT t4.a4, t5.b5 @@ -5054,13 +5112,15 @@ CREATE TABLE t2 ( f3 int(11), f2 varchar(1024), f4 varchar(10), PRIMARY KEY (f3) ); INSERT INTO t2 VALUES (6,'RPOYT','y'),(10,'JINQE','m'); +INSERT INTO t2 VALUES (100,'Q','q'),(101,'Q','q'),(102,'Q','q'),(103,'Q','q'); +INSERT INTO t2 VALUES (104,'Q','q'),(105,'Q','q'),(106,'Q','q'),(107,'Q','q'); SET SESSION join_cache_level = 1; SET SESSION optimizer_switch = 'index_condition_pushdown=off'; EXPLAIN SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Rowid-ordered scan +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 Using where 1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); @@ -5070,7 +5130,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Rowid-ordered scan +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 Using where 1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); @@ -5523,7 +5583,7 @@ and t2.uid=t1.fid; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ref uid uid 5 const 4 Using where; Start temporary 1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 Using index -1 PRIMARY t1 ALL uid NULL NULL NULL 11 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t1 ref uid uid 5 test.t3.fid 2 Using where; End temporary; Using join buffer (flat, BKAH join); Rowid-ordered scan 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 Using join buffer (flat, BKAH join); Rowid-ordered scan select name from t2, t1 where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) @@ -6150,8 +6210,8 @@ a b c explain select t1.a, t1.b, t1.c from t1,t2 where t2.a = t1.a and t2.b = t1.b and t2.c=t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where -1 SIMPLE t2 hash_index PRIMARY #hash#PRIMARY:PRIMARY 12:12 test.t1.c,test.t1.a,test.t1.b 2 Using index; Using join buffer (flat, BNLH join) +1 SIMPLE t2 index PRIMARY PRIMARY 12 NULL 2 Using index +1 SIMPLE t1 hash_ALL NULL #hash#$hj 15 test.t2.a,test.t2.b,test.t2.c 2 Using where; Using join buffer (flat, BNLH join) drop table t1,t2; set join_cache_level=@save_join_cache_level; # @@ -6198,7 +6258,7 @@ EXPLAIN { "table": { "table_name": "a", - "access_type": "range", + "access_type": "index", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", diff --git a/mysql-test/main/join_cache.test b/mysql-test/main/join_cache.test index 125ae84c309..c4401997b1d 100644 --- a/mysql-test/main/join_cache.test +++ b/mysql-test/main/join_cache.test @@ -6,6 +6,7 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; DROP DATABASE IF EXISTS world; --enable_warnings +--source include/have_innodb.inc set @org_optimizer_switch=@@optimizer_switch; set @save_join_cache_level=@@join_cache_level; @@ -53,16 +54,19 @@ set join_cache_level=1; show variables like 'join_cache_level'; +--echo # Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -72,6 +76,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -84,16 +89,19 @@ SELECT City.Name, Country.Name, CountryLanguage.Language set join_cache_level=2; show variables like 'join_cache_level'; +--echo # join_cache_level 2, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 2, Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 2, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -103,6 +111,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # join_cache_level 2, Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -115,16 +124,19 @@ SELECT City.Name, Country.Name, CountryLanguage.Language set join_cache_level=3; show variables like 'join_cache_level'; +--echo # join_cache_level 3, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 3, Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 3, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -134,7 +146,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; - +--echo # join_cache_level 3, Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -148,16 +160,19 @@ SELECT City.Name, Country.Name, CountryLanguage.Language set join_cache_level=4; show variables like 'join_cache_level'; +--echo # join_cache_level 4, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 4, Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 4, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -167,6 +182,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # join_cache_level 4, Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -177,11 +193,13 @@ SELECT City.Name, Country.Name, CountryLanguage.Language LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # join_cache_level 4, Query 5 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND City.Population > 5000000 WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; +--echo # join_cache_level 4, Query 6 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND @@ -195,17 +213,20 @@ CREATE INDEX City_Name ON City(Name); ANALYZE TABLE City; --enable_result_log +--echo # After Analyze, Query 1 EXPLAIN SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND City.Population > 5000000 WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; +--echo # After Analyze, Query 2 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND City.Population > 5000000 WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; +--echo # After Analyze, Query 3 EXPLAIN SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City @@ -213,6 +234,7 @@ SELECT Country.Name, Country.Population, City.Name, City.Population (City.Population > 5000000 OR City.Name LIKE 'Za%') WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; +--echo # After Analyze, Query 4 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND @@ -229,16 +251,19 @@ show variables like 'join_buffer_size'; show variables like 'join_cache_level'; +--echo # join_cache_level 1, Join_buffer_size, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 1, Join_buffer_size, Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 1, Join_buffer_size, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -248,6 +273,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # join_cache_level 1, Join_buffer_size, Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -260,16 +286,19 @@ SELECT City.Name, Country.Name, CountryLanguage.Language set join_cache_level=2; show variables like 'join_cache_level'; +--echo # join_cache_level 2, Join_buffer_size, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 2, Join_buffer_size, Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 2, Join_buffer_size, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -279,6 +308,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # join_cache_level 2, Join_buffer_size, Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -291,16 +321,19 @@ SELECT City.Name, Country.Name, CountryLanguage.Language set join_cache_level=3; show variables like 'join_cache_level'; +--echo # join_cache_level 3, Join_buffer_size, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 3, Join_buffer_size, Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 3, Join_buffer_size, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -310,6 +343,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # join_cache_level 3, Join_buffer_size, Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -322,16 +356,19 @@ SELECT City.Name, Country.Name, CountryLanguage.Language set join_cache_level=4; show variables like 'join_cache_level'; +--echo # join_cache_level 4, Join_buffer_size, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 4, Join_buffer_size, Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # join_cache_level 4, Join_buffer_size, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -341,6 +378,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # join_cache_level 4, Join_buffer_size, Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -374,16 +412,19 @@ show variables like 'join_buffer_size'; set join_cache_level=3; show variables like 'join_cache_level'; +--echo # Part 2, join_cache_level=3, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # Part 2, join_cache_level=3, Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # Part 2, join_cache_level=3, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -393,6 +434,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # Part 2, join_cache_level=3, Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -402,15 +444,18 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # Part 2, join_cache_level=3, Query 5 EXPLAIN SELECT Name FROM City WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND City.Population > 100000; +--echo # Part 2, join_cache_level=3, Query 6 SELECT Name FROM City WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND City.Population > 100000; +--echo # Part 2, join_cache_level=3, Query 7 #enable after fix MDEV-27871 --disable_view_protocol @@ -421,6 +466,7 @@ SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.P WHERE Country.Population > 10000000; +--echo # Part 2, join_cache_level=3, Query 8 SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.Percentage) FROM Country LEFT JOIN CountryLanguage ON (CountryLanguage.Country=Country.Code AND Language='English') @@ -433,16 +479,19 @@ show variables like 'join_buffer_size'; set join_cache_level=4; show variables like 'join_cache_level'; +--echo # Part 2, join_cache_level=4, Query 1 EXPLAIN SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # Part 2, join_cache_level=4, Query 2 --sorted_result SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; +--echo # Part 2, join_cache_level=4, Query 3 EXPLAIN SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -452,6 +501,7 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # Part 2, join_cache_level=4, Query 4 --sorted_result SELECT City.Name, Country.Name, CountryLanguage.Language FROM City,Country,CountryLanguage @@ -461,15 +511,18 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; +--echo # Part 2, join_cache_level=4, Query 5 EXPLAIN SELECT Name FROM City WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND City.Population > 100000; +--echo # Part 2, join_cache_level=4, Query 6 SELECT Name FROM City WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND City.Population > 100000; +--echo # Part 2, join_cache_level=4, Query 7 #enable after fix MDEV-27871 --disable_view_protocol @@ -480,6 +533,7 @@ SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.P WHERE Country.Population > 10000000; +--echo # Part 2, join_cache_level=4, Query 8 SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.Percentage) FROM Country LEFT JOIN CountryLanguage ON (CountryLanguage.Country=Country.Code AND Language='English') @@ -487,7 +541,7 @@ SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.P Country.Population > 10000000; --enable_view_protocol - +--echo # Part 2, join_cache_level=4, Query 9 --replace_column 9 # EXPLAIN SELECT Country.Name, Country.Population, City.Name, City.Population @@ -495,6 +549,7 @@ SELECT Country.Name, Country.Population, City.Name, City.Population ON City.Country=Country.Code AND City.Population > 5000000 WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; +--echo # Part 2, join_cache_level=4, Query 10 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND City.Population > 5000000 @@ -502,6 +557,7 @@ SELECT Country.Name, Country.Population, City.Name, City.Population CREATE INDEX City_Name ON City(Name); +--echo # Part 2, join_cache_level=4, City_Name, Query 1 EXPLAIN SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City @@ -509,6 +565,7 @@ SELECT Country.Name, Country.Population, City.Name, City.Population (City.Population > 5000000 OR City.Name LIKE 'Za%') WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; +--echo # Part 2, join_cache_level=4, City_Name, Query 2 SELECT Country.Name, Country.Population, City.Name, City.Population FROM Country LEFT JOIN City ON City.Country=Country.Code AND @@ -3206,6 +3263,8 @@ CREATE TABLE t2 ( f3 int(11), f2 varchar(1024), f4 varchar(10), PRIMARY KEY (f3) ); INSERT INTO t2 VALUES (6,'RPOYT','y'),(10,'JINQE','m'); +INSERT INTO t2 VALUES (100,'Q','q'),(101,'Q','q'),(102,'Q','q'),(103,'Q','q'); +INSERT INTO t2 VALUES (104,'Q','q'),(105,'Q','q'),(106,'Q','q'),(107,'Q','q'); SET SESSION join_cache_level = 1; @@ -3808,8 +3867,6 @@ drop table t0,t1,t2; --echo # of LEFT JOIN operations when using join buffer --echo # ---source include/have_innodb.inc - CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, col1 varchar(255) NOT NULL DEFAULT '', diff --git a/mysql-test/main/join_nested.result b/mysql-test/main/join_nested.result index 741c3e4038e..1f8ffccf16b 100644 --- a/mysql-test/main/join_nested.result +++ b/mysql-test/main/join_nested.result @@ -695,21 +695,21 @@ t0.b=t1.b AND (t9.a=1); a b a b a b a b a b a b a b a b a b a b 1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 -1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 -1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 -1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 -1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 -1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 -1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 -1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 -1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 -1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 SELECT t1.a,t1.b FROM t1; @@ -1062,9 +1062,9 @@ t0.b=t1.b AND (t8.b=t9.b OR t8.c IS NULL) AND (t9.a=1); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t0 ref idx_a idx_a 5 const 2 100.00 +1 SIMPLE t0 ALL idx_a NULL NULL NULL 3 66.67 Using where +1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t1 ALL idx_b NULL NULL NULL 7 75.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where @@ -1743,10 +1743,10 @@ LEFT JOIN ON t4.carrier = t1.carrier; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index package_id package_id 5 NULL 45 Using where; Using index +1 SIMPLE t3 ref package_id package_id 5 test.t2.package_id 1 Using index 1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 1 SIMPLE t4 eq_ref PRIMARY,id PRIMARY 2 test.t1.carrier 1 Using where 1 SIMPLE t5 ref carrier_id carrier_id 5 test.t4.id 22 Using index -1 SIMPLE t3 ref package_id package_id 5 test.t2.package_id 1 Using index SELECT COUNT(*) FROM ((t2 JOIN t1 ON t2.package_id = t1.id) JOIN t3 ON t3.package_id = t1.id) diff --git a/mysql-test/main/join_nested.test b/mysql-test/main/join_nested.test index ed1fe4c9f7e..ee89c91e734 100644 --- a/mysql-test/main/join_nested.test +++ b/mysql-test/main/join_nested.test @@ -364,6 +364,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, SELECT t9.a,t9.b FROM t9; +--sorted_result SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b FROM t0,t1 diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result index 57bd6298b3b..c5386983ceb 100644 --- a/mysql-test/main/join_nested_jcl6.result +++ b/mysql-test/main/join_nested_jcl6.result @@ -652,6 +652,7 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) @@ -659,9 +660,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) -1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t9`.`b` = `test`.`t8`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) SELECT t9.a,t9.b FROM t9; a b @@ -703,23 +703,23 @@ t0.b=t1.b AND (t8.b=t9.b OR t8.c IS NULL) AND (t9.a=1); a b a b a b a b a b a b a b a b a b a b -1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 -1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 -1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 -1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 -1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 -1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 -1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 -1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 SELECT t1.a,t1.b FROM t1; a b @@ -920,6 +920,7 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) @@ -927,9 +928,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) -1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t9`.`b` = `test`.`t8`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) INSERT INTO t4 VALUES (-3,12,0), (-4,13,0), (-1,11,0), (-3,11,0), (-5,15,0); INSERT INTO t5 VALUES (-3,11,0), (-2,12,0), (-3,13,0), (-4,12,0); CREATE INDEX idx_b ON t4(b); @@ -1071,9 +1071,9 @@ t0.b=t1.b AND (t8.b=t9.b OR t8.c IS NULL) AND (t9.a=1); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t0 ref idx_a idx_a 5 const 2 100.00 -1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t1 ALL idx_b NULL NULL NULL 7 75.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t0 ALL idx_a NULL NULL NULL 3 66.67 Using where +1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) @@ -1752,10 +1752,10 @@ LEFT JOIN ON t4.carrier = t1.carrier; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index package_id package_id 5 NULL 45 Using where; Using index +1 SIMPLE t3 ref package_id package_id 5 test.t2.package_id 1 Using index 1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t4 eq_ref PRIMARY,id PRIMARY 2 test.t1.carrier 1 Using where 1 SIMPLE t5 ref carrier_id carrier_id 5 test.t4.id 22 Using index -1 SIMPLE t3 ref package_id package_id 5 test.t2.package_id 1 Using index SELECT COUNT(*) FROM ((t2 JOIN t1 ON t2.package_id = t1.id) JOIN t3 ON t3.package_id = t1.id) @@ -2085,8 +2085,8 @@ ON t6.b >= 2 AND t5.b=t7.b AND (t8.a > 0 OR t8.c IS NULL) AND t6.a>0 AND t7.a>0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 -1 SIMPLE t7 range PRIMARY,b_i PRIMARY 4 NULL 2 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) -1 SIMPLE t6 range|filter PRIMARY,b_i PRIMARY|b_i 4|5 NULL 3 (86%) Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join); Using rowid filter +1 SIMPLE t7 ref|filter PRIMARY,b_i b_i|PRIMARY 5|4 test.t5.b 2 (29%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter +1 SIMPLE t6 ALL PRIMARY,b_i NULL NULL NULL 7 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result index d6ab8c7dc9c..eb5bf0e1700 100644 --- a/mysql-test/main/join_outer.result +++ b/mysql-test/main/join_outer.result @@ -2260,7 +2260,7 @@ create table t2 (a int, b int, c int, key(b), key(c)); insert into t2 select @a:=A.a + 10*B.a+100*C.a, IF(@a<900, NULL, @a), -IF(@a<500, NULL, @a) +IF(@a<450, NULL, @a) from t1 A, t1 B, t1 C; delete from t1 where a=0; # Check that there are different #rows of NULLs for b and c, both !=10: @@ -2269,7 +2269,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref b b 5 const 780 Using index condition explain select * from t2 force index (c) where c is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c c 5 const 393 Using index condition +1 SIMPLE t2 ref c c 5 const 312 Using index condition explain select * from t1 left join t2 on t2.b is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 9 @@ -2277,7 +2277,7 @@ id select_type table type possible_keys key key_len ref rows Extra explain select * from t1 left join t2 on t2.c is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 9 -1 SIMPLE t2 ALL c NULL NULL NULL 1000 Using where +1 SIMPLE t2 ref c c 5 const 312 Using where drop table t1,t2; # # MDEV-10006: optimizer doesn't convert outer join to inner on views with WHERE clause diff --git a/mysql-test/main/join_outer.test b/mysql-test/main/join_outer.test index 5e1e83e4049..ac4207a720a 100644 --- a/mysql-test/main/join_outer.test +++ b/mysql-test/main/join_outer.test @@ -1813,7 +1813,7 @@ create table t2 (a int, b int, c int, key(b), key(c)); insert into t2 select @a:=A.a + 10*B.a+100*C.a, IF(@a<900, NULL, @a), - IF(@a<500, NULL, @a) + IF(@a<450, NULL, @a) from t1 A, t1 B, t1 C; delete from t1 where a=0; diff --git a/mysql-test/main/join_outer_innodb.result b/mysql-test/main/join_outer_innodb.result index 809a980576d..5373dbc0bbc 100644 --- a/mysql-test/main/join_outer_innodb.result +++ b/mysql-test/main/join_outer_innodb.result @@ -437,6 +437,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL a4,a6,a5,a7 NULL NULL NULL 3 Using where 1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index +1 SIMPLE t10 eq_ref PRIMARY PRIMARY 1 test.t1.a6 1 1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where @@ -453,12 +454,12 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where 1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where; Using index 1 SIMPLE t16 ref PRIMARY PRIMARY 2 test.t15.o1 1 Using where -1 SIMPLE t10 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) explain select * from v1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL a4,a6,a5,a7 NULL NULL NULL 3 Using where 1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index +1 SIMPLE t10 eq_ref PRIMARY PRIMARY 1 test.t1.a6 1 1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index 1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where @@ -475,7 +476,6 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where 1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where; Using index 1 SIMPLE t16 ref PRIMARY PRIMARY 2 test.t15.o1 1 Using where -1 SIMPLE t10 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) drop view v1; drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16; # diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result index 7f2f6ae96d4..5c88511b020 100644 --- a/mysql-test/main/join_outer_jcl6.result +++ b/mysql-test/main/join_outer_jcl6.result @@ -2267,7 +2267,7 @@ create table t2 (a int, b int, c int, key(b), key(c)); insert into t2 select @a:=A.a + 10*B.a+100*C.a, IF(@a<900, NULL, @a), -IF(@a<500, NULL, @a) +IF(@a<450, NULL, @a) from t1 A, t1 B, t1 C; delete from t1 where a=0; # Check that there are different #rows of NULLs for b and c, both !=10: @@ -2276,7 +2276,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref b b 5 const 780 Using index condition explain select * from t2 force index (c) where c is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c c 5 const 393 Using index condition +1 SIMPLE t2 ref c c 5 const 312 Using index condition explain select * from t1 left join t2 on t2.b is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 9 @@ -2284,7 +2284,7 @@ id select_type table type possible_keys key key_len ref rows Extra explain select * from t1 left join t2 on t2.c is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 9 -1 SIMPLE t2 ALL c NULL NULL NULL 1000 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c c 5 const 312 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan drop table t1,t2; # # MDEV-10006: optimizer doesn't convert outer join to inner on views with WHERE clause diff --git a/mysql-test/main/key.result b/mysql-test/main/key.result index 091e8e44b82..653e41f8e28 100644 --- a/mysql-test/main/key.result +++ b/mysql-test/main/key.result @@ -231,11 +231,14 @@ numeropost 1 EXPLAIN SELECT numeropost FROM t1 WHERE numreponse='1'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const numreponse numreponse 4 const 1 Using index +1 SIMPLE t1 const numreponse numreponse 4 const 1 FLUSH TABLES; SELECT numeropost FROM t1 WHERE numreponse='1'; numeropost 1 +EXPLAIN SELECT numreponse+0 FROM t1 WHERE numreponse='1'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const numreponse numreponse 4 const 1 Using index drop table t1; create table t1 (c varchar(30) character set utf8, t text character set utf8, unique (c(2)), unique (t(3))) engine=myisam; show create table t1; @@ -610,7 +613,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index +2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by SELECT 1 as RES FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; RES @@ -628,19 +631,19 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort SHOW STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 10.412184 +Last_query_cost 8.506592 EXPLAIN SELECT a, SUM( b ) FROM t1 USE INDEX( a ) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort SHOW STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 10.412184 +Last_query_cost 8.506592 EXPLAIN SELECT a, SUM( b ) FROM t1 FORCE INDEX( a ) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 5 NULL 6 SHOW STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 15.399000 +Last_query_cost 11.003515 DROP TABLE t1; # # MDEV-21480: Unique key using ref access though eq_ref access can be used diff --git a/mysql-test/main/key.test b/mysql-test/main/key.test index 29e08b8834a..c891194f1ad 100644 --- a/mysql-test/main/key.test +++ b/mysql-test/main/key.test @@ -227,9 +227,12 @@ drop table t1; CREATE TABLE t1 (numeropost mediumint(8) unsigned NOT NULL default '0', numreponse int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (numeropost,numreponse), UNIQUE KEY numreponse (numreponse)); INSERT INTO t1 (numeropost,numreponse) VALUES ('1','1'),('1','2'),('2','3'),('2','4'); SELECT numeropost FROM t1 WHERE numreponse='1'; +# No 'Using index' EXPLAIN SELECT numeropost FROM t1 WHERE numreponse='1'; FLUSH TABLES; SELECT numeropost FROM t1 WHERE numreponse='1'; +# This one will have 'Using index' +EXPLAIN SELECT numreponse+0 FROM t1 WHERE numreponse='1'; drop table t1; # diff --git a/mysql-test/main/key_cache.result b/mysql-test/main/key_cache.result index 4a5df2da65d..3edbac8c9ae 100644 --- a/mysql-test/main/key_cache.result +++ b/mysql-test/main/key_cache.result @@ -440,25 +440,25 @@ VARIABLE_NAME VARIABLE_VALUE KEY_BLOCKS_NOT_FLUSHED 0 KEY_BLOCKS_USED 4 KEY_BLOCKS_WARM 0 -KEY_READ_REQUESTS 22 +KEY_READ_REQUESTS 21 KEY_READS 0 KEY_WRITE_REQUESTS 26 KEY_WRITES 6 select variable_value into @key_blocks_unused from information_schema.session_status where variable_name = 'Key_blocks_unused'; select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default NULL NULL 2097152 1024 4 # 0 22 0 26 6 +default NULL NULL 2097152 1024 4 # 0 21 0 26 6 small NULL NULL 1048576 1024 1 # 0 1 0 2 1 delete from t2 where a='zzzz'; select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default NULL NULL 2097152 1024 4 # 0 29 0 32 9 +default NULL NULL 2097152 1024 4 # 0 28 0 32 9 small NULL NULL 1048576 1024 1 # 0 1 0 2 1 delete from t1; delete from t2; select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default NULL NULL 2097152 1024 4 # 0 29 0 32 9 +default NULL NULL 2097152 1024 4 # 0 28 0 32 9 small NULL NULL 1048576 1024 1 # 0 1 0 2 1 set global key_cache_segments=2; select @@key_cache_segments; @@ -488,7 +488,7 @@ VARIABLE_NAME VARIABLE_VALUE KEY_BLOCKS_NOT_FLUSHED 0 KEY_BLOCKS_USED 4 KEY_BLOCKS_WARM 0 -KEY_READ_REQUESTS 22 +KEY_READ_REQUESTS 21 KEY_READS 0 KEY_WRITE_REQUESTS 26 KEY_WRITES 6 @@ -497,13 +497,13 @@ variable_value < @key_blocks_unused 1 select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default 2 NULL 2097152 1024 4 # 0 22 0 26 6 +default 2 NULL 2097152 1024 4 # 0 21 0 26 6 small NULL NULL 1048576 1024 1 # 0 1 0 2 1 delete from t1; delete from t2; select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default 2 NULL 2097152 1024 4 # 0 22 0 26 6 +default 2 NULL 2097152 1024 4 # 0 21 0 26 6 small NULL NULL 1048576 1024 1 # 0 1 0 2 1 set global key_cache_segments=1; select @@key_cache_segments; @@ -533,7 +533,7 @@ VARIABLE_NAME VARIABLE_VALUE KEY_BLOCKS_NOT_FLUSHED 0 KEY_BLOCKS_USED 4 KEY_BLOCKS_WARM 0 -KEY_READ_REQUESTS 22 +KEY_READ_REQUESTS 21 KEY_READS 0 KEY_WRITE_REQUESTS 26 KEY_WRITES 6 @@ -542,13 +542,13 @@ variable_value = @key_blocks_unused 1 select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default 1 NULL 2097152 1024 4 # 0 22 0 26 6 +default 1 NULL 2097152 1024 4 # 0 21 0 26 6 small NULL NULL 1048576 1024 1 # 0 1 0 2 1 delete from t1; delete from t2; select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default 1 NULL 2097152 1024 4 # 0 22 0 26 6 +default 1 NULL 2097152 1024 4 # 0 21 0 26 6 small NULL NULL 1048576 1024 1 # 0 1 0 2 1 flush tables; flush status; @@ -586,7 +586,7 @@ update t1 set p=3 where p=1; update t2 set i=2 where i=1; select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default 2 NULL 32768 1024 4 # 0 22 0 26 6 +default 2 NULL 32768 1024 4 # 0 21 0 26 6 small NULL NULL 1048576 1024 1 # 0 0 0 0 0 insert into t1(a) select a from t1; insert into t1(a) select a from t1; @@ -606,7 +606,7 @@ insert into t2(i,a) select i,a from t2; insert into t2(i,a) select i,a from t2; select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default 2 NULL 32768 1024 # # 0 6733 # 3684 103 +default 2 NULL 32768 1024 # # 0 6732 # 3684 103 small NULL NULL 1048576 1024 # # 0 0 # 0 0 select * from t1 where p between 1010 and 1020 ; p a @@ -625,7 +625,7 @@ p i a 1020 3 zzzz select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -default 2 NULL 32768 1024 # # 0 6750 # 3684 103 +default 2 NULL 32768 1024 # # 0 6749 # 3684 103 small NULL NULL 1048576 1024 # # 0 0 # 0 0 flush tables; flush status; @@ -699,7 +699,7 @@ update t2 set p=p+3000, i=2 where a='qqqq'; select * from information_schema.key_caches where key_cache_name like "key%" and segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19 +keycache1 7 NULL 262143 2048 25 # 0 2114 25 1071 19 set global keycache2.key_buffer_size=1024*1024; cache index t2 in keycache2; Table Op Msg_type Msg_text @@ -712,7 +712,7 @@ keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3 select * from information_schema.key_caches where key_cache_name like "key%" and segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES -keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19 +keycache1 7 NULL 262143 2048 25 # 0 2114 25 1071 19 keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3 cache index t2 in keycache1; Table Op Msg_type Msg_text @@ -753,7 +753,7 @@ select * from information_schema.key_caches where segment_number is null; KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES default 2 NULL 32768 1024 # # 0 3172 24 1552 18 small NULL NULL 1048576 1024 # # 0 0 0 0 0 -keycache1 7 NULL 262143 2048 # # 0 3229 43 1594 30 +keycache1 7 NULL 262143 2048 # # 0 3277 43 1594 30 keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3 set global keycache1.key_cache_block_size=2*1024; insert into t2 values (7000, 3, 'yyyy'); diff --git a/mysql-test/main/limit_rows_examined.result b/mysql-test/main/limit_rows_examined.result index f0a22b8f3f2..e87dd25cac9 100644 --- a/mysql-test/main/limit_rows_examined.result +++ b/mysql-test/main/limit_rows_examined.result @@ -255,7 +255,7 @@ select * from t1i where c1 IN (select * from t2i where c2 > ' ') LIMIT ROWS EXAMINED 6; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1i range PRIMARY PRIMARY 2 NULL 4 Using where; Using index +1 PRIMARY t1i index PRIMARY PRIMARY 2 NULL 4 Using where; Using index 1 PRIMARY t2i eq_ref PRIMARY PRIMARY 2 test.t1i.c1 1 Using index select * from t1i where c1 IN (select * from t2i where c2 > ' ') @@ -395,7 +395,7 @@ select * from t1i where c1 IN (select * from t2i where c2 > ' ') LIMIT ROWS EXAMINED 17; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1i index NULL PRIMARY 2 NULL 4 Using where; Using index -2 MATERIALIZED t2i range PRIMARY PRIMARY 2 NULL 4 Using where; Using index +2 MATERIALIZED t2i index PRIMARY PRIMARY 2 NULL 4 Using where; Using index select * from t1i where c1 IN (select * from t2i where c2 > ' ') LIMIT ROWS EXAMINED 17; c1 diff --git a/mysql-test/main/long_unique.result b/mysql-test/main/long_unique.result index 7f8110a283e..664c9e82ec6 100644 --- a/mysql-test/main/long_unique.result +++ b/mysql-test/main/long_unique.result @@ -1195,20 +1195,20 @@ ERROR 42S22: Unknown column 'DB_ROW_HASH_1' in 'IN/ALL/ANY subquery' select DB_ROW_HASH_1, DB_ROW_HASH_2 from t1,t2 where DB_ROW_HASH_1 in (select DB_ROW_HASH_1 from t2); DB_ROW_HASH_1 DB_ROW_HASH_2 11 1 -22 2 -33 3 -44 4 +11 1 +11 1 11 1 22 2 -33 3 -44 4 -11 1 +22 2 +22 2 22 2 33 3 -44 4 -11 1 -22 2 33 3 +33 3 +33 3 +44 4 +44 4 +44 4 44 4 select * from t2 where DB_ROW_HASH_1 in (select DB_ROW_HASH_1 from t1); DB_ROW_HASH_1 DB_ROW_HASH_2 diff --git a/mysql-test/main/long_unique.test b/mysql-test/main/long_unique.test index fa49b6a5ad4..3203675a7ad 100644 --- a/mysql-test/main/long_unique.test +++ b/mysql-test/main/long_unique.test @@ -389,6 +389,7 @@ select DB_ROW_HASH_1, DB_ROW_HASH_2 from t1; select DB_ROW_HASH_1, DB_ROW_HASH_2 from t1,t2; --error ER_BAD_FIELD_ERROR select * from t1 where DB_ROW_HASH_1 in (select DB_ROW_HASH_1 from t2); +--sorted_result select DB_ROW_HASH_1, DB_ROW_HASH_2 from t1,t2 where DB_ROW_HASH_1 in (select DB_ROW_HASH_1 from t2); select * from t2 where DB_ROW_HASH_1 in (select DB_ROW_HASH_1 from t1); --error ER_BAD_FIELD_ERROR diff --git a/mysql-test/main/multi_update.result b/mysql-test/main/multi_update.result index 1af632a19c8..674dc79fe12 100644 --- a/mysql-test/main/multi_update.result +++ b/mysql-test/main/multi_update.result @@ -1092,8 +1092,8 @@ a b c a b c set optimizer_switch='firstmatch=off'; explain update t1, t2 set t2.c=1 where t1.a=t2.a and t1.b in (select b from t3 where t3.c< t2.c) order by t2.c, t1.c limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort -1 PRIMARY t1 ALL a NULL NULL NULL 10 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary; Using filesort +1 PRIMARY t1 ref a a 5 test.t2.a 1 1 PRIMARY t3 ALL NULL NULL NULL NULL 10 Using where; Start temporary; End temporary update t1, t2 set t2.c=1 where t1.a=t2.a and t1.b in (select b from t3 where t3.c<=t2.c) order by t2.c, t1.c limit 5; select * from t2; diff --git a/mysql-test/main/myisam.result b/mysql-test/main/myisam.result index 0b0099d7b84..cb163bb29ff 100644 --- a/mysql-test/main/myisam.result +++ b/mysql-test/main/myisam.result @@ -640,10 +640,14 @@ create table t1 ( a tinytext, b char(1), index idx (a(1),b) ); insert into t1 values (null,''), (null,''); explain select count(*) from t1 where a is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx idx 4 const 2 Using where +1 SIMPLE t1 ALL idx NULL NULL NULL 2 Using where select count(*) from t1 where a is null; count(*) 2 +insert into t1 values (1,''), (2,''); +explain select count(*) from t1 where a is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx idx 4 const 2 Using where drop table t1; create table t1 (c1 int, c2 varchar(4) not null default '', key(c2(3))) default charset=utf8; @@ -2532,6 +2536,7 @@ DROP TABLE t1, t2, t3; # # BUG#51307 - widespread corruption with partitions and insert...select # +call mtr.add_suppression("Enabling keys got errno 12 on test.t1, retrying"); CREATE TABLE t1(a CHAR(255), KEY(a)); SELECT * FROM t1, t1 AS a1; a a diff --git a/mysql-test/main/myisam.test b/mysql-test/main/myisam.test index ec49e71bc2d..32b74027b14 100644 --- a/mysql-test/main/myisam.test +++ b/mysql-test/main/myisam.test @@ -593,6 +593,8 @@ create table t1 ( a tinytext, b char(1), index idx (a(1),b) ); insert into t1 values (null,''), (null,''); explain select count(*) from t1 where a is null; select count(*) from t1 where a is null; +insert into t1 values (1,''), (2,''); +explain select count(*) from t1 where a is null; drop table t1; # @@ -1676,6 +1678,9 @@ DROP TABLE t1, t2, t3; --echo # --echo # BUG#51307 - widespread corruption with partitions and insert...select --echo # + +call mtr.add_suppression("Enabling keys got errno 12 on test.t1, retrying"); + CREATE TABLE t1(a CHAR(255), KEY(a)); SELECT * FROM t1, t1 AS a1; SET myisam_sort_buffer_size=4; diff --git a/mysql-test/main/myisam_explain_non_select_all.result b/mysql-test/main/myisam_explain_non_select_all.result index 83e18f3906f..9b98dc77eb7 100644 --- a/mysql-test/main/myisam_explain_non_select_all.result +++ b/mysql-test/main/myisam_explain_non_select_all.result @@ -256,9 +256,8 @@ FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b` < 3 # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution @@ -268,8 +267,8 @@ Warnings: Warning 1287 ' INTO FROM...' instead # Status of "equivalent" SELECT query execution: Variable_name Value -Handler_read_key 5 -Handler_read_rnd_next 8 +Handler_read_key 4 +Handler_read_rnd_next 5 # Status of testing query execution: Variable_name Value Handler_read_key 4 @@ -342,16 +341,16 @@ Warning 1287 ' INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 5 func 2 +2 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 5 func 1 3 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 5 func 2 100.00 +2 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 5 func 1 100.00 3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort # Status of EXPLAIN EXTENDED query Variable_name Value @@ -3086,10 +3086,10 @@ FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1) +1 PRIMARY eq_ref distinct_key distinct_key 5 test.t1.a 1 100.00 3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where `x`.`b` = `test`.`t1`.`a` +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from (/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` join `test`.`t1` where `x`.`b` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution Variable_name Value Handler_read_key 4 @@ -3120,7 +3120,7 @@ Warning 1287 ' INTO ;' is deprecated and will be EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -1 PRIMARY ref key0 key0 5 test.t1.a 2 FirstMatch(t1) +1 PRIMARY eq_ref distinct_key distinct_key 5 test.t1.a 1 1 PRIMARY ALL NULL NULL NULL NULL 3 4 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort 2 DERIVED t2 ALL NULL NULL NULL NULL 3 @@ -3182,7 +3182,7 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1) +1 PRIMARY eq_ref distinct_key distinct_key 5 test.t1.a 1 100.00 1 PRIMARY ALL NULL NULL NULL NULL 3 100.00 4 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort 2 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 @@ -3194,11 +3194,11 @@ FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1) +1 PRIMARY eq_ref distinct_key distinct_key 5 test.t1.a 1 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) 4 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) join `test`.`t2` where `x`.`b` = `test`.`t1`.`a` +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` join `test`.`t1` join `test`.`t2` where `x`.`b` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution Variable_name Value Handler_read_key 4 diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 3ab761306da..31147c7bdde 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -11406,7 +11406,7 @@ set in_predicate_conversion_threshold=3; explain select * from t0 where a in (1,2,3,4,5,6); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where -1 PRIMARY ref key0 key0 4 test.t0.a 2 FirstMatch(t0) +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t0.a 1 3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) from information_schema.optimizer_trace; diff --git a/mysql-test/main/opt_tvc.result b/mysql-test/main/opt_tvc.result index 7c4d02fb09d..8ec88f49997 100644 --- a/mysql-test/main/opt_tvc.result +++ b/mysql-test/main/opt_tvc.result @@ -46,12 +46,11 @@ a b 2 5 explain extended select * from t1 where a in (1,2); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`_col_1` = `test`.`t1`.`a` explain extended select * from t1 where a in ( @@ -59,12 +58,49 @@ select * from (values (1),(2)) as tvc_0 ); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` +select * from t1 where a in (1,2,2,2,3,4,5,6,7); +a b +1 2 +4 6 +1 1 +2 5 +7 8 +select * from t1 +where a in +( +select * +from (values (1),(2),(2),(2),(2),(3),(4),(5),(6),(7)) as tvc_0 +); +a b +1 2 +4 6 +1 1 +2 5 +7 8 +explain extended select * from t1 where a in (1,2,2,2,3,4,5,6,7); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2),(2),(2),(3),(4),(5),(6),(7)) `tvc_0` join `test`.`t1` where `tvc_0`.`_col_1` = `test`.`t1`.`a` +explain extended select * from t1 +where a in +( +select * +from (values (1),(2),(2),(2),(2),(3),(4),(5),(6),(7)) as tvc_0 +); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2),(2),(2),(2),(3),(4),(5),(6),(7)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` # AND-condition with IN-predicates in WHERE-part select * from t1 where a in (1,2) and @@ -90,15 +126,13 @@ explain extended select * from t1 where a in (1,2) and b in (1,5); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 -4 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.b 1 100.00 5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(5)) `tvc_1` join (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`_col_1` = `test`.`t1`.`a` and `tvc_1`.`_col_1` = `test`.`t1`.`b` explain extended select * from t1 where a in ( @@ -111,15 +145,13 @@ select * from (values (1),(5)) as tvc_1 ); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 -4 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.b 1 100.00 5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(5)) `tvc_1` join (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` and `tvc_1`.`1` = `test`.`t1`.`b` # subquery with IN-predicate select * from t1 where a in @@ -150,8 +182,8 @@ from t2 where b in (3,4) id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED eq_ref distinct_key distinct_key 4 test.t2.b 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `tvc_0`.`_col_1` = `test`.`t2`.`b` @@ -168,8 +200,8 @@ from (values (3),(4)) as tvc_0 id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED eq_ref distinct_key distinct_key 4 test.t2.b 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `tvc_0`.`3` = `test`.`t2`.`b` @@ -206,12 +238,11 @@ from t1 where a in (1,2) ) as dr_table; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`_col_1` = `test`.`t1`.`a` explain extended select * from ( select * @@ -224,12 +255,11 @@ as tvc_0 ) ) as dr_table; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` # non-recursive CTE with IN-predicate with tvc_0 as ( @@ -265,12 +295,11 @@ where a in (1,2) ) select * from tvc_0; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 with tvc_0 as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` in (1,2))/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 with tvc_0 as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (dual) join `test`.`t1` where `test`.`t1`.`a` in (1,2))/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`_col_1` = `test`.`t1`.`a` explain extended select * from ( select * @@ -283,12 +312,11 @@ as tvc_0 ) ) as dr_table; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` # VIEW with IN-predicate create view v1 as select * @@ -316,20 +344,18 @@ a b 2 5 explain extended select * from v1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`_col_1` = `test`.`t1`.`a` explain extended select * from v2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` drop view v1,v2; # subselect defined by derived table with IN-predicate select * from t1 @@ -382,8 +408,8 @@ as dr_table id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `tvc_0`.`_col_1` = `test`.`t1`.`a` @@ -407,8 +433,8 @@ as dr_table id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (flat, BNL join) +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 Using where +2 MATERIALIZED eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `tvc_0`.`1` = `test`.`t1`.`a` @@ -444,13 +470,12 @@ where b in (3,5) group by b ) as dr_table; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY ALL NULL NULL NULL NULL 9 100.00 -2 DERIVED t1 ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort -2 DERIVED eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY ALL NULL NULL NULL NULL 6 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary; Using filesort +2 DERIVED eq_ref distinct_key distinct_key 4 test.t1.b 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `dr_table`.`max(a)` AS `max(a)`,`dr_table`.`b` AS `b` from (/* select#2 */ select max(`test`.`t1`.`a`) AS `max(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(5)) `tvc_0`) where 1 group by `test`.`t1`.`b`) `dr_table` +Note 1003 /* select#1 */ select `dr_table`.`max(a)` AS `max(a)`,`dr_table`.`b` AS `b` from (/* select#2 */ select max(`test`.`t1`.`a`) AS `max(a)`,`test`.`t1`.`b` AS `b` from (values (3),(5)) `tvc_0` join `test`.`t1` where `tvc_0`.`_col_1` = `test`.`t1`.`b` group by `test`.`t1`.`b`) `dr_table` explain extended select * from ( select max(a),b @@ -464,13 +489,12 @@ as tvc_0 group by b ) as dr_table; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY ALL NULL NULL NULL NULL 9 100.00 -2 DERIVED t1 ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort -2 DERIVED eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY ALL NULL NULL NULL NULL 6 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary; Using filesort +2 DERIVED eq_ref distinct_key distinct_key 4 test.t1.b 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `dr_table`.`max(a)` AS `max(a)`,`dr_table`.`b` AS `b` from (/* select#2 */ select max(`test`.`t1`.`a`) AS `max(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(5)) `tvc_0`) where 1 group by `test`.`t1`.`b`) `dr_table` +Note 1003 /* select#1 */ select `dr_table`.`max(a)` AS `max(a)`,`dr_table`.`b` AS `b` from (/* select#2 */ select max(`test`.`t1`.`a`) AS `max(a)`,`test`.`t1`.`b` AS `b` from (values (3),(5)) `tvc_0` join `test`.`t1` where `tvc_0`.`3` = `test`.`t1`.`b` group by `test`.`t1`.`b`) `dr_table` # prepare statement prepare stmt from "select * from t1 where a in (1,2)"; execute stmt; @@ -506,12 +530,11 @@ a b 4 yq explain extended select * from t3 where a in (1,4); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 2 100.00 +1 PRIMARY ALL NULL NULL NULL NULL 2 100.00 1 PRIMARY t3 ref idx idx 5 tvc_0._col_1 3 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` semi join ((values (1),(4)) `tvc_0`) where `test`.`t3`.`a` = `tvc_0`.`_col_1` +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from (values (1),(4)) `tvc_0` join `test`.`t3` where `test`.`t3`.`a` = `tvc_0`.`_col_1` # use vectors in IN predeicate set @@in_predicate_conversion_threshold= 4; select * from t1 where (a,b) in ((1,2),(3,4)); @@ -519,12 +542,11 @@ a b 1 2 explain extended select * from t1 where (a,b) in ((1,2),(3,4)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1,2),(3,4)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1,2),(3,4)) `tvc_0` join `test`.`t1` where `tvc_0`.`_col_1` = `test`.`t1`.`a` and `tvc_0`.`_col_2` = `test`.`t1`.`b` set @@in_predicate_conversion_threshold= 2; # transformation works for the one IN predicate and doesn't work for the other set @@in_predicate_conversion_threshold= 5; @@ -539,10 +561,10 @@ where (a,b) in ((1,2),(8,9)) and (a,c) in ((1,3),(8,0),(5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where -1 PRIMARY ref key0 key0 8 test.t2.a,test.t2.c 2 100.00 FirstMatch(t2) +1 PRIMARY eq_ref distinct_key distinct_key 8 test.t2.a,test.t2.c 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` semi join ((values (1,3),(8,0),(5,1)) `tvc_0`) where `tvc_0`.`_col_1` = `test`.`t2`.`a` and `tvc_0`.`_col_2` = `test`.`t2`.`c` and (`test`.`t2`.`a`,`test`.`t2`.`b`) in (((1,2)),((8,9))) +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from (values (1,3),(8,0),(5,1)) `tvc_0` join `test`.`t2` where `tvc_0`.`_col_1` = `test`.`t2`.`a` and `tvc_0`.`_col_2` = `test`.`t2`.`c` and (`test`.`t2`.`a`,`test`.`t2`.`b`) in (((1,2)),((8,9))) set @@in_predicate_conversion_threshold= 2; # # mdev-14281: conversion of NOT IN predicate into subquery predicate @@ -567,18 +589,18 @@ explain extended select * from t1 where (a,b) not in ((1,2),(8,9), (5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 8 func,func 1 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(((`test`.`t1`.`a`) in (temporary) on key0 where trigcond((`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond((`test`.`t1`.`b`) = `tvc_0`.`_col_2`))))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(((`test`.`t1`.`a`) in on distinct_key where trigcond((`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond((`test`.`t1`.`b`) = `tvc_0`.`_col_2`))))) explain extended select * from t1 where (a,b) not in (select * from (values (1,2),(8,9), (5,1)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 8 func,func 1 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(((`test`.`t1`.`a`) in (temporary) on key0 where trigcond((`test`.`t1`.`a`) = `tvc_0`.`1`) and trigcond((`test`.`t1`.`b`) = `tvc_0`.`2`))))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(((`test`.`t1`.`a`) in on distinct_key where trigcond((`test`.`t1`.`a`) = `tvc_0`.`1`) and trigcond((`test`.`t1`.`b`) = `tvc_0`.`2`))))) select * from t1 where b < 7 and (a,b) not in ((1,2),(8,9), (5,1)); a b @@ -589,10 +611,10 @@ explain extended select * from t1 where b < 7 and (a,b) not in ((1,2),(8,9), (5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 8 func,func 1 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(((`test`.`t1`.`a`) in (temporary) on key0 where trigcond((`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond((`test`.`t1`.`b`) = `tvc_0`.`_col_2`))))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<`test`.`t1`.`a`,`test`.`t1`.`b`>(((`test`.`t1`.`a`,`test`.`t1`.`b`),(((`test`.`t1`.`a`) in on distinct_key where trigcond((`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond((`test`.`t1`.`b`) = `tvc_0`.`_col_2`))))) select * from t2 where (a,c) not in ((1,2),(8,9), (5,1)); a b c @@ -605,10 +627,10 @@ explain extended select * from t2 where (a,c) not in ((1,2),(8,9), (5,1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 8 func,func 1 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<`test`.`t2`.`a`,`test`.`t2`.`c`>(((`test`.`t2`.`a`,`test`.`t2`.`c`),(((`test`.`t2`.`a`) in (temporary) on key0 where trigcond((`test`.`t2`.`a`) = `tvc_0`.`_col_1`) and trigcond((`test`.`t2`.`c`) = `tvc_0`.`_col_2`))))) +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<`test`.`t2`.`a`,`test`.`t2`.`c`>(((`test`.`t2`.`a`,`test`.`t2`.`c`),(((`test`.`t2`.`a`) in on distinct_key where trigcond((`test`.`t2`.`a`) = `tvc_0`.`_col_1`) and trigcond((`test`.`t2`.`c`) = `tvc_0`.`_col_2`))))) drop table t1, t2, t3; set @@in_predicate_conversion_threshold= default; # diff --git a/mysql-test/main/opt_tvc.test b/mysql-test/main/opt_tvc.test index ebb34758f87..89bede851eb 100644 --- a/mysql-test/main/opt_tvc.test +++ b/mysql-test/main/opt_tvc.test @@ -54,6 +54,23 @@ eval $optimized_query; eval explain extended $query; eval explain extended $optimized_query; + +let $query= select * from t1 where a in (1,2,2,2,3,4,5,6,7); + +let $optimized_query= +select * from t1 +where a in + ( + select * + from (values (1),(2),(2),(2),(2),(3),(4),(5),(6),(7)) as tvc_0 + ); + +eval $query; +eval $optimized_query; +eval explain extended $query; +eval explain extended $optimized_query; + + --echo # AND-condition with IN-predicates in WHERE-part let $query= diff --git a/mysql-test/main/set_operation.result b/mysql-test/main/set_operation.result index fa0fe21d156..977bc40c0e2 100644 --- a/mysql-test/main/set_operation.result +++ b/mysql-test/main/set_operation.result @@ -221,7 +221,7 @@ NULL UNIT RESULT ALL NULL NULL NULL NULL NULL NULL 16 EXCEPT NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNIT RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 /* select#1 */ select `__14`.`1` AS `1` from (/* select#8 */ select `__7`.`1` AS `1` from (/* select#2 */ select 1 AS `1` except /* select#3 */ select 5 AS `5` union /* select#4 */ select 6 AS `6`) `__7` union /* select#9 */ select `__8`.`2` AS `2` from (/* select#5 */ select 2 AS `2` intersect /* select#6 */ select 3 AS `3` intersect /* select#7 */ select 4 AS `4`) `__8` except /* select#12 */ select `__11`.`7` AS `7` from (/* select#10 */ select 7 AS `7` intersect /* select#11 */ select 8 AS `8`) `__11`) `__14` union all /* select#15 */ select `__15`.`9` AS `9` from (/* select#13 */ select 9 AS `9` union all /* select#14 */ select 10 AS `10`) `__15` except all /* select#16 */ select 11 AS `11` +Note 1003 /* select#1 */ select `__14`.`1` AS `1` from (/* select#8 */ select `__7`.`1` AS `1` from (/* select#2 */ select 1 AS `1` except /* select#3 */ select 5 AS `5` union all /* select#4 */ select 6 AS `6`) `__7` union /* select#9 */ select `__8`.`2` AS `2` from (/* select#5 */ select 2 AS `2` intersect /* select#6 */ select 3 AS `3` intersect /* select#7 */ select 4 AS `4`) `__8` except /* select#12 */ select `__11`.`7` AS `7` from (/* select#10 */ select 7 AS `7` intersect /* select#11 */ select 8 AS `8`) `__11`) `__14` union all /* select#15 */ select `__15`.`9` AS `9` from (/* select#13 */ select 9 AS `9` union all /* select#14 */ select 10 AS `10`) `__15` except all /* select#16 */ select 11 AS `11` (select 1 union all select 2) union (select 3 union all select 4); @@ -242,7 +242,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 5 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 /* select#1 */ select `__5`.`1` AS `1` from (/* select#2 */ select 1 AS `1` union /* select#3 */ select 2 AS `2`) `__5` union /* select#6 */ select `__6`.`3` AS `3` from (/* select#4 */ select 3 AS `3` union /* select#5 */ select 4 AS `4`) `__6` +Note 1003 /* select#1 */ select `__5`.`1` AS `1` from (/* select#2 */ select 1 AS `1` union all /* select#3 */ select 2 AS `2`) `__5` union /* select#6 */ select `__6`.`3` AS `3` from (/* select#4 */ select 3 AS `3` union /* select#5 */ select 4 AS `4`) `__6` (select 1 intersect all select 2) except select 3; @@ -258,7 +258,7 @@ NULL INTERSECT RESULT ALL NULL NULL NULL NULL NULL NULL 4 EXCEPT NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL EXCEPT RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 /* select#1 */ select `__4`.`1` AS `1` from (/* select#2 */ select 1 AS `1` intersect /* select#3 */ select 2 AS `2`) `__4` except /* select#4 */ select 3 AS `3` +Note 1003 /* select#1 */ select `__4`.`1` AS `1` from (/* select#2 */ select 1 AS `1` intersect all /* select#3 */ select 2 AS `2`) `__4` except /* select#4 */ select 3 AS `3` (select 1 intersect all select 2 intersect all select 3) intersect (select 4 intersect all select 5); @@ -278,7 +278,7 @@ NULL INTERSECT RESULT ALL NULL NULL NULL NULL NULL NULL NULL INTERSECT RESULT ALL NULL NULL NULL NULL NULL NULL NULL INTERSECT RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 /* select#1 */ select `__6`.`1` AS `1` from (/* select#2 */ select 1 AS `1` intersect /* select#3 */ select 2 AS `2` intersect /* select#4 */ select 3 AS `3`) `__6` intersect /* select#7 */ select `__7`.`4` AS `4` from (/* select#5 */ select 4 AS `4` intersect /* select#6 */ select 5 AS `5`) `__7` +Note 1003 /* select#1 */ select `__6`.`1` AS `1` from (/* select#2 */ select 1 AS `1` intersect all /* select#3 */ select 2 AS `2` intersect all /* select#4 */ select 3 AS `3`) `__6` intersect /* select#7 */ select `__7`.`4` AS `4` from (/* select#5 */ select 4 AS `4` intersect /* select#6 */ select 5 AS `5`) `__7` # test set operations with table value constructor (values (1,1),(1,1),(1,1),(2,2),(2,2),(3,3),(9,9)) INTERSECT ALL diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result index 75333b65f71..bd4f15af3c6 100644 --- a/mysql-test/main/table_value_constr.result +++ b/mysql-test/main/table_value_constr.result @@ -743,21 +743,19 @@ a b explain extended select * from t1 where a in (values (1)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` explain extended select * from t1 where a in (select * from (values (1)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` # IN-subquery with VALUES structure(s) : UNION with VALUES on the first place select * from t1 where a in (values (1) union select 2); @@ -776,7 +774,7 @@ explain extended select * from t1 where a in (values (1) union select 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +4 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -787,7 +785,7 @@ where a in (select * from (values (1)) as tvc_0 union select 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 4 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -812,7 +810,7 @@ where a in (select 2 union values (1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -4 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +4 DEPENDENT UNION eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -848,7 +846,7 @@ explain extended select * from t1 where a in (values (1) union all select b from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +4 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 3 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: @@ -858,7 +856,7 @@ where a in (select * from (values (1)) as tvc_0 union all select b from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 4 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: @@ -880,18 +878,18 @@ explain extended select * from t1 where a not in (values (1),(2)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 4 func 1 100.00 Using where; Full scan on NULL key 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#3 */ select `tvc_0`.`1` from (values (1),(2)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`1`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,(((`test`.`t1`.`a`) in on distinct_key where trigcond((`test`.`t1`.`a`) = `tvc_0`.`1`))))) explain extended select * from t1 where a not in (select * from (values (1),(2)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 4 func 1 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `tvc_0`.`1` from (values (1),(2)) `tvc_0` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`1`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<`test`.`t1`.`a`>((`test`.`t1`.`a`,(((`test`.`t1`.`a`) in on distinct_key where trigcond((`test`.`t1`.`a`) = `tvc_0`.`1`))))) # NOT IN subquery with VALUES structure(s) : UNION with VALUES on the first place select * from t1 where a not in (values (1) union select 2); @@ -978,21 +976,19 @@ a b explain extended select * from t1 where a = any (values (1),(2)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` explain extended select * from t1 where a = any (select * from (values (1),(2)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (values (1),(2)) `tvc_0` join `test`.`t1` where `tvc_0`.`1` = `test`.`t1`.`a` # ANY-subquery with VALUES structure(s) : UNION with VALUES on the first place select * from t1 where a = any (values (1) union select 2); @@ -1011,7 +1007,7 @@ explain extended select * from t1 where a = any (values (1) union select 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +4 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -1022,7 +1018,7 @@ where a = any (select * from (values (1)) as tvc_0 union select 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 4 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -1047,7 +1043,7 @@ where a = any (select 2 union values (1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -4 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +4 DEPENDENT UNION eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -1140,7 +1136,7 @@ where a = any (select 1 union values (1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -4 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +4 DEPENDENT UNION eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -2688,9 +2684,9 @@ a explain extended select a from t1 where a in (values (7) union values (8)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +4 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used -5 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +5 DEPENDENT UNION eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -2951,6 +2947,8 @@ values ((values (4)), (select 5)), ((select 2), (values (8))); values ((values (1) union values (1))); (values (1) union values (1)) 1 +values ((values (1) union all values (1))); +ERROR 21000: Subquery returns more than 1 row values ((values (1) union values (1) union values (1))); (values (1) union values (1) union values (1)) 1 diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test index 8fa443c3b77..b86244f9605 100644 --- a/mysql-test/main/table_value_constr.test +++ b/mysql-test/main/table_value_constr.test @@ -1575,6 +1575,9 @@ values ((values (4)), (select 5)), ((select 2), (values (8))); values ((values (1) union values (1))); +--error ER_SUBQUERY_NO_1_ROW +values ((values (1) union all values (1))); + values ((values (1) union values (1) union values (1))); values ((values ((values (4))))); diff --git a/mysql-test/main/union.result b/mysql-test/main/union.result index aab13d191a4..5b9e51ddee0 100644 --- a/mysql-test/main/union.result +++ b/mysql-test/main/union.result @@ -2783,3 +2783,70 @@ drop table t1; # # End of 10.3 tests # + +# check union all & union disctinct + +select 1 as res union select 2 union select 1 union select 2; +res +1 +2 +select 1 as res union distinct select 2 union distinct select 1 union distinct select 2; +res +1 +2 +select 1 as res union all select 2 union all select 1 union all select 2; +res +1 +2 +1 +2 +select truncate(seq/2,0)+1 as res from seq_1_to_6 union select 2; +res +1 +2 +3 +4 +select truncate(seq/2,0)+1 as res from seq_1_to_6 union distinct select 2; +res +1 +2 +3 +4 +select truncate(seq/2,0)+1 as res from seq_1_to_6 union all select 2; +res +1 +2 +2 +3 +3 +4 +2 +select 1 as res union all select 2 union distinct select 1 union all select 2; +res +1 +2 +2 +select 1 as res union select 2 union all select 1 union distinct select 3; +res +1 +2 +3 +select 1 as res union select 2 union all select 1 union distinct select 3 union all select 2; +res +1 +2 +3 +2 +select 1 as res union select 2 union all select 1 union distinct select 3 union all select 2 union distinct select 5; +res +1 +2 +3 +5 +select truncate(seq/2,0)+1 as res from seq_1_to_6 union all select 2 union all select 1 union distinct select 3 union all select 2; +res +1 +2 +3 +4 +2 diff --git a/mysql-test/main/union.test b/mysql-test/main/union.test index 4cebdcff9bb..98c36e0404a 100644 --- a/mysql-test/main/union.test +++ b/mysql-test/main/union.test @@ -1,6 +1,8 @@ # # Test of unions # +--source include/have_sequence.inc + CREATE TABLE t1 (a int not null, b char (10) not null); insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); @@ -2010,3 +2012,21 @@ drop table t1; --echo # --echo # End of 10.3 tests --echo # + +--echo +--echo # check union all & union disctinct +--echo + +select 1 as res union select 2 union select 1 union select 2; +select 1 as res union distinct select 2 union distinct select 1 union distinct select 2; +select 1 as res union all select 2 union all select 1 union all select 2; + +select truncate(seq/2,0)+1 as res from seq_1_to_6 union select 2; +select truncate(seq/2,0)+1 as res from seq_1_to_6 union distinct select 2; +select truncate(seq/2,0)+1 as res from seq_1_to_6 union all select 2; + +select 1 as res union all select 2 union distinct select 1 union all select 2; +select 1 as res union select 2 union all select 1 union distinct select 3; +select 1 as res union select 2 union all select 1 union distinct select 3 union all select 2; +select 1 as res union select 2 union all select 1 union distinct select 3 union all select 2 union distinct select 5; +select truncate(seq/2,0)+1 as res from seq_1_to_6 union all select 2 union all select 1 union distinct select 3 union all select 2; diff --git a/mysql-test/suite/compat/oracle/r/table_value_constr.result b/mysql-test/suite/compat/oracle/r/table_value_constr.result index c88dc245808..630c5932276 100644 --- a/mysql-test/suite/compat/oracle/r/table_value_constr.result +++ b/mysql-test/suite/compat/oracle/r/table_value_constr.result @@ -741,21 +741,19 @@ a b explain extended select * from t1 where a in (values (1)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1)) "tvc_0") where 1 +Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from (values (1)) "tvc_0" join "test"."t1" where "tvc_0"."1" = "test"."t1"."a" explain extended select * from t1 where a in (select * from (values (1)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1)) "tvc_0") where 1 +Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from (values (1)) "tvc_0" join "test"."t1" where "tvc_0"."1" = "test"."t1"."a" # IN-subquery with VALUES structure(s) : UNION with VALUES on the first place select * from t1 where a in (values (1) union select 2); @@ -774,7 +772,7 @@ explain extended select * from t1 where a in (values (1) union select 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +4 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -785,7 +783,7 @@ where a in (select * from (values (1)) as tvc_0 union select 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 4 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -810,7 +808,7 @@ where a in (select 2 union values (1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -4 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +4 DEPENDENT UNION eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -846,7 +844,7 @@ explain extended select * from t1 where a in (values (1) union all select b from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +4 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 3 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: @@ -856,7 +854,7 @@ where a in (select * from (values (1)) as tvc_0 union all select b from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 4 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: @@ -878,18 +876,18 @@ explain extended select * from t1 where a not in (values (1),(2)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +3 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 4 func 1 100.00 Using where; Full scan on NULL key 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" where !<"test"."t1"."a">(("test"."t1"."a","test"."t1"."a" in ( (/* select#3 */ select "tvc_0"."1" from (values (1),(2)) "tvc_0" ), ("test"."t1"."a" in on distinct_key where "test"."t1"."a" = ""."1")))) +Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" where !<"test"."t1"."a">(("test"."t1"."a",((("test"."t1"."a") in on distinct_key where trigcond(("test"."t1"."a") = "tvc_0"."1"))))) explain extended select * from t1 where a not in (select * from (values (1),(2)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +2 DEPENDENT SUBQUERY unique_subquery distinct_key distinct_key 4 func 1 100.00 Using where; Full scan on NULL key 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" where !<"test"."t1"."a">(("test"."t1"."a","test"."t1"."a" in ( (/* select#2 */ select "tvc_0"."1" from (values (1),(2)) "tvc_0" ), ("test"."t1"."a" in on distinct_key where "test"."t1"."a" = ""."1")))) +Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" where !<"test"."t1"."a">(("test"."t1"."a",((("test"."t1"."a") in on distinct_key where trigcond(("test"."t1"."a") = "tvc_0"."1"))))) # NOT IN subquery with VALUES structure(s) : UNION with VALUES on the first place select * from t1 where a not in (values (1) union select 2); @@ -976,21 +974,19 @@ a b explain extended select * from t1 where a = any (values (1),(2)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -3 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1),(2)) "tvc_0") where 1 +Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from (values (1),(2)) "tvc_0" join "test"."t1" where "tvc_0"."1" = "test"."t1"."a" explain extended select * from t1 where a = any (select * from (values (1),(2)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED ALL NULL NULL NULL NULL 2 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1),(2)) "tvc_0") where 1 +Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from (values (1),(2)) "tvc_0" join "test"."t1" where "tvc_0"."1" = "test"."t1"."a" # ANY-subquery with VALUES structure(s) : UNION with VALUES on the first place select * from t1 where a = any (values (1) union select 2); @@ -1009,7 +1005,7 @@ explain extended select * from t1 where a = any (values (1) union select 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -4 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +4 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -1020,7 +1016,7 @@ where a = any (select * from (values (1)) as tvc_0 union select 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -2 DEPENDENT SUBQUERY ref key0 key0 4 func 2 100.00 +2 DEPENDENT SUBQUERY eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used 4 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL @@ -1045,7 +1041,7 @@ where a = any (select 2 union values (1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -4 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +4 DEPENDENT UNION eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -1138,7 +1134,7 @@ where a = any (select 1 union values (1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -4 DEPENDENT UNION ref key0 key0 4 func 2 100.00 +4 DEPENDENT UNION eq_ref distinct_key distinct_key 4 func 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index f2e2247bae1..0b008c34601 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -298,7 +298,7 @@ SELECT * FROM federated.t1 WHERE id >= 5) t WHERE federated.t3.name=t.name; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 7 -1 PRIMARY ref key0 key0 18 federated.t3.name 2 +1 PRIMARY ref key1 key1 18 federated.t3.name 2 2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL # # MDEV-21887: federatedx crashes on SELECT ... INTO query in select_handler code diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 9b4e60b4086..054a1feaf47 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1588,8 +1588,9 @@ Item_exists_subselect::Item_exists_subselect(THD *thd, { DBUG_ENTER("Item_exists_subselect::Item_exists_subselect"); - init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this)); + select_lex->distinct= 1; + select_lex->master_unit()->distinct= 1; max_columns= UINT_MAX; null_value= FALSE; //can't be NULL base_flags&= ~item_base_t::MAYBE_NULL; //can't be NULL @@ -1640,6 +1641,39 @@ Item_in_subselect::Item_in_subselect(THD *thd, Item * left_exp, Item_row(thd, static_cast(left_exp)); func= &eq_creator; init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this)); + select_lex->distinct= 1; + + /* + If the IN subquery (xxx IN (SELECT ...) is a join without grouping, + we don't need duplicates from the tables it is joining. These + tables can be derived tables, like shown in the following + example. In this case, it's useful to indicate that we don't need + duplicates from them either. + + Example: + col IN (SELECT ... -- this is the select_lex + FROM + (SELECT ... FROM t1) AS t1, -- child1, first_inner_init(). + (SELECT ... FROM t2) AS t2, -- child2 + WHERE + ... + ) + + We don't need duplicates from either child1 or child2. + We only indicate this to child1 (select_lex->first_inner_unit()), as that + catches most of practically important use cases. + + (The check for item==NULL is to make sure the subquery is a derived table + and not any other kind of subquery like another IN (SELECT ...) or a scalar- + context (SELECT 'foo')) + */ + + select_lex->master_unit()->distinct= 1; + if (!select_lex->with_sum_func && + select_lex->first_inner_unit() && + select_lex->first_inner_unit()->item == NULL) + select_lex->first_inner_unit()->distinct= 1; + max_columns= UINT_MAX; set_maybe_null(); reset(); @@ -1667,6 +1701,16 @@ Item_allany_subselect::Item_allany_subselect(THD *thd, Item * left_exp, Item_row(thd, static_cast(left_exp)); func= func_creator(all_arg); init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this)); + select_lex->distinct= 1; + /* + If this is is 'xxx IN (SELECT ...) mark that the we are only interested in + unique values for the select + */ + select_lex->master_unit()->distinct= 1; + if (!select_lex->with_sum_func && + select_lex->first_inner_unit() && + select_lex->first_inner_unit()->item == NULL) + select_lex->first_inner_unit()->distinct= 1; max_columns= 1; reset(); //if test_limit will fail then error will be reported to client diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 6f0857239dd..1fa5179875c 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -870,18 +870,20 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived) goto exit; /* - Temp table is created so that it hounours if UNION without ALL is to be + Temp table is created so that it honors if UNION without ALL is to be processed - As 'distinct' parameter we always pass FALSE (0), because underlying - query will control distinct condition by itself. Correct test of - distinct underlying query will be is_unit_op && + As 'distinct' parameter we pass unit->distinct, which tells us if + the values should be uniq. + Note that the underlying query will also control distinct condition. + Correct test of distinct underlying query will be is_unit_op && !unit->union_distinct->next_select() (i.e. it is union and last distinct SELECT is last SELECT of UNION). */ thd->create_tmp_table_for_derived= TRUE; if (!(derived->table) && - derived->derived_result->create_result_table(thd, &unit->types, FALSE, + derived->derived_result->create_result_table(thd, &unit->types, + unit->distinct, (first_select->options | thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS), diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 3707b8ef8e4..5e85d1d0902 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2873,7 +2873,7 @@ void st_select_lex_node::init_query_common() { options= 0; set_linkage(UNSPECIFIED_TYPE); - distinct= TRUE; + distinct= FALSE; no_table_names_allowed= 0; uncacheable= 0; } @@ -10146,6 +10146,7 @@ SELECT_LEX_UNIT *LEX::parsed_select_expr_start(SELECT_LEX *s1, SELECT_LEX *s2, if (res == NULL) return NULL; res->pre_last_parse= sel1; + res->distinct= distinct; push_select(res->fake_select_lex); return res; } @@ -10392,7 +10393,6 @@ bool LEX::parsed_TVC_start() insert_list= 0; if (!(sel= alloc_select(TRUE)) || push_select(sel)) return true; - sel->init_select(); sel->braces= FALSE; // just initialisation return false; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1ae83e35664..9169ceca236 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2613,8 +2613,12 @@ int JOIN::optimize_stage2() if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE)) DBUG_RETURN(1); - if (optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_WITH_KEYS)) - drop_unused_derived_keys(); + /* + We have to call drop_unused_derived_keys() even if we don't have any + generated keys (enabled with OPTIMIZER_SWITCH_DERIVED_WITH_KEYS) + as we may still have unique constraints we have to get rid of. + */ + drop_unused_derived_keys(); if (rollup.state != ROLLUP::STATE_NONE) { @@ -5698,7 +5702,14 @@ make_join_statistics(JOIN *join, List &tables_list, base_const_ref.intersect(base_part); base_eq_part= eq_part; base_eq_part.intersect(base_part); - if (table->actual_key_flags(keyinfo) & HA_NOSAME) + + /* + We can read the const record if we are using a full unique key and + if the table is not an unopened to be materialized table/view. + */ + if ((table->actual_key_flags(keyinfo) & HA_NOSAME) && + (!s->table->pos_in_table_list->is_materialized_derived() || + s->table->pos_in_table_list->fill_me)) { if (base_const_ref == base_eq_part && @@ -13573,9 +13584,12 @@ void JOIN::drop_unused_derived_keys() if (tab->ref.key >= 0 && tab->ref.key < MAX_KEY) tab->ref.key= 0; else + { tmp_tbl->s->keys= 0; + tmp_tbl->s->uniques= 0; + } } - tab->keys= (key_map) (tmp_tbl->s->keys ? 1 : 0); + tab->keys= (key_map) (tmp_tbl->s->keys || tmp_tbl->s->uniques ? 1 : 0); } } @@ -22708,12 +22722,16 @@ join_read_const_table(THD *thd, JOIN_TAB *tab, POSITION *pos) if (tab->table->pos_in_table_list->is_materialized_derived() && !tab->table->pos_in_table_list->fill_me) { + DBUG_ASSERT(0); //TODO: don't get here at all - /* Skip materialized derived tables/views. */ + /* + Skip materialized derived tables/views as they temporary table is not + opened yet. + */ DBUG_RETURN(0); } - else if (tab->table->pos_in_table_list->jtbm_subselect && - tab->table->pos_in_table_list->jtbm_subselect->is_jtbm_const_tab) + else if (tab->table->pos_in_table_list->jtbm_subselect && + tab->table->pos_in_table_list->jtbm_subselect->is_jtbm_const_tab) { /* Row will not be found */ int res; diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index 9745997f60d..bb5914a78a6 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -705,11 +705,11 @@ st_select_lex *wrap_tvc(THD *thd, st_select_lex *tvc_sl, goto err; wrapper_sl->select_number= ++thd->lex->stmt_lex->current_select_number; wrapper_sl->parent_lex= lex; /* Used in init_query. */ - wrapper_sl->init_query(); - wrapper_sl->init_select(); + wrapper_sl->make_empty_select(); wrapper_sl->nest_level= tvc_sl->nest_level; wrapper_sl->parsing_place= tvc_sl->parsing_place; + wrapper_sl->distinct= tvc_sl->distinct; wrapper_sl->set_linkage(tvc_sl->get_linkage()); wrapper_sl->exclude_from_table_unique_test= tvc_sl->exclude_from_table_unique_test; @@ -737,6 +737,7 @@ st_select_lex *wrap_tvc(THD *thd, st_select_lex *tvc_sl, derived_unit->init_query(); derived_unit->thd= thd; derived_unit->include_down(wrapper_sl); + derived_unit->distinct= tvc_sl->distinct; /* Attach the select used of TVC as the only slave to the unit for @@ -1011,7 +1012,9 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd, lex->init_select(); tvc_select= lex->current_select; derived_unit= tvc_select->master_unit(); + derived_unit->distinct= 1; tvc_select->set_linkage(DERIVED_TABLE_TYPE); + tvc_select->distinct= 1; /* Create TVC used in the transformation */ if (create_value_list_for_tvc(thd, &values)) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 0a92422676a..188f98aa7dd 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1302,6 +1302,7 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, bool instantiate_tmp_table= false; bool single_tvc= !first_sl->next_select() && first_sl->tvc; bool single_tvc_wo_order= single_tvc && !first_sl->order_list.elements; + bool distinct_key= 0; DBUG_ENTER("st_select_lex_unit::prepare"); DBUG_ASSERT(thd == current_thd); @@ -1405,15 +1406,17 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, { case INTERSECT_TYPE: have_intersect= TRUE; - if (!s->distinct){ - have_except_all_or_intersect_all= true; - } + if (!s->distinct) + have_except_all_or_intersect_all= TRUE; break; case EXCEPT_TYPE: have_except= TRUE; - if (!s->distinct){ + if (!s->distinct) have_except_all_or_intersect_all= TRUE; - } + break; + case DERIVED_TABLE_TYPE: + if (s->distinct) + distinct_key= 1; break; default: break; @@ -1620,7 +1623,8 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, if (join_union_item_types(thd, types, union_part_count + 1)) goto err; if (union_result->create_result_table(thd, &types, - MY_TEST(union_distinct), + (MY_TEST(union_distinct) || + distinct_key), create_options, &derived_arg->alias, false, instantiate_tmp_table, false, @@ -1643,7 +1647,7 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, res= derived_arg->derived_result->create_result_table(thd, &types, - FALSE, + distinct_key, create_options, &derived_arg->alias, FALSE, FALSE, @@ -1767,9 +1771,9 @@ cont: union_result->create_result_table(thd, &types, MY_TEST(union_distinct) || have_except_all_or_intersect_all || - have_intersect, - create_options, &empty_clex_str, false, - instantiate_tmp_table, false, + have_intersect || distinct_key, + create_options, &empty_clex_str, + false, instantiate_tmp_table, false, hidden); union_result->addon_cnt= hidden; for (uint i= 0; i < hidden; i++) From b44e28af6f4cb839a9de896e95e5652a81961889 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 9 May 2022 11:36:44 +0300 Subject: [PATCH 031/123] Simple optimization: Remove JOIN::set_group_rpa as it is not needed --- sql/sql_select.cc | 8 +------- sql/sql_select.h | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9169ceca236..102dbe12227 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -532,7 +532,6 @@ void JOIN::init(THD *thd_arg, List &fields_arg, no_const_tables= FALSE; first_select= sub_select; - set_group_rpa= false; group_sent= 0; outer_ref_cond= pseudo_bits_cond= NULL; @@ -4467,7 +4466,6 @@ JOIN::reinit() if (current_ref_ptrs != items0) { set_items_ref_array(items0); - set_group_rpa= false; } /* need to reset ref access state (see join_read_key) */ @@ -15383,7 +15381,6 @@ void JOIN::cleanup(bool full) if (current_ref_ptrs != items0) { set_items_ref_array(items0); - set_group_rpa= false; } DBUG_VOID_RETURN; } @@ -23647,11 +23644,8 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) List *fields= join_tab ? (join_tab-1)->fields : join->fields; DBUG_ENTER("end_send_group"); - if (!join->items3.is_null() && !join->set_group_rpa) - { - join->set_group_rpa= true; + if (!join->items3.is_null() && join->current_ref_ptrs != join->items3) join->set_items_ref_array(join->items3); - } if (!join->first_record || end_of_records || (idx=test_if_group_changed(join->group_fields)) >= 0) diff --git a/sql/sql_select.h b/sql/sql_select.h index ec13eecd4d6..0ac33b9303e 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1574,8 +1574,6 @@ public: /* SJM nests that are executed with SJ-Materialization strategy */ List sjm_info_list; - /** TRUE <=> ref_pointer_array is set to items3. */ - bool set_group_rpa; /** Exec time only: TRUE <=> current group has been sent */ bool group_sent; /** From 249475b99cf32dfa12efbbf7058238587c90ca47 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 29 Sep 2022 19:57:56 +0300 Subject: [PATCH 032/123] Make --ps-protocol command work in --ps-protocol mode --- client/mysqltest.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 9682f346253..d3e5f96faea 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -8607,6 +8607,7 @@ end: var_set_errno(mysql_stmt_errno(stmt)); + display_optimizer_trace(cn, ds); revert_properties(); /* Close the statement if reconnect, need new prepare */ From 1d82e5daf7174a402a603c553357dcb78515eb04 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 13 Jun 2022 17:45:37 +0300 Subject: [PATCH 033/123] Move join->emb_smj_nest setting to choose_plan() This cleans up the interface for choose_plan() as it is not depending on setting join->emb_sj_nest. choose_plan() now sets up join->emb_sj_nest and join->allowed_tables before calling optimize_straight_join() and best_extension_by_limited_search(). Other things: - Converted some 'if' to DBUG_ASSERT() as these should always be true. - Calculate 'allowed_tables' in choose_plan() as this never changes in the childs. - Added assert to check that next_emb->nested_join->n_tables doesn't get to a wrong value. - Documented some variables in sql_select.h --- sql/opt_split.cc | 2 +- sql/opt_subselect.cc | 4 +--- sql/sql_select.cc | 39 ++++++++++++++++++++++++++------------- sql/sql_select.h | 27 +++++++++++++++++++++++++-- 4 files changed, 53 insertions(+), 19 deletions(-) diff --git a/sql/opt_split.cc b/sql/opt_split.cc index 1bd90869f2e..6c31b895378 100644 --- a/sql/opt_split.cc +++ b/sql/opt_split.cc @@ -973,7 +973,7 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count, table_map all_table_map= (((table_map) 1) << join->table_count) - 1; reset_validity_vars_for_keyuses(best_key_keyuse_ext_start, best_table, best_key, remaining_tables, true); - choose_plan(join, all_table_map & ~join->const_table_map); + choose_plan(join, all_table_map & ~join->const_table_map, 0); /* Check that the chosen plan is really a splitting plan. diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index bd0a187db63..71030444a55 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -2500,8 +2500,7 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map) !sj_nest->sj_subq_pred->is_correlated && sj_nest->sj_subq_pred->types_allow_materialization) { - join->emb_sjm_nest= sj_nest; - if (choose_plan(join, all_table_map &~join->const_table_map)) + if (choose_plan(join, all_table_map &~join->const_table_map, sj_nest)) DBUG_RETURN(TRUE); /* purecov: inspected */ /* The best plan to run the subquery is now in join->best_positions, @@ -2594,7 +2593,6 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map) } } } - join->emb_sjm_nest= NULL; DBUG_RETURN(FALSE); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 102dbe12227..486bc688cf3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6035,7 +6035,7 @@ make_join_statistics(JOIN *join, List &tables_list, /* Find an optimal join order of the non-constant tables. */ if (join->const_tables != join->table_count) { - if (choose_plan(join, all_table_map & ~join->const_table_map)) + if (choose_plan(join, all_table_map & ~join->const_table_map, 0)) goto error; #ifdef HAVE_valgrind @@ -9238,6 +9238,7 @@ static void choose_initial_table_order(JOIN *join) @param join pointer to the structure providing all context info for the query @param join_tables set of the tables in the query + @param emb_sjm_nest List of tables in case of materialized semi-join nest @retval FALSE ok @@ -9246,13 +9247,14 @@ static void choose_initial_table_order(JOIN *join) */ bool -choose_plan(JOIN *join, table_map join_tables) +choose_plan(JOIN *join, table_map join_tables, TABLE_LIST *emb_sjm_nest) { uint search_depth= join->thd->variables.optimizer_search_depth; uint use_cond_selectivity= join->thd->variables.optimizer_use_condition_selectivity; bool straight_join= MY_TEST(join->select_options & SELECT_STRAIGHT_JOIN); THD *thd= join->thd; + qsort2_cmp jtab_sort_func; DBUG_ENTER("choose_plan"); join->cur_embedding_map= 0; @@ -9260,14 +9262,20 @@ choose_plan(JOIN *join, table_map join_tables) join->prune_level= join->thd->variables.optimizer_prune_level; reset_nj_counters(join, join->join_list); - qsort2_cmp jtab_sort_func; - if (join->emb_sjm_nest) + if ((join->emb_sjm_nest= emb_sjm_nest)) { /* We're optimizing semi-join materialization nest, so put the tables from this semi-join as first */ jtab_sort_func= join_tab_cmp_embedded_first; + /* + If we are searching for the execution plan of a materialized semi-join + nest then allowed_tables contains bits only for the tables from this + nest. + */ + join->allowed_tables= (emb_sjm_nest->sj_inner_tables & + ~join->const_table_map); } else { @@ -9280,6 +9288,7 @@ choose_plan(JOIN *join, table_map join_tables) of records accessed. */ jtab_sort_func= straight_join ? join_tab_cmp_straight : join_tab_cmp; + join->allowed_tables= ~join->const_table_map; } /* @@ -9290,19 +9299,19 @@ choose_plan(JOIN *join, table_map join_tables) */ my_qsort2(join->best_ref + join->const_tables, join->table_count - join->const_tables, sizeof(JOIN_TAB*), - jtab_sort_func, (void*)join->emb_sjm_nest); + jtab_sort_func, (void*) emb_sjm_nest); Json_writer_object wrapper(thd); Json_writer_array trace_plan(thd,"considered_execution_plans"); - if (!join->emb_sjm_nest) - { + if (!emb_sjm_nest) choose_initial_table_order(join); - } + /* Note: constant tables are already in the join prefix. We don't put them into the cur_sj_inner_tables, though. */ + join->cur_sj_inner_tables= 0; if (straight_join) @@ -9334,6 +9343,8 @@ choose_plan(JOIN *join, table_map join_tables) */ if (join->thd->lex->is_single_level_stmt()) join->thd->status_var.last_query_cost= join->best_read; + + join->emb_sjm_nest= 0; DBUG_RETURN(FALSE); } @@ -9728,6 +9739,7 @@ greedy_search(JOIN *join, // ==join->tables or # tables in the sj-mat nest we're optimizing uint n_tables __attribute__((unused)); DBUG_ENTER("greedy_search"); + DBUG_ASSERT(!(remaining_tables & join->const_table_map)); /* number of tables that remain to be optimized */ usable_tables= (join->emb_sjm_nest ? @@ -10716,7 +10728,6 @@ best_extension_by_limited_search(JOIN *join, /* allowed_tables is used to check if there are tables left that can improve a key search and to see if there are more tables to add in next iteration. - allowed_current_tables tells us which tables we can add to the current plan at this stage. */ @@ -10880,7 +10891,7 @@ best_extension_by_limited_search(JOIN *join, */ if (best_record_count >= current_record_count && best_read_time >= current_read_time && - (!(position->key_dependent & allowed_tables) || + (!(position->key_dependent & join->allowed_tables) || position->records_read < 2.0)) { best_record_count= current_record_count; @@ -10944,7 +10955,7 @@ best_extension_by_limited_search(JOIN *join, .add("estimated_join_cardinality", partial_join_cardinality); if (search_depth > 1 && - ((remaining_tables & ~real_table_bit) & allowed_tables)) + ((remaining_tables & ~real_table_bit) & join->allowed_tables)) { /* Recursively expand the current partial plan */ @@ -18299,10 +18310,12 @@ static bool check_interleaving_with_nj(JOIN_TAB *next_tab) join->cur_embedding_map |= next_emb->nested_join->nj_map; } + DBUG_ASSERT(next_emb->nested_join->n_tables >= + next_emb->nested_join->counter); + if (next_emb->nested_join->n_tables != next_emb->nested_join->counter) break; - /* We're currently at Y or Z-bracket as depicted in the above picture. Mark that we've left it and continue walking up the brackets hierarchy. @@ -29869,7 +29882,7 @@ JOIN::reoptimize(Item *added_where, table_map join_tables, return REOPT_ERROR; /* Re-run the join optimizer to compute a new query plan. */ - if (choose_plan(this, join_tables)) + if (choose_plan(this, join_tables, 0)) return REOPT_ERROR; return REOPT_NEW_PLAN; diff --git a/sql/sql_select.h b/sql/sql_select.h index 0ac33b9303e..87b80fd52e9 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -359,7 +359,23 @@ typedef struct st_join_table { double cached_scan_time; double cached_scan_and_compare_time; - table_map dependent,key_dependent; + /* + dependent is the table that must be read before the current one + Used for example with STRAIGHT_JOIN or outer joins + */ + table_map dependent; + /* + key_dependent is dependent but add those tables that are used to compare + with a key field in a simple expression. See add_key_field(). + It is only used to prune searches in best_extension_by_limited_search() + */ + table_map key_dependent; + /* + Tables that have expression in their attached condition clause that depends + on this table. + */ + table_map related_tables; + /* Bitmap of TAB_INFO_* bits that encodes special line for EXPLAIN 'Extra' column, or 0 if there is no info. @@ -1256,6 +1272,13 @@ public: bool hash_join; bool do_send_rows; table_map const_table_map; + + /* + Tables one is allowed to use in choose_plan(). Either all or + set to a mapt of the tables in the materialized semi-join nest + */ + table_map allowed_tables; + /** Bitmap of semijoin tables that the current partial plan decided to materialize and access by lookups @@ -2370,7 +2393,7 @@ inline Item * or_items(THD *thd, Item* cond, Item *item) { return (cond ? (new (thd->mem_root) Item_cond_or(thd, cond, item)) : item); } -bool choose_plan(JOIN *join, table_map join_tables); +bool choose_plan(JOIN *join, table_map join_tables, TABLE_LIST *emb_sjm_nest); void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab, table_map last_remaining_tables, bool first_alt, uint no_jbuf_before, From 4515a89814adaa61b26a900086a54b8cf51f188a Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 16 Jun 2022 13:12:01 +0300 Subject: [PATCH 034/123] Fixed cost calculations for materialized tables One effect of this change in the test suite is that tests with very few rows changed to use sub queries instead of materialization. This is correct and expected as for these the materialization overhead is too high. A lot of tests where fixed to still use materialization by adding a few rows to the tables (most tests has only 2-3 rows and are thus easily affected when cost computations are changed). Other things: - Added more variables to TMPTABLE_COSTS for better cost calculation - Added cost of copying rows to TMPTABLE_COSTS lookup and write - Added THD::optimizer_cache_hit_ratio for easier cost calculations - Added DISK_FAST_READ_SIZE to be used when calculating costs when reading big blocks from a disk --- mysql-test/include/explain_non_select.inc | 6 +- mysql-test/include/index_merge1.inc | 2 +- mysql-test/main/cte_nonrecursive.result | 8 +- mysql-test/main/derived_cond_pushdown.result | 10 +- mysql-test/main/derived_cond_pushdown.test | 2 +- mysql-test/main/explain_json.result | 32 ++-- mysql-test/main/index_merge_myisam.result | 4 +- .../main/myisam_explain_non_select_all.result | 34 ++-- mysql-test/main/opt_trace.result | 156 ++++++++++++------ mysql-test/main/order_by.result | 18 +- mysql-test/main/order_by.test | 2 +- mysql-test/main/subselect.result | 23 ++- mysql-test/main/subselect.test | 16 +- mysql-test/main/subselect3.inc | 11 +- mysql-test/main/subselect3.result | 20 ++- mysql-test/main/subselect3_jcl6.result | 20 ++- mysql-test/main/subselect4.result | 36 ++-- mysql-test/main/subselect4.test | 8 +- mysql-test/main/subselect_exists2in.result | 19 ++- mysql-test/main/subselect_exists2in.test | 12 +- mysql-test/main/subselect_mat.result | 16 +- mysql-test/main/subselect_mat_cost.result | 40 +---- mysql-test/main/subselect_mat_cost.test | 8 +- .../main/subselect_no_exists_to_in.result | 18 +- mysql-test/main/subselect_no_mat.result | 18 +- mysql-test/main/subselect_no_opts.result | 18 +- mysql-test/main/subselect_no_scache.result | 23 ++- mysql-test/main/subselect_no_semijoin.result | 42 +++-- .../main/subselect_partial_match.result | 18 +- mysql-test/main/subselect_partial_match.test | 8 +- mysql-test/main/subselect_sj.result | 23 +-- mysql-test/main/subselect_sj.test | 2 +- mysql-test/main/subselect_sj2.result | 19 ++- mysql-test/main/subselect_sj2.test | 15 +- mysql-test/main/subselect_sj2_jcl6.result | 24 ++- mysql-test/main/subselect_sj2_mat.result | 35 ++-- mysql-test/main/subselect_sj2_mat.test | 2 +- mysql-test/main/subselect_sj_jcl6.result | 23 +-- mysql-test/main/subselect_sj_mat.result | 37 ++--- mysql-test/main/type_time_6065.result | 5 +- mysql-test/main/view.test | 3 +- sql/handler.cc | 3 +- sql/opt_split.cc | 2 +- sql/opt_subselect.cc | 66 +++++--- sql/optimizer_costs.h | 4 +- sql/sql_class.cc | 2 +- sql/sql_class.h | 2 + sql/sql_const.h | 6 + sql/sql_select.h | 5 +- sql/sys_vars.cc | 11 +- 50 files changed, 566 insertions(+), 371 deletions(-) diff --git a/mysql-test/include/explain_non_select.inc b/mysql-test/include/explain_non_select.inc index d22310c9813..9ce620a72de 100644 --- a/mysql-test/include/explain_non_select.inc +++ b/mysql-test/include/explain_non_select.inc @@ -73,11 +73,11 @@ INSERT INTO t2 VALUES (1), (2), (3); --source include/explain_utils.inc DROP TABLE t1, t2; ---echo #7 +--echo #7a CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1), (2), (3); CREATE TABLE t2 (b INT); -INSERT INTO t2 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (1), (2), (3), (1000); --let $query = UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) --let $select = SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) --source include/explain_utils.inc @@ -197,7 +197,7 @@ DROP TABLE t1, t2, t3; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1), (2), (3); CREATE TABLE t2 (a INT); -INSERT INTO t2 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (1), (2), (3), (1000); --let $query = UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) --let $select = SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) --source include/explain_utils.inc diff --git a/mysql-test/include/index_merge1.inc b/mysql-test/include/index_merge1.inc index 91609f628ca..199fc9d3b2f 100644 --- a/mysql-test/include/index_merge1.inc +++ b/mysql-test/include/index_merge1.inc @@ -517,7 +517,7 @@ DROP TABLE t1; create table t1 (a int); insert into t1 values (1),(2); create table t2(a int, b int); -insert into t2 values (1,1), (2, 1000); +insert into t2 values (1,1), (2, 1000),(5000,5000); create table t3 (a int, b int, filler char(100), key(a), key(b)); insert into t3 select 1000, 1000,'filler' from seq_1_to_1000; diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result index 4c0aa2e8cf3..58418cc7d9d 100644 --- a/mysql-test/main/cte_nonrecursive.result +++ b/mysql-test/main/cte_nonrecursive.result @@ -418,8 +418,8 @@ t2.c in (with t as (select * from t1 where t1.a<5) select t2.c from t2,t where t2.c=t.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 -1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where 3 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) explain @@ -430,8 +430,8 @@ from t2,(select * from t1 where t1.a<5) as t where t2.c=t.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 -1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) # two different definitions of t: one in the with clause of the main query, @@ -461,8 +461,8 @@ t.c in (with t as (select * from t1 where t1.a<5) select t2.c from t2,t where t2.c=t.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) 4 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where 4 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) explain @@ -472,8 +472,8 @@ t.c in (select t2.c from t2, (select * from t1 where t1.a<5) as t where t2.c=t.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where 3 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) # another with table tt is defined in the with clause of a subquery diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index b60359f074c..ce0338bee1f 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -19723,7 +19723,7 @@ create table t1 (id int, a int, index (a), index (id, a)) engine=myisam; insert into t1 values (17,1),(17,3010),(17,3013),(17,3053),(21,2446),(21,2467),(21,2); create table t2 (a int) engine=myisam; -insert into t2 values (1),(2),(3); +insert into t2 values (1),(2),(3),(1000),(2000),(3000); create table t3 (id int) engine=myisam; insert into t3 values (1),(2); analyze table t1,t2,t3; @@ -19747,7 +19747,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ref a a 5 test.t3.id 1 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 1 PRIMARY ref key0 key0 5 test.t3.id 2 -3 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 +3 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 2 DERIVED cp2 index NULL a 5 NULL 7 Using index explain format=json select * from t1, (select a from t1 cp2 group by a) dt, t3 where dt.a = t1.a and t1.a = t3.id and t1.a in (select a from t2); @@ -19798,7 +19798,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", - "rows": 3, + "rows": 6, "filtered": 100 } } @@ -19855,7 +19855,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ref a a 5 test.t3.id 1 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 1 PRIMARY ref key0 key0 5 test.t3.id 2 -3 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 +3 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 2 LATERAL DERIVED cp2 ref a a 5 test.t1.a 1 Using where; Using index explain format=json select * from t1, (select a from t1 cp2 group by a) dt, t3 where dt.a = t1.a and t1.a = t3.id and t1.a in (select a from t2); @@ -19906,7 +19906,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", - "rows": 3, + "rows": 6, "filtered": 100 } } diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index a09fd1b59e3..83e784c3450 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -3601,7 +3601,7 @@ insert into t1 values (17,1),(17,3010),(17,3013),(17,3053),(21,2446),(21,2467),(21,2); create table t2 (a int) engine=myisam; -insert into t2 values (1),(2),(3); +insert into t2 values (1),(2),(3),(1000),(2000),(3000); create table t3 (id int) engine=myisam; insert into t3 values (1),(2); diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index fde96bc1a14..d861eff05f1 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -728,19 +728,6 @@ EXPLAIN "filtered": 100 } }, - { - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL" - } - }, { "table": { "table_name": "", @@ -769,6 +756,19 @@ EXPLAIN } } } + }, + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "1Kb", + "join_type": "BNL" + } } ] } @@ -1078,7 +1078,7 @@ EXPLAIN "access_type": "ALL", "rows": 2, "filtered": 100, - "attached_condition": "!(t1.a,t1.a in (subquery#2))" + "attached_condition": "!(t1.a,(subquery#2))" } } ], @@ -1086,13 +1086,15 @@ EXPLAIN { "query_block": { "select_id": 2, + "having_condition": "trigcond(t2.b is null)", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, - "filtered": 100 + "filtered": 100, + "attached_condition": "trigcond((t1.a) = t2.b or t2.b is null)" } } ] diff --git a/mysql-test/main/index_merge_myisam.result b/mysql-test/main/index_merge_myisam.result index 7d10500d34d..30bda34ec0b 100644 --- a/mysql-test/main/index_merge_myisam.result +++ b/mysql-test/main/index_merge_myisam.result @@ -554,7 +554,7 @@ DROP TABLE t1; create table t1 (a int); insert into t1 values (1),(2); create table t2(a int, b int); -insert into t2 values (1,1), (2, 1000); +insert into t2 values (1,1), (2, 1000),(5000,5000); create table t3 (a int, b int, filler char(100), key(a), key(b)); insert into t3 select 1000, 1000,'filler' from seq_1_to_1000; insert into t3 values (1,1,'data'); @@ -566,7 +566,7 @@ where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 2 MATERIALIZED t3 ALL a,b NULL NULL NULL 1002 Range checked for each record (index map: 0x3) select * from t1 where exists (select 1 from t2, t3 diff --git a/mysql-test/main/myisam_explain_non_select_all.result b/mysql-test/main/myisam_explain_non_select_all.result index f14676bb394..98bb644fd5f 100644 --- a/mysql-test/main/myisam_explain_non_select_all.result +++ b/mysql-test/main/myisam_explain_non_select_all.result @@ -327,11 +327,11 @@ Handler_read_rnd_next 7 Handler_update 2 DROP TABLE t1, t2; -#7 +#7a CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1), (2), (3); CREATE TABLE t2 (b INT); -INSERT INTO t2 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (1), (2), (3), (1000); # # query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) # select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) @@ -341,17 +341,17 @@ Warning 1287 ' INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using where # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -1004,7 +1004,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 100.00 Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where 1 # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution @@ -1015,7 +1015,7 @@ Warning 1287 ' INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 -2 DEPENDENT SUBQUERY t2 ALL IDX NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 2 FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 -2 DEPENDENT SUBQUERY t2 ALL IDX NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 2 100.00 Warnings: Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 # Status of EXPLAIN EXTENDED query @@ -2678,7 +2677,7 @@ FLUSH TABLES; EXPLAIN EXTENDED SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 -2 DEPENDENT SUBQUERY t2 ALL IDX NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 2 100.00 Warnings: Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select <`test`.`t1`.`f1`>((/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where `test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` @@ -2689,12 +2688,14 @@ Warnings: Warning 1287 ' INTO FROM...' instead # Status of "equivalent" SELECT query execution: Variable_name Value -Handler_read_key 9 -Handler_read_rnd_next 9 +Handler_read_key 11 +Handler_read_next 2 +Handler_read_rnd_next 3 # Status of testing query execution: Variable_name Value -Handler_read_key 7 -Handler_read_rnd_next 9 +Handler_read_key 9 +Handler_read_next 2 +Handler_read_rnd_next 3 Handler_update 2 DROP TABLE t1, t2; diff --git a/mysql-test/main/myisam_icp.result b/mysql-test/main/myisam_icp.result index 5dfa61effef..2ffd2d9ad4b 100644 --- a/mysql-test/main/myisam_icp.result +++ b/mysql-test/main/myisam_icp.result @@ -407,7 +407,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 ORDER BY c1 LIMIT 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,k1 PRIMARY 4 NULL 3 Using index condition; Using where; Rowid-ordered scan; Using filesort +1 SIMPLE t1 range|filter PRIMARY,k1 PRIMARY|k1 4|5 NULL 3 (50%) Using index condition; Using where; Rowid-ordered scan; Using filesort; Using rowid filter DROP TABLE t1; # # @@ -429,8 +429,8 @@ SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where -2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL # Using index 2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func # Using index condition +2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL # Using index; Using join buffer (flat, BNL join) SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); pk i @@ -448,9 +448,10 @@ c1 INT NOT NULL, PRIMARY KEY (pk) ); INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +insert into t1 select seq,seq from seq_100_to_110; EXPLAIN SELECT pk, c1 FROM t1 WHERE (pk<3 or pk>3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 5 Using where +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 16 Using where SET SESSION optimizer_switch='index_condition_pushdown=off'; SELECT pk, c1 FROM t1 WHERE (pk<3 or pk>3); pk c1 @@ -458,6 +459,17 @@ pk c1 2 7 4 3 5 1 +100 100 +101 101 +102 102 +103 103 +104 104 +105 105 +106 106 +107 107 +108 108 +109 109 +110 110 DROP TABLE t1; set optimizer_switch= @save_optimizer_switch; # @@ -506,7 +518,7 @@ WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR (t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan -1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR (t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); @@ -675,7 +687,6 @@ DROP TABLE t1; # CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b)); INSERT INTO t1 VALUES (1,4,'Ill'); -insert into t1 select seq+100,5,seq from seq_1_to_100; CREATE TABLE t2 (a varchar(1024), KEY (a(512))); INSERT INTO t2 VALUES ('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w'); @@ -685,8 +696,8 @@ EXPLAIN SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL # Using where; Using filesort -1 SIMPLE t2 ref a a 515 test.t1.a # Using where +1 SIMPLE t1 system PRIMARY NULL NULL NULL # +1 SIMPLE t2 ref a a 515 const # Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; b c @@ -696,8 +707,8 @@ EXPLAIN SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL # Using where; Using filesort -1 SIMPLE t2 ref a a 515 test.t1.a # Using where +1 SIMPLE t1 system PRIMARY NULL NULL NULL # +1 SIMPLE t2 ref a a 515 const # Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; b c @@ -809,6 +820,8 @@ test.t2 analyze status Engine-independent statistics collected test.t2 analyze status Table is already up to date SET @save_optimize_switch=@@optimizer_switch; SET optimizer_switch='materialization=on'; +set @save_optimizer_where_cost=@@optimizer_where_cost; +set @@optimizer_where_cost=1; EXPLAIN SELECT COUNT(*) FROM t1 AS t, t2 WHERE c = g @@ -832,6 +845,7 @@ OR a = 0 AND h < 'z' ); COUNT(*) 1478 SET optimizer_switch=@save_optimizer_switch; +set @@optimizer_where_cost=@save_optimizer_where_cost; DROP TABLE t1,t2; # check "Handler_pushed" status varuiables CREATE TABLE t1 ( diff --git a/mysql-test/main/myisam_mrr.result b/mysql-test/main/myisam_mrr.result index b758b2b3258..6bf72e688bc 100644 --- a/mysql-test/main/myisam_mrr.result +++ b/mysql-test/main/myisam_mrr.result @@ -517,7 +517,7 @@ table3.col_varchar_key = table2.col_varchar_nokey AND table3.pk<>0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE table2 ALL col_varchar_key NULL NULL NULL 40 Using where -1 SIMPLE table3 ref PRIMARY,col_varchar_key col_varchar_key 3 test.table2.col_varchar_key 5 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE table3 ALL PRIMARY,col_varchar_key NULL NULL NULL 40 Using where; Using join buffer (flat, BNL join) set join_cache_level= @save_join_cache_level; set join_buffer_size= @save_join_buffer_size; drop table t1; @@ -572,8 +572,7 @@ Handler_mrr_rowid_refills 0 create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 (a int, b int, filler char(200), key(a)); -insert into t1 -select A.a+10*B.a+100*C.a+1000*D.a, 123,'filler' from t0 A, t0 B, t0 C, t0 D; +insert into t1 select seq, 123, 'filler' from seq_0_to_14999; explain select sum(b) from t1 where a < 10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 5 NULL 9 Using index condition; Rowid-ordered scan diff --git a/mysql-test/main/myisam_mrr.test b/mysql-test/main/myisam_mrr.test index 11c9aa64ef1..601844ab385 100644 --- a/mysql-test/main/myisam_mrr.test +++ b/mysql-test/main/myisam_mrr.test @@ -1,6 +1,8 @@ # # MRR/MyISAM tests. # +--source include/have_sequence.inc + --disable_warnings drop table if exists t0, t1, t2, t3; @@ -278,8 +280,7 @@ show status like 'Handler_mrr%'; create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 (a int, b int, filler char(200), key(a)); -insert into t1 -select A.a+10*B.a+100*C.a+1000*D.a, 123,'filler' from t0 A, t0 B, t0 C, t0 D; +insert into t1 select seq, 123, 'filler' from seq_0_to_14999; explain select sum(b) from t1 where a < 10; --echo # This should show one MRR scan and no re-fills: diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 9a098312eb2..ad1343fa779 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -764,6 +764,10 @@ The following specify which files/extra groups are read (specified before remain key. --optimizer-row-next-find-cost=# Cost of finding the next row when scanning the table. + --optimizer-rowid-compare-cost=# + Cost of comparing two rowid's + --optimizer-rowid-copy-cost=# + Cost of copying a rowid --optimizer-scan-setup-cost=# Extra cost added to TABLE and INDEX scans to get optimizer to prefer index lookups. @@ -1748,6 +1752,8 @@ optimizer-prune-level 2 optimizer-row-copy-cost 6.0866e-05 optimizer-row-lookup-cost 0.000130839 optimizer-row-next-find-cost 4.5916e-05 +optimizer-rowid-compare-cost 2.653e-06 +optimizer-rowid-copy-cost 2.653e-06 optimizer-scan-setup-cost 0.01 optimizer-search-depth 62 optimizer-selectivity-sampling-limit 100 diff --git a/mysql-test/main/named_pipe.result b/mysql-test/main/named_pipe.result index 2baa3471ec9..a0738cdad34 100644 --- a/mysql-test/main/named_pipe.result +++ b/mysql-test/main/named_pipe.result @@ -1,5 +1,6 @@ connect pipe_con,localhost,root,,,,,PIPE; drop table if exists t1,t2,t3,t4; +set @@default_storage_engine="aria"; CREATE TABLE t1 ( Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL @@ -600,6 +601,9 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index +# +# Some test with ORDER BY and limit +# explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort @@ -1289,7 +1293,7 @@ companynr tinyint(2) unsigned zerofill NOT NULL default '00', companyname char(30) NOT NULL default '', PRIMARY KEY (companynr), UNIQUE KEY companyname(companyname) -) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; companynr companyname 00 Unknown @@ -1379,6 +1383,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE delete from t2 where fld1=999999; +# +# Test left join optimization +# explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where @@ -1393,15 +1400,15 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; id select_type table type possible_keys key key_len ref rows Extra @@ -1417,11 +1424,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/negation_elimination.result b/mysql-test/main/negation_elimination.result index 0ad23e547b0..7b9a76d86b2 100644 --- a/mysql-test/main/negation_elimination.result +++ b/mysql-test/main/negation_elimination.result @@ -4,7 +4,7 @@ insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12), (13), (14), (15), (16), (17), (18), (19); explain select * from t1 where not(not(a)); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index select * from t1 where not(not(a)); a 1 @@ -55,7 +55,7 @@ a 10 explain select * from t1 where not(a = 10); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 19 Using where; Using index select * from t1 where not(a = 10); a 0 @@ -500,7 +500,7 @@ NULL NULL 3 1 explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index a a 5 NULL 5 80.00 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 4 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`a` <> 0 AS `not(not(a))`,`test`.`t1`.`a` > 2 or `test`.`t1`.`a` <> 0 AS `not(a <= 2 and not(a))`,`test`.`t1`.`a` like '1' AS `not(a not like "1")`,`test`.`t1`.`a` in (1,2) AS `not (a not in (1,2))`,`test`.`t1`.`a` = 2 AS `not(a != 2)` from `test`.`t1` where `test`.`t1`.`a` <> 0 having `test`.`t1`.`a` <> 0 drop table t1; diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index ea8d6139920..35cae556d92 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -118,8 +118,8 @@ select * from v1 { "table": "t1", "table_scan": { "rows": 2, - "read_cost": 1.002197266, - "read_and_compare_cost": 1.502197266 + "read_cost": 0.01028441, + "read_and_compare_cost": 0.01034841 } } ] @@ -139,18 +139,18 @@ select * from v1 { { "access_type": "scan", "rows": 2, - "rows_after_scan": 1, "rows_after_filter": 1, - "cost": 1.502197266, + "rows_out": 1, + "cost": 0.01034841, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 1, - "records_out": 1, - "cost": 1.502197266, + "rows_read": 1, + "rows_out": 1, + "cost": 0.01034841, "uses_join_buffering": false } } @@ -161,14 +161,14 @@ select * from v1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 1.502197266 + "cost_for_plan": 0.01034841 } ] }, { "best_join_order": ["t1"], "rows": 1, - "cost": 1.502197266 + "cost": 0.01034841 }, { "substitute_best_equal": { @@ -286,8 +286,8 @@ select * from (select * from t1 where t1.a=1)q { "table": "t1", "table_scan": { "rows": 2, - "read_cost": 1.002197266, - "read_and_compare_cost": 1.502197266 + "read_cost": 0.01028441, + "read_and_compare_cost": 0.01034841 } } ] @@ -307,18 +307,18 @@ select * from (select * from t1 where t1.a=1)q { { "access_type": "scan", "rows": 2, - "rows_after_scan": 1, "rows_after_filter": 1, - "cost": 1.502197266, + "rows_out": 1, + "cost": 0.01034841, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 1, - "records_out": 1, - "cost": 1.502197266, + "rows_read": 1, + "rows_out": 1, + "cost": 0.01034841, "uses_join_buffering": false } } @@ -329,14 +329,14 @@ select * from (select * from t1 where t1.a=1)q { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 1.502197266 + "cost_for_plan": 0.01034841 } ] }, { "best_join_order": ["t1"], "rows": 1, - "cost": 1.502197266 + "cost": 0.01034841 }, { "substitute_best_equal": { @@ -459,8 +459,8 @@ select * from v2 { "table": "t1", "table_scan": { "rows": 2, - "read_cost": 1.002197266, - "read_and_compare_cost": 1.502197266 + "read_cost": 0.01028441, + "read_and_compare_cost": 0.01034841 } } ] @@ -480,9 +480,9 @@ select * from v2 { { "access_type": "scan", "rows": 2, - "rows_after_scan": 1, "rows_after_filter": 1, - "cost": 1.502197266, + "rows_out": 1, + "cost": 0.01034841, "index_only": false, "chosen": true, "use_tmp_table": true @@ -490,9 +490,9 @@ select * from v2 { ], "chosen_access_method": { "type": "scan", - "records_read": 1, - "records_out": 1, - "cost": 1.502197266, + "rows_read": 1, + "rows_out": 1, + "cost": 0.01034841, "uses_join_buffering": false } } @@ -503,15 +503,15 @@ select * from v2 { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 1.502197266, - "cost_for_sorting": 1 + "cost_for_plan": 0.01034841, + "cost_for_sorting": 6.301866e-4 } ] }, { "best_join_order": ["t1"], "rows": 1, - "cost": 2.502197266 + "cost": 0.010978597 }, { "substitute_best_equal": { @@ -549,8 +549,8 @@ select * from v2 { "table": "", "table_scan": { "rows": 2, - "read_cost": 2, - "read_and_compare_cost": 2.5 + "read_cost": 0.012350033, + "read_and_compare_cost": 0.012418701 } } ] @@ -570,18 +570,18 @@ select * from v2 { { "access_type": "scan", "rows": 2, - "rows_after_scan": 2, "rows_after_filter": 2, - "cost": 2.5, + "rows_out": 2, + "cost": 0.012418701, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 2, - "records_out": 2, - "cost": 2.5, + "rows_read": 2, + "rows_out": 2, + "cost": 0.012418701, "uses_join_buffering": false } } @@ -592,14 +592,14 @@ select * from v2 { "plan_prefix": [], "table": "", "rows_for_plan": 2, - "cost_for_plan": 2.5 + "cost_for_plan": 0.012418701 } ] }, { "best_join_order": [""], "rows": 2, - "cost": 2.5 + "cost": 0.012418701 }, { "attaching_conditions_to_tables": { @@ -703,8 +703,8 @@ explain select * from v2 { "table": "t2", "table_scan": { "rows": 10, - "read_cost": 1.010986328, - "read_and_compare_cost": 3.510986328 + "read_cost": 0.01127965, + "read_and_compare_cost": 0.01159965 } } ] @@ -724,18 +724,18 @@ explain select * from v2 { { "access_type": "scan", "rows": 10, - "rows_after_scan": 10, "rows_after_filter": 10, - "cost": 3.510986328, + "rows_out": 10, + "cost": 0.01159965, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 10, - "records_out": 10, - "cost": 3.510986328, + "rows_read": 10, + "rows_out": 10, + "cost": 0.01159965, "uses_join_buffering": false } } @@ -746,14 +746,14 @@ explain select * from v2 { "plan_prefix": [], "table": "t2", "rows_for_plan": 10, - "cost_for_plan": 3.510986328 + "cost_for_plan": 0.01159965 } ] }, { "best_join_order": ["t2"], "rows": 10, - "cost": 3.510986328 + "cost": 0.01159965 }, { "attaching_conditions_to_tables": { @@ -836,8 +836,8 @@ explain select * from v1 { "table": "t1", "table_scan": { "rows": 10, - "read_cost": 1.010986328, - "read_and_compare_cost": 3.510986328 + "read_cost": 0.01127965, + "read_and_compare_cost": 0.01159965 } } ] @@ -857,9 +857,9 @@ explain select * from v1 { { "access_type": "scan", "rows": 10, - "rows_after_scan": 10, "rows_after_filter": 10, - "cost": 3.510986328, + "rows_out": 10, + "cost": 0.01159965, "index_only": false, "chosen": true, "use_tmp_table": true @@ -867,9 +867,9 @@ explain select * from v1 { ], "chosen_access_method": { "type": "scan", - "records_read": 10, - "records_out": 10, - "cost": 3.510986328, + "rows_read": 10, + "rows_out": 10, + "cost": 0.01159965, "uses_join_buffering": false } } @@ -880,15 +880,15 @@ explain select * from v1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 10, - "cost_for_plan": 3.510986328, - "cost_for_sorting": 10 + "cost_for_plan": 0.01159965, + "cost_for_sorting": 0.006368384 } ] }, { "best_join_order": ["t1"], "rows": 10, - "cost": 13.51098633 + "cost": 0.017968034 }, { "attaching_conditions_to_tables": { @@ -920,8 +920,8 @@ explain select * from v1 { "table": "", "table_scan": { "rows": 10, - "read_cost": 10, - "read_and_compare_cost": 12.5 + "read_cost": 0.012414166, + "read_and_compare_cost": 0.012757506 } } ] @@ -941,18 +941,18 @@ explain select * from v1 { { "access_type": "scan", "rows": 10, - "rows_after_scan": 10, "rows_after_filter": 10, - "cost": 12.5, + "rows_out": 10, + "cost": 0.012757506, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 10, - "records_out": 10, - "cost": 12.5, + "rows_read": 10, + "rows_out": 10, + "cost": 0.012757506, "uses_join_buffering": false } } @@ -963,14 +963,14 @@ explain select * from v1 { "plan_prefix": [], "table": "", "rows_for_plan": 10, - "cost_for_plan": 12.5 + "cost_for_plan": 0.012757506 } ] }, { "best_join_order": [""], "rows": 10, - "cost": 12.5 + "cost": 0.012757506 }, { "attaching_conditions_to_tables": { @@ -1102,16 +1102,16 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "table": "t1", "table_scan": { "rows": 100, - "read_cost": 1.158691406, - "read_and_compare_cost": 26.15869141 + "read_cost": 0.0224761, + "read_and_compare_cost": 0.0256761 } }, { "table": "t2", "table_scan": { "rows": 100, - "read_cost": 1.158691406, - "read_and_compare_cost": 26.15869141 + "read_cost": 0.0224761, + "read_and_compare_cost": 0.0256761 } } ] @@ -1131,18 +1131,18 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { { "access_type": "scan", "rows": 100, - "rows_after_scan": 100, "rows_after_filter": 100, - "cost": 26.15869141, + "rows_out": 100, + "cost": 0.0256761, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 100, - "records_out": 100, - "cost": 26.15869141, + "rows_read": 100, + "rows_out": 100, + "cost": 0.0256761, "uses_join_buffering": false } } @@ -1157,18 +1157,18 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { { "access_type": "scan", "rows": 100, - "rows_after_scan": 100, "rows_after_filter": 100, - "cost": 26.15869141, + "rows_out": 100, + "cost": 0.0256761, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 100, - "records_out": 100, - "cost": 26.15869141, + "rows_read": 100, + "rows_out": 100, + "cost": 0.0256761, "uses_join_buffering": false } } @@ -1179,7 +1179,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": [], "table": "t1", "rows_for_plan": 100, - "cost_for_plan": 26.15869141, + "cost_for_plan": 0.0256761, "rest_of_plan": [ { "plan_prefix": ["t1"], @@ -1197,24 +1197,24 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "used_range_estimates": false, "reason": "not available", "rows": 1, - "cost": 125.0585794, + "cost": 0.1731074, "chosen": true }, { "access_type": "scan_with_join_cache", "rows": 100, - "rows_after_scan": 75, - "rows_after_filter": 75, - "cost": 1807.408691, + "rows_after_filter": 100, + "rows_out": 1, + "cost": 0.9604227, "index_only": false, "chosen": false } ], "chosen_access_method": { "type": "ref", - "records_read": 1, - "records_out": 1, - "cost": 125.0585794, + "rows_read": 1, + "rows_out": 1, + "cost": 0.1731074, "uses_join_buffering": false } } @@ -1225,7 +1225,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": ["t1"], "table": "t2", "rows_for_plan": 100, - "cost_for_plan": 151.2172709 + "cost_for_plan": 0.1987835 } ] }, @@ -1233,7 +1233,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": [], "table": "t2", "rows_for_plan": 100, - "cost_for_plan": 26.15869141, + "cost_for_plan": 0.0256761, "rest_of_plan": [ { "plan_prefix": ["t2"], @@ -1251,24 +1251,24 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "used_range_estimates": false, "reason": "not available", "rows": 1, - "cost": 125.0585794, + "cost": 0.1731074, "chosen": true }, { "access_type": "scan_with_join_cache", "rows": 100, - "rows_after_scan": 75, - "rows_after_filter": 75, - "cost": 1807.408691, + "rows_after_filter": 100, + "rows_out": 1, + "cost": 0.9604227, "index_only": false, "chosen": false } ], "chosen_access_method": { "type": "ref", - "records_read": 1, - "records_out": 1, - "cost": 125.0585794, + "rows_read": 1, + "rows_out": 1, + "cost": 0.1731074, "uses_join_buffering": false } } @@ -1279,10 +1279,10 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": ["t2"], "table": "t1", "rows_for_plan": 100, - "cost_for_plan": 151.2172709, + "cost_for_plan": 0.1987835, "pruned_by_cost": true, - "current_cost": 151.2172709, - "best_cost": 151.2173709 + "current_cost": 0.1987835, + "best_cost": 0.1987835 } ] } @@ -1291,7 +1291,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { { "best_join_order": ["t1", "t2"], "rows": 100, - "cost": 151.2172709 + "cost": 0.1987835 }, { "substitute_best_equal": { @@ -1330,10 +1330,11 @@ drop table t1,t2,t0; # group_by min max optimization # CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a INT NOT NULL, KEY(a)); +insert into t1 select seq, mod(seq,4)+1 from seq_1_to_65536; analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status OK +test.t1 analyze status Table is already up to date EXPLAIN SELECT DISTINCT a FROM t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL a 4 NULL 5 Using index for group-by @@ -1372,7 +1373,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { "range_analysis": { "table_scan": { "rows": 65536, - "cost": 16457 + "cost": 10.29477568 }, "potential_range_indexes": [ { @@ -1388,7 +1389,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { ], "best_covering_index_scan": { "index": "a", - "cost": 14898.29141, + "cost": 9.123706862, "chosen": true }, "group_index_range": { @@ -1398,7 +1399,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { "index": "a", "covering": true, "rows": 5, - "cost": 6.5 + "cost": 0.004191135 } ] }, @@ -1410,7 +1411,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { "max_aggregate": false, "distinct_aggregate": false, "rows": 5, - "cost": 6.5, + "cost": 0.004191135, "key_parts_used_for_access": ["a"], "ranges": [], "chosen": true @@ -1424,12 +1425,12 @@ EXPLAIN SELECT DISTINCT a FROM t1 { "max_aggregate": false, "distinct_aggregate": false, "rows": 5, - "cost": 6.5, + "cost": 0.004191135, "key_parts_used_for_access": ["a"], "ranges": [] }, "rows_for_plan": 5, - "cost_for_plan": 6.5, + "cost_for_plan": 0.004191135, "chosen": true } } @@ -1451,17 +1452,17 @@ EXPLAIN SELECT DISTINCT a FROM t1 { { "access_type": "index_merge", "rows": 5, - "rows_after_scan": 5, "rows_after_filter": 5, - "cost": 6.5, + "rows_out": 5, + "cost": 0.004191135, "chosen": true } ], "chosen_access_method": { "type": "index_merge", - "records_read": 5, - "records_out": 5, - "cost": 6.5, + "rows_read": 5, + "rows_out": 5, + "cost": 0.004191135, "uses_join_buffering": false } } @@ -1472,14 +1473,14 @@ EXPLAIN SELECT DISTINCT a FROM t1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 5, - "cost_for_plan": 6.5 + "cost_for_plan": 0.004191135 } ] }, { "best_join_order": ["t1"], "rows": 5, - "cost": 6.5 + "cost": 0.004191135 }, { "attaching_conditions_to_tables": { @@ -1515,10 +1516,13 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a; id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL a 20 NULL 7 Using where; Using index for group-by +set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a; +id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 20 NULL 7 Using where; Using index select * from information_schema.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES -EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { +set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "steps": [ { "join_preparation": { @@ -1574,7 +1578,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "range_analysis": { "table_scan": { "rows": 7, - "cost": 2.764526367 + "cost": 0.001130435 }, "potential_range_indexes": [ { @@ -1585,8 +1589,9 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { ], "best_covering_index_scan": { "index": "a", - "cost": 2.084226263, - "chosen": true + "cost": 0.001758432, + "chosen": false, + "cause": "cost" }, "setup_range_conditions": [], "analyzing_range_alternatives": { @@ -1603,7 +1608,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "covering": true, "ranges": ["(2,3) <= (b,c) <= (2,3)"], "rows": 7, - "cost": 2.75 + "cost": 0.004425189 } ] }, @@ -1615,7 +1620,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "max_aggregate": false, "distinct_aggregate": false, "rows": 7, - "cost": 2.75, + "cost": 0.004425189, "key_parts_used_for_access": ["a", "b", "c"], "ranges": ["(2,3) <= (b,c) <= (2,3)"], "chosen": false, @@ -1656,9 +1661,9 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { { "access_type": "scan", "rows": 7, - "rows_after_scan": 1, "rows_after_filter": 1, - "cost": 2.084226263, + "rows_out": 0.571428573, + "cost": 0.001758432, "index_only": true, "chosen": true, "use_tmp_table": true @@ -1666,9 +1671,9 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { ], "chosen_access_method": { "type": "scan", - "records_read": 1, - "records_out": 0.571428573, - "cost": 2.084226263, + "rows_read": 1, + "rows_out": 0.571428573, + "cost": 0.001758432, "uses_join_buffering": false } } @@ -1678,16 +1683,19 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { { "plan_prefix": [], "table": "t1", - "rows_for_plan": 1, - "cost_for_plan": 2.084226263, - "cost_for_sorting": 1 + "rows_for_plan": 0.571428573, + "cost_for_plan": 0.001758432, + "pushdown_cond_selectivity": 0.571428573, + "filtered": 8.163265322, + "rows_out": 0.571428573, + "cost_for_sorting": 3.585611e-4 } ] }, { "best_join_order": ["t1"], - "rows": 1, - "cost": 3.084226263 + "rows": 0.571428573, + "cost": 0.002116993 }, { "substitute_best_equal": { @@ -1711,8 +1719,8 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "clause": "GROUP BY", "table": "t1", "rows_estimation": 1, - "read_cost": 2.147624763, - "filesort_cost": 0.0633985, + "filesort_cost": 4.579083e-5, + "read_cost": 0.001804223, "filesort_type": "priority_queue with addon fields", "fanout": 1, "possible_keys": [ @@ -1722,7 +1730,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { "direction": 1, "rows_to_examine": 7, "range_scan": false, - "scan_cost": 2.084226263, + "scan_cost": 0.001667847, "chosen": true } ] @@ -1811,7 +1819,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { "range_analysis": { "table_scan": { "rows": 16, - "cost": 5.015625 + "cost": 0.01253808 }, "potential_range_indexes": [ { @@ -1822,7 +1830,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { ], "best_covering_index_scan": { "index": "id", - "cost": 4.11171589, + "cost": 0.008002862, "chosen": true }, "setup_range_conditions": [], @@ -1840,7 +1848,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { "covering": true, "ranges": ["(2001-01-04) <= (a)"], "rows": 9, - "cost": 3.25 + "cost": 0.005620843 } ] }, @@ -1852,7 +1860,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { "max_aggregate": true, "distinct_aggregate": false, "rows": 9, - "cost": 3.25, + "cost": 0.005620843, "key_parts_used_for_access": ["id"], "ranges": ["(2001-01-04) <= (a)"], "chosen": true @@ -1866,12 +1874,12 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { "max_aggregate": true, "distinct_aggregate": false, "rows": 9, - "cost": 3.25, + "cost": 0.005620843, "key_parts_used_for_access": ["id"], "ranges": ["(2001-01-04) <= (a)"] }, "rows_for_plan": 9, - "cost_for_plan": 3.25, + "cost_for_plan": 0.005620843, "chosen": true } } @@ -1893,18 +1901,18 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { { "access_type": "index_merge", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25, + "rows_out": 9, + "cost": 0.005620843, "chosen": true, "use_tmp_table": true } ], "chosen_access_method": { "type": "index_merge", - "records_read": 9, - "records_out": 9, - "cost": 3.25, + "rows_read": 9, + "rows_out": 9, + "cost": 0.005620843, "uses_join_buffering": false } } @@ -1915,15 +1923,15 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { "plan_prefix": [], "table": "t1", "rows_for_plan": 9, - "cost_for_plan": 3.25, - "cost_for_sorting": 9 + "cost_for_plan": 0.005620843, + "cost_for_sorting": 0.005728198 } ] }, { "best_join_order": ["t1"], "rows": 9, - "cost": 12.25 + "cost": 0.011349041 }, { "substitute_best_equal": { @@ -2014,7 +2022,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { "range_analysis": { "table_scan": { "rows": 16, - "cost": 5.015625 + "cost": 0.01253808 }, "potential_range_indexes": [ { @@ -2025,7 +2033,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { ], "best_covering_index_scan": { "index": "id", - "cost": 4.11171589, + "cost": 0.008002862, "chosen": true }, "setup_range_conditions": [], @@ -2043,7 +2051,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { "covering": true, "ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"], "rows": 9, - "cost": 3.25 + "cost": 0.005620843 } ] }, @@ -2055,7 +2063,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { "max_aggregate": false, "distinct_aggregate": false, "rows": 9, - "cost": 3.25, + "cost": 0.005620843, "key_parts_used_for_access": ["id", "a"], "ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"], "chosen": true @@ -2069,12 +2077,12 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { "max_aggregate": false, "distinct_aggregate": false, "rows": 9, - "cost": 3.25, + "cost": 0.005620843, "key_parts_used_for_access": ["id", "a"], "ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"] }, "rows_for_plan": 9, - "cost_for_plan": 3.25, + "cost_for_plan": 0.005620843, "chosen": true } } @@ -2096,18 +2104,18 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { { "access_type": "index_merge", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25, + "rows_out": 9, + "cost": 0.005620843, "chosen": true, "use_tmp_table": true } ], "chosen_access_method": { "type": "index_merge", - "records_read": 9, - "records_out": 9, - "cost": 3.25, + "rows_read": 9, + "rows_out": 9, + "cost": 0.005620843, "uses_join_buffering": false } } @@ -2118,15 +2126,15 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { "plan_prefix": [], "table": "t1", "rows_for_plan": 9, - "cost_for_plan": 3.25, - "cost_for_sorting": 9 + "cost_for_plan": 0.005620843, + "cost_for_sorting": 0.005728198 } ] }, { "best_join_order": ["t1"], "rows": 9, - "cost": 12.25 + "cost": 0.011349041 }, { "substitute_best_equal": { @@ -2160,10 +2168,6 @@ drop table t1; # # Late ORDER BY optimization # -create table ten(a int); -insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table one_k(a int primary key); -insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C; create table t1 ( pk int not null, a int, @@ -2174,19 +2178,18 @@ KEY c(c), KEY a_c(a,c), KEY a_b(a,b) ); -insert into t1 -select a, a,a,a, 'filler-dataaa' from test.one_k; +insert into t1 select seq, seq,seq,seq, 'filler-dataaa' from seq_0_to_999; update t1 set a=1 where pk between 0 and 180; update t1 set b=2 where pk between 0 and 20; analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK -set optimizer_trace='enabled=on'; explain select * from t1 where a=1 and b=2 order by c limit 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref a_c,a_b a_b 10 const,const 21 Using where; Using filesort update t1 set b=2 where pk between 20 and 40; +set optimizer_trace='enabled=on'; explain select * from t1 where a=1 and b=2 order by c limit 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a_c,a_b a_c 5 NULL 180 Using where @@ -2270,7 +2273,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "range_analysis": { "table_scan": { "rows": 1000, - "cost": 265.2822266 + "cost": 0.1731718 }, "potential_range_indexes": [ { @@ -2299,8 +2302,9 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "using_mrr": false, "index_only": false, "rows": 180, - "cost": 135.6693776, - "chosen": true + "cost": 0.223346519, + "chosen": false, + "cause": "cost" }, { "index": "a_b", @@ -2309,7 +2313,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "using_mrr": false, "index_only": false, "rows": 41, - "cost": 31.3040249, + "cost": 0.051838728, "chosen": true } ], @@ -2330,7 +2334,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "ranges": ["(1,2) <= (a,b) <= (1,2)"] }, "rows_for_plan": 41, - "cost_for_plan": 31.3040249, + "cost_for_plan": 0.051838728, "chosen": true } } @@ -2340,12 +2344,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "rowid_filters": [ { "key": "a_b", - "build_cost": 1.752281351, + "build_cost": 6.9153e-4, "rows": 41 }, { "key": "a_c", - "build_cost": 6.264109827, + "build_cost": 0.0040552, "rows": 180 } ] @@ -2390,7 +2394,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "index": "a_c", "used_range_estimates": true, "rows": 180, - "cost": 135.6493776, + "cost": 0.222796377, "chosen": true }, { @@ -2398,7 +2402,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "index": "a_b", "used_range_estimates": true, "rows": 41, - "cost": 31.2840249, + "cost": 0.051288586, "chosen": true }, { @@ -2409,9 +2413,9 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { ], "chosen_access_method": { "type": "ref", - "records_read": 41, - "records_out": 41, - "cost": 31.2840249, + "rows_read": 41, + "rows_out": 41, + "cost": 0.051288586, "uses_join_buffering": false } } @@ -2422,14 +2426,14 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 41, - "cost_for_plan": 31.2840249 + "cost_for_plan": 0.051288586 } ] }, { "best_join_order": ["t1"], "rows": 41, - "cost": 31.2840249 + "cost": 0.051288586 }, { "substitute_best_equal": { @@ -2453,8 +2457,8 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "clause": "ORDER BY", "table": "t1", "rows_estimation": 41, - "read_cost": 32.58369415, - "filesort_cost": 1.299669251, + "filesort_cost": 9.387121e-4, + "read_cost": 0.052227298, "filesort_type": "priority_queue with addon fields", "fanout": 1, "possible_keys": [ @@ -2464,7 +2468,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "direction": 1, "rows_to_examine": 24, "range_scan": false, - "scan_cost": 18.51405907, + "scan_cost": 0.030312813, "chosen": true }, { @@ -2473,7 +2477,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "direction": 1, "rows_to_examine": 4.390243902, "range_scan": true, - "scan_cost": 11.5484164, + "scan_cost": 0.023380552, "chosen": true }, { @@ -2487,10 +2491,6 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { { "table": "t1", "range_analysis": { - "table_scan": { - "rows": 1000, - "cost": 1.79769e308 - }, "potential_range_indexes": [ { "index": "c", @@ -2518,7 +2518,8 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "using_mrr": false, "index_only": false, "rows": 180, - "cost": 135.6693776, + "cost": 0.223346519, + "cost_with_limit": 0.002483968, "chosen": true } ], @@ -2539,7 +2540,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "ranges": ["(1) <= (a) <= (1)"] }, "rows_for_plan": 180, - "cost_for_plan": 135.6693776, + "cost_for_plan": 0.223346519, "chosen": true } } @@ -2555,7 +2556,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { } ] } 0 0 -drop table t1,ten,one_k; +drop table t1; # # TABLE ELIMINATION # @@ -2646,8 +2647,8 @@ select t1.a from t1 left join t2 on t1.a=t2.a { "table": "t1", "table_scan": { "rows": 4, - "read_cost": 1.003417969, - "read_and_compare_cost": 2.003417969 + "read_cost": 0.01053322, + "read_and_compare_cost": 0.01066122 } }, { @@ -2673,18 +2674,18 @@ select t1.a from t1 left join t2 on t1.a=t2.a { { "access_type": "scan", "rows": 4, - "rows_after_scan": 4, "rows_after_filter": 4, - "cost": 2.003417969, + "rows_out": 4, + "cost": 0.01066122, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 4, - "records_out": 4, - "cost": 2.003417969, + "rows_read": 4, + "rows_out": 4, + "cost": 0.01066122, "uses_join_buffering": false } } @@ -2695,14 +2696,14 @@ select t1.a from t1 left join t2 on t1.a=t2.a { "plan_prefix": ["t2"], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.003417969 + "cost_for_plan": 0.01066122 } ] }, { "best_join_order": ["t2", "t1"], "rows": 4, - "cost": 2.003417969 + "cost": 0.01066122 }, { "substitute_best_equal": { @@ -2802,16 +2803,16 @@ explain select * from t1 left join t2 on t2.a=t1.a { "table": "t1", "table_scan": { "rows": 4, - "read_cost": 1.003417969, - "read_and_compare_cost": 2.003417969 + "read_cost": 0.01053322, + "read_and_compare_cost": 0.01066122 } }, { "table": "t2", "table_scan": { "rows": 2, - "read_cost": 1.002197266, - "read_and_compare_cost": 1.502197266 + "read_cost": 0.01028441, + "read_and_compare_cost": 0.01034841 } } ] @@ -2831,18 +2832,18 @@ explain select * from t1 left join t2 on t2.a=t1.a { { "access_type": "scan", "rows": 4, - "rows_after_scan": 4, "rows_after_filter": 4, - "cost": 2.003417969, + "rows_out": 4, + "cost": 0.01066122, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 4, - "records_out": 4, - "cost": 2.003417969, + "rows_read": 4, + "rows_out": 4, + "cost": 0.01066122, "uses_join_buffering": false } } @@ -2853,7 +2854,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { "plan_prefix": [], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.003417969, + "cost_for_plan": 0.01066122, "rest_of_plan": [ { "plan_prefix": ["t1"], @@ -2869,24 +2870,20 @@ explain select * from t1 left join t2 on t2.a=t1.a { "access_type": "eq_ref", "index": "PRIMARY", "rows": 1, - "cost": 5.002147913, + "cost": 0.007120904, "chosen": true }, { - "access_type": "scan", - "rows": 2, - "rows_after_scan": 1.5, - "rows_after_filter": 1.5, - "cost": 6.008789062, - "index_only": false, - "chosen": false + "type": "scan", + "chosen": false, + "cause": "cost" } ], "chosen_access_method": { "type": "eq_ref", - "records_read": 1, - "records_out": 1, - "cost": 5.002147913, + "rows_read": 1, + "rows_out": 1, + "cost": 0.007120904, "uses_join_buffering": false } } @@ -2897,7 +2894,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { "plan_prefix": ["t1"], "table": "t2", "rows_for_plan": 4, - "cost_for_plan": 7.005565882 + "cost_for_plan": 0.017782124 } ] } @@ -2906,7 +2903,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { { "best_join_order": ["t1", "t2"], "rows": 4, - "cost": 7.005565882 + "cost": 0.017782124 }, { "substitute_best_equal": { @@ -3043,8 +3040,8 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and "table": "t1", "table_scan": { "rows": 4, - "read_cost": 1.003417969, - "read_and_compare_cost": 2.003417969 + "read_cost": 0.01053322, + "read_and_compare_cost": 0.01066122 } }, { @@ -3076,18 +3073,18 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and { "access_type": "scan", "rows": 4, - "rows_after_scan": 4, "rows_after_filter": 4, - "cost": 2.003417969, + "rows_out": 4, + "cost": 0.01066122, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 4, - "records_out": 4, - "cost": 2.003417969, + "rows_read": 4, + "rows_out": 4, + "cost": 0.01066122, "uses_join_buffering": false } } @@ -3098,14 +3095,14 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and "plan_prefix": ["t3", "t2"], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.003417969 + "cost_for_plan": 0.01066122 } ] }, { "best_join_order": ["t3", "t2", "t1"], "rows": 4, - "cost": 2.003417969 + "cost": 0.01066122 }, { "substitute_best_equal": { @@ -3143,33 +3140,27 @@ drop table t0, t1, t2, t3; # # IN subquery to sem-join is traced # -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1(a int, b int); -insert into t1 values (0,0),(1,1),(2,2); -create table t2 as select * from t1; -create table t11(a int, b int); -create table t10 (pk int, a int); -insert into t10 select a,a from t0; -create table t12 like t10; -insert into t12 select * from t10; -analyze table t1,t10; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status OK -test.t10 analyze status Engine-independent statistics collected -test.t10 analyze status OK +insert into t1 select seq,seq from seq_0_to_3; +create table t2 (p int, a int); +insert into t2 select seq,seq from seq_1_to_10; set optimizer_trace='enabled=on'; -explain extended select * from t1 where a in (select pk from t10); +explain extended select * from t1 where a in (select p from t2); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t10 ALL NULL NULL NULL NULL 10 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 10 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t10`) where 1 +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`p` = `test`.`t1`.`a` +insert into t2 select seq,seq from seq_10_to_100; +explain extended select * from t1 where a in (select p from t2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`p` = `test`.`t1`.`a` select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES -explain extended select * from t1 where a in (select pk from t10) { +explain extended select * from t1 where a in (select p from t2) { "steps": [ { "join_preparation": { @@ -3188,13 +3179,13 @@ explain extended select * from t1 where a in (select pk from t10) { } }, { - "expanded_query": "/* select#2 */ select t10.pk from t10" + "expanded_query": "/* select#2 */ select t2.p from t2" } ] } }, { - "expanded_query": "/* select#1 */ select t1.a AS a,t1.b AS b from t1 where t1.a in (/* select#2 */ select t10.pk from t10)" + "expanded_query": "/* select#1 */ select t1.a AS a,t1.b AS b from t1 where t1.a in (/* select#2 */ select t2.p from t2)" } ] } @@ -3223,19 +3214,19 @@ explain extended select * from t1 where a in (select pk from t10) { { "condition_processing": { "condition": "WHERE", - "original_condition": "1 and t1.a = t10.pk", + "original_condition": "1 and t1.a = t2.p", "steps": [ { "transformation": "equality_propagation", - "resulting_condition": "1 and multiple equal(t1.a, t10.pk)" + "resulting_condition": "1 and multiple equal(t1.a, t2.p)" }, { "transformation": "constant_propagation", - "resulting_condition": "1 and multiple equal(t1.a, t10.pk)" + "resulting_condition": "1 and multiple equal(t1.a, t2.p)" }, { "transformation": "trivial_condition_removal", - "resulting_condition": "multiple equal(t1.a, t10.pk)" + "resulting_condition": "multiple equal(t1.a, t2.p)" } ] } @@ -3249,7 +3240,7 @@ explain extended select * from t1 where a in (select pk from t10) { "depends_on_map_bits": [] }, { - "table": "t10", + "table": "t2", "row_may_be_null": false, "map_bit": 1, "depends_on_map_bits": [] @@ -3264,17 +3255,17 @@ explain extended select * from t1 where a in (select pk from t10) { { "table": "t1", "table_scan": { - "rows": 3, - "read_cost": 1.003295898, - "read_and_compare_cost": 1.753295898 + "rows": 4, + "read_cost": 0.01053322, + "read_and_compare_cost": 0.01066122 } }, { - "table": "t10", + "table": "t2", "table_scan": { - "rows": 10, - "read_cost": 1.010986328, - "read_and_compare_cost": 3.510986328 + "rows": 101, + "read_cost": 0.022600505, + "read_and_compare_cost": 0.025832505 } } ] @@ -3294,26 +3285,26 @@ explain extended select * from t1 where a in (select pk from t10) { "get_costs_for_tables": [ { "best_access_path": { - "table": "t10", + "table": "t2", "plan_details": { "record_count": 1 }, "considered_access_paths": [ { "access_type": "scan", - "rows": 10, - "rows_after_scan": 10, - "rows_after_filter": 10, - "cost": 3.510986328, + "rows": 101, + "rows_after_filter": 101, + "rows_out": 101, + "cost": 0.025832505, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 10, - "records_out": 10, - "cost": 3.510986328, + "rows_read": 101, + "rows_out": 101, + "cost": 0.025832505, "uses_join_buffering": false } } @@ -3322,9 +3313,9 @@ explain extended select * from t1 where a in (select pk from t10) { }, { "plan_prefix": [], - "table": "t10", - "rows_for_plan": 10, - "cost_for_plan": 3.510986328 + "table": "t2", + "rows_for_plan": 101, + "cost_for_plan": 0.025832505 } ] } @@ -3345,45 +3336,45 @@ explain extended select * from t1 where a in (select pk from t10) { "considered_access_paths": [ { "access_type": "scan", - "rows": 3, - "rows_after_scan": 3, - "rows_after_filter": 3, - "cost": 1.753295898, + "rows": 4, + "rows_after_filter": 4, + "rows_out": 4, + "cost": 0.01066122, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.753295898, + "rows_read": 4, + "rows_out": 4, + "cost": 0.01066122, "uses_join_buffering": false } } }, { "best_access_path": { - "table": "t10", + "table": "t2", "plan_details": { "record_count": 1 }, "considered_access_paths": [ { "access_type": "scan", - "rows": 10, - "rows_after_scan": 10, - "rows_after_filter": 10, - "cost": 3.510986328, + "rows": 101, + "rows_after_filter": 101, + "rows_out": 101, + "cost": 0.025832505, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 10, - "records_out": 10, - "cost": 3.510986328, + "rows_read": 101, + "rows_out": 101, + "cost": 0.025832505, "uses_join_buffering": false } } @@ -3393,8 +3384,8 @@ explain extended select * from t1 where a in (select pk from t10) { { "plan_prefix": [], "table": "t1", - "rows_for_plan": 3, - "cost_for_plan": 1.753295898, + "rows_for_plan": 4, + "cost_for_plan": 0.01066122, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -3402,26 +3393,26 @@ explain extended select * from t1 where a in (select pk from t10) { "get_costs_for_tables": [ { "best_access_path": { - "table": "t10", + "table": "t2", "plan_details": { - "record_count": 3 + "record_count": 4 }, "considered_access_paths": [ { "access_type": "scan_with_join_cache", - "rows": 10, - "rows_after_scan": 10, - "rows_after_filter": 10, - "cost": 10.63598633, + "rows": 101, + "rows_after_filter": 101, + "rows_out": 101, + "cost": 0.063593833, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 10, - "records_out": 10, - "cost": 10.63598633, + "rows_read": 101, + "rows_out": 101, + "cost": 0.063593833, "uses_join_buffering": true } } @@ -3430,40 +3421,46 @@ explain extended select * from t1 where a in (select pk from t10) { }, { "plan_prefix": ["t1"], - "table": "t10", - "rows_for_plan": 30, - "cost_for_plan": 12.38928223, + "table": "t2", + "rows_for_plan": 404, + "cost_for_plan": 0.074255053, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 3, - "cost": 12.38928223 + "rows": 4, + "cost": 0.074255053 }, { "strategy": "SJ-Materialization", - "records": 3, - "cost": 8.664282227 + "rows": 4, + "cost": 0.078768645 }, { "strategy": "DuplicateWeedout", - "records": 3, - "dups_cost": 12.38928223, - "write_cost": 2.5, - "full_lookup_cost": 15, - "total_cost": 29.88928223 + "prefix_row_count": 4, + "tmp_table_rows": 1, + "sj_inner_fanout": 101, + "rows": 4, + "dups_cost": 0.074255053, + "write_cost": 0.02564388, + "full_lookup_cost": 0.06503188, + "total_cost": 0.164930813 }, { - "chosen_strategy": "SJ-Materialization" + "chosen_strategy": "FirstMatch" } - ] + ], + "sj_rows_out": 1, + "sj_rows_for_plan": 4, + "sj_filtered": 0.99009901 } ] }, { "plan_prefix": [], - "table": "t10", - "rows_for_plan": 10, - "cost_for_plan": 3.510986328, + "table": "t2", + "rows_for_plan": 101, + "cost_for_plan": 0.025832505, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -3472,30 +3469,50 @@ explain extended select * from t1 where a in (select pk from t10) { { "fix_semijoin_strategies_for_picked_join_order": [ { - "semi_join_strategy": "SJ-Materialization", + "semi_join_strategy": "FirstMatch", "join_order": [ { - "table": "t10" + "table": "t2", + "best_access_path": { + "table": "t2", + "plan_details": { + "record_count": 4 + }, + "considered_access_paths": [ + { + "access_type": "scan", + "rows": 101, + "rows_after_filter": 101, + "rows_out": 101, + "cost": 0.10333002, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 101, + "rows_out": 101, + "cost": 0.10333002, + "uses_join_buffering": false + } + } } ] } ] }, { - "best_join_order": ["t1", ""], - "rows": 3, - "cost": 8.664282227 + "best_join_order": ["t1", "t2"], + "rows": 4, + "cost": 0.074255053 }, { "substitute_best_equal": { "condition": "WHERE", - "resulting_condition": "1" + "resulting_condition": "t2.p = t1.a" } }, - { - "condition_on_constant_tables": "1", - "computing_condition": [] - }, { "attaching_conditions_to_tables": { "attached_conditions_computation": [], @@ -3505,12 +3522,8 @@ explain extended select * from t1 where a in (select pk from t10) { "attached": null }, { - "table": "t10", - "attached": null - }, - { - "table": "", - "attached": null + "table": "t2", + "attached": "t2.p = t1.a" } ] } @@ -3526,12 +3539,10 @@ explain extended select * from t1 where a in (select pk from t10) { } ] } 0 0 -drop table t0,t1,t11,t10,t12,t2; +drop table t1,t2; # # Selectivities for columns and indexes. # -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 ( pk int, a int, @@ -3539,7 +3550,7 @@ b int, key pk(pk), key pk_a(pk,a), key pk_a_b(pk,a,b)); -insert into t1 select a,a,a from t0; +insert into t1 select seq,seq,seq from seq_0_to_9; ANALYZE TABLE t1 PERSISTENT FOR COLUMNS (a,b) INDEXES (); Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected @@ -3653,7 +3664,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "range_analysis": { "table_scan": { "rows": 10, - "cost": 3.515869141 + "cost": 0.01159965 }, "potential_range_indexes": [ { @@ -3674,7 +3685,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { ], "best_covering_index_scan": { "index": "pk_a_b", - "cost": 2.760739566, + "cost": 0.007173242, "chosen": true }, "setup_range_conditions": [], @@ -3687,7 +3698,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.270585794, + "cost": 0.002483968, "chosen": true }, { @@ -3697,7 +3708,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.270829876, + "cost": 0.002483968, "chosen": false, "cause": "cost" }, @@ -3708,7 +3719,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.746073957, + "cost": 0.001388369, "chosen": true } ], @@ -3716,10 +3727,10 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "intersecting_indexes": [ { "index": "pk", - "index_scan_cost": 0.525585794, - "cumulated_index_scan_cost": 0.525585794, - "disk_sweep_cost": 0.75, - "cumulative_total_cost": 1.275585794, + "index_scan_cost": 0.000806227, + "cumulated_index_scan_cost": 0.000806227, + "disk_sweep_cost": 0.001143284, + "cumulative_total_cost": 0.001949511, "usable": true, "matching_rows_now": 1, "intersect_covering_with_this_index": false, @@ -3757,7 +3768,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "ranges": ["(2,5,1) <= (pk,a,b) <= (2,5,1)"] }, "rows_for_plan": 1, - "cost_for_plan": 0.746073957, + "cost_for_plan": 0.001388369, "chosen": true } } @@ -3767,17 +3778,17 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "rowid_filters": [ { "key": "pk", - "build_cost": 0.526585794, + "build_cost": 0.000002653, "rows": 1 }, { "key": "pk_a", - "build_cost": 0.526829876, + "build_cost": 0.000002653, "rows": 1 }, { "key": "pk_a_b", - "build_cost": 0.527073957, + "build_cost": 0.000002653, "rows": 1 } ] @@ -3822,7 +3833,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk", "used_range_estimates": true, "rows": 1, - "cost": 1.250585794, + "cost": 0.001933826, "chosen": true }, { @@ -3830,7 +3841,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk_a", "used_range_estimates": true, "rows": 1, - "cost": 1.250829876, + "cost": 0.001933826, "chosen": false, "cause": "cost" }, @@ -3839,7 +3850,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk_a_b", "used_range_estimates": true, "rows": 1, - "cost": 0.726073957, + "cost": 0.000838227, "chosen": true }, { @@ -3850,9 +3861,9 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { ], "chosen_access_method": { "type": "ref", - "records_read": 1, - "records_out": 1, - "cost": 0.726073957, + "rows_read": 1, + "rows_out": 1, + "cost": 0.000838227, "uses_join_buffering": false } } @@ -3863,14 +3874,14 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 0.726073957 + "cost_for_plan": 0.000838227 } ] }, { "best_join_order": ["t1"], "rows": 1, - "cost": 0.726073957 + "cost": 0.000838227 }, { "substitute_best_equal": { @@ -3902,7 +3913,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { } 0 0 set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set @@use_stat_tables= @save_use_stat_tables; -drop table t0,t1; +drop table t1; set optimizer_trace="enabled=off"; # # Tests added to show that sub-statements are not traced @@ -3966,8 +3977,8 @@ select f1(a) from t1 { "table": "t1", "table_scan": { "rows": 4, - "read_cost": 1.003417969, - "read_and_compare_cost": 2.003417969 + "read_cost": 0.01053322, + "read_and_compare_cost": 0.01066122 } } ] @@ -3987,18 +3998,18 @@ select f1(a) from t1 { { "access_type": "scan", "rows": 4, - "rows_after_scan": 4, "rows_after_filter": 4, - "cost": 2.003417969, + "rows_out": 4, + "cost": 0.01066122, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 4, - "records_out": 4, - "cost": 2.003417969, + "rows_read": 4, + "rows_out": 4, + "cost": 0.01066122, "uses_join_buffering": false } } @@ -4009,14 +4020,14 @@ select f1(a) from t1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.003417969 + "cost_for_plan": 0.01066122 } ] }, { "best_join_order": ["t1"], "rows": 4, - "cost": 2.003417969 + "cost": 0.01066122 }, { "attaching_conditions_to_tables": { @@ -4080,8 +4091,8 @@ select f2(a) from t1 { "table": "t1", "table_scan": { "rows": 4, - "read_cost": 1.003417969, - "read_and_compare_cost": 2.003417969 + "read_cost": 0.01053322, + "read_and_compare_cost": 0.01066122 } } ] @@ -4101,18 +4112,18 @@ select f2(a) from t1 { { "access_type": "scan", "rows": 4, - "rows_after_scan": 4, "rows_after_filter": 4, - "cost": 2.003417969, + "rows_out": 4, + "cost": 0.01066122, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 4, - "records_out": 4, - "cost": 2.003417969, + "rows_read": 4, + "rows_out": 4, + "cost": 0.01066122, "uses_join_buffering": false } } @@ -4123,14 +4134,14 @@ select f2(a) from t1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 4, - "cost_for_plan": 2.003417969 + "cost_for_plan": 0.01066122 } ] }, { "best_join_order": ["t1"], "rows": 4, - "cost": 2.003417969 + "cost": 0.01066122 }, { "attaching_conditions_to_tables": { @@ -4171,7 +4182,7 @@ a 2 select length(trace) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; length(trace) -2766 +2747 set optimizer_trace_max_mem_size=100; select * from t1; a @@ -4185,7 +4196,7 @@ select * from t1 { "join_preparation": { "select_id": 1, "steps": [ - 2666 0 + 2647 0 set optimizer_trace_max_mem_size=0; select * from t1; a @@ -4193,7 +4204,7 @@ a 2 select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES -select * from t1 2766 0 +select * from t1 2747 0 drop table t1; set optimizer_trace='enabled=off'; set @@optimizer_trace_max_mem_size= @save_optimizer_trace_max_mem_size; @@ -4218,7 +4229,7 @@ explain delete from t0 where t0.a<3 { "range_analysis": { "table_scan": { "rows": 10, - "cost": 3.510986328 + "cost": 0.01159965 }, "potential_range_indexes": [ { @@ -4237,7 +4248,7 @@ explain delete from t0 where t0.a<3 { "using_mrr": false, "index_only": false, "rows": 3, - "cost": 2.771757383, + "cost": 0.004951706, "chosen": true } ], @@ -4255,7 +4266,7 @@ explain delete from t0 where t0.a<3 { "ranges": ["(NULL) < (a) < (3)"] }, "rows_for_plan": 3, - "cost_for_plan": 2.771757383, + "cost_for_plan": 0.004951706, "chosen": true } } @@ -4358,7 +4369,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "range_analysis": { "table_scan": { "rows": 10, - "cost": 3.510986328 + "cost": 0.01159965 }, "potential_range_indexes": [ { @@ -4369,7 +4380,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ], "best_covering_index_scan": { "index": "a", - "cost": 2.755857945, + "cost": 0.007173242, "chosen": true }, "setup_range_conditions": [], @@ -4382,7 +4393,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "using_mrr": false, "index_only": true, "rows": 3, - "cost": 1.196757383, + "cost": 0.001664909, "chosen": true } ], @@ -4403,7 +4414,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "ranges": ["(NULL) < (a) < (3)"] }, "rows_for_plan": 3, - "cost_for_plan": 1.196757383, + "cost_for_plan": 0.001664909, "chosen": true } } @@ -4423,7 +4434,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "range_analysis": { "table_scan": { "rows": 10, - "cost": 3.510986328 + "cost": 0.01159965 }, "potential_range_indexes": [ { @@ -4434,7 +4445,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ], "best_covering_index_scan": { "index": "a", - "cost": 2.755857945, + "cost": 0.007173242, "chosen": true }, "setup_range_conditions": [], @@ -4447,7 +4458,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "using_mrr": false, "index_only": true, "rows": 3, - "cost": 1.196757383, + "cost": 0.001664909, "chosen": true } ], @@ -4468,7 +4479,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "ranges": ["(NULL) < (a) < (3)"] }, "rows_for_plan": 3, - "cost_for_plan": 1.196757383, + "cost_for_plan": 0.001664909, "chosen": true } } @@ -4499,18 +4510,19 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "considered_access_paths": [ { "access_type": "range", + "range_index": "a", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.196757383, + "rows_out": 3, + "cost": 0.001664909, "chosen": true } ], "chosen_access_method": { "type": "range", - "records_read": 3, - "records_out": 3, - "cost": 1.196757383, + "rows_read": 3, + "rows_out": 3, + "cost": 0.001664909, "uses_join_buffering": false } } @@ -4524,18 +4536,19 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "considered_access_paths": [ { "access_type": "range", + "range_index": "a", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.196757383, + "rows_out": 3, + "cost": 0.001664909, "chosen": true } ], "chosen_access_method": { "type": "range", - "records_read": 3, - "records_out": 3, - "cost": 1.196757383, + "rows_read": 3, + "rows_out": 3, + "cost": 0.001664909, "uses_join_buffering": false } } @@ -4546,7 +4559,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "plan_prefix": [], "table": "t0", "rows_for_plan": 3, - "cost_for_plan": 1.196757383, + "cost_for_plan": 0.001664909, "rest_of_plan": [ { "plan_prefix": ["t0"], @@ -4564,7 +4577,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "used_range_estimates": false, "reason": "not better than ref estimates", "rows": 1, - "cost": 2.176757383, + "cost": 0.002105081, "chosen": true }, { @@ -4575,9 +4588,9 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ], "chosen_access_method": { "type": "ref", - "records_read": 1, - "records_out": 1, - "cost": 2.176757383, + "rows_read": 1, + "rows_out": 1, + "cost": 0.002105081, "uses_join_buffering": false } } @@ -4588,7 +4601,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "plan_prefix": ["t0"], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 3.373514767 + "cost_for_plan": 0.00376999 } ] }, @@ -4596,7 +4609,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 1.196757383, + "cost_for_plan": 0.001664909, "rest_of_plan": [ { "plan_prefix": ["t1"], @@ -4615,7 +4628,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "used_range_estimates": false, "reason": "not better than ref estimates", "rows": 2, - "cost": 2.853514767, + "cost": 0.002519891, "chosen": true }, { @@ -4626,9 +4639,9 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ], "chosen_access_method": { "type": "ref", - "records_read": 2, - "records_out": 1.166666667, - "cost": 2.853514767, + "rows_read": 2, + "rows_out": 2, + "cost": 0.002519891, "uses_join_buffering": false } } @@ -4639,10 +4652,10 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "plan_prefix": ["t1"], "table": "t0", "rows_for_plan": 6, - "cost_for_plan": 4.05027215, + "cost_for_plan": 0.0041848, "pruned_by_cost": true, - "current_cost": 4.05027215, - "best_cost": 3.373614767 + "current_cost": 0.0041848, + "best_cost": 0.00376999 } ] } @@ -4651,7 +4664,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { { "best_join_order": ["t0", "t1"], "rows": 3, - "cost": 3.373514767 + "cost": 0.00376999 }, { "substitute_best_equal": { @@ -4760,8 +4773,8 @@ explain select * from (select rand() from t1)q { "table": "t1", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } } ] @@ -4781,18 +4794,18 @@ explain select * from (select rand() from t1)q { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -4803,14 +4816,14 @@ explain select * from (select rand() from t1)q { "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 1.752563477 + "cost_for_plan": 0.010504815 } ] }, { "best_join_order": ["t1"], "rows": 3, - "cost": 1.752563477 + "cost": 0.010504815 }, { "attaching_conditions_to_tables": { @@ -4842,8 +4855,8 @@ explain select * from (select rand() from t1)q { "table": "", "table_scan": { "rows": 3, - "read_cost": 3, - "read_and_compare_cost": 3.75 + "read_cost": 0.01235805, + "read_and_compare_cost": 0.012461052 } } ] @@ -4863,18 +4876,18 @@ explain select * from (select rand() from t1)q { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 3.75, + "rows_out": 3, + "cost": 0.012461052, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 3.75, + "rows_read": 3, + "rows_out": 3, + "cost": 0.012461052, "uses_join_buffering": false } } @@ -4885,14 +4898,14 @@ explain select * from (select rand() from t1)q { "plan_prefix": [], "table": "", "rows_for_plan": 3, - "cost_for_plan": 3.75 + "cost_for_plan": 0.012461052 } ] }, { "best_join_order": [""], "rows": 3, - "cost": 3.75 + "cost": 0.012461052 }, { "attaching_conditions_to_tables": { @@ -5044,24 +5057,24 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "table": "t1", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } }, { "table": "t_inner_1", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } }, { "table": "t_inner_2", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } } ] @@ -5089,18 +5102,18 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -5115,18 +5128,18 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -5137,7 +5150,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "rest_of_plan": [ { "plan_prefix": ["t_inner_1"], @@ -5152,18 +5165,18 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 3.890063477, + "rows_out": 3, + "cost": 0.011523207, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 3.890063477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.011523207, "uses_join_buffering": true } } @@ -5174,7 +5187,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": ["t_inner_1"], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 5.642626953 + "cost_for_plan": 0.022028022 } ] }, @@ -5182,7 +5195,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "pruned_by_heuristic": true } ] @@ -5205,18 +5218,18 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -5231,18 +5244,18 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -5257,18 +5270,18 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -5279,7 +5292,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5295,18 +5308,18 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 3.890063477, + "rows_out": 3, + "cost": 0.011523207, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 3.890063477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.011523207, "uses_join_buffering": true } } @@ -5321,18 +5334,18 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 3.890063477, + "rows_out": 3, + "cost": 0.011523207, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 3.890063477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.011523207, "uses_join_buffering": true } } @@ -5343,7 +5356,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": ["t1"], "table": "t_inner_1", "rows_for_plan": 9, - "cost_for_plan": 5.642626953, + "cost_for_plan": 0.022028022, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5359,18 +5372,18 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 9.177563477, + "rows_out": 3, + "cost": 0.015203373, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 9.177563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.015203373, "uses_join_buffering": true } } @@ -5381,30 +5394,36 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": ["t1", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 27, - "cost_for_plan": 14.82019043, + "cost_for_plan": 0.037231395, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 3, - "cost": 22.7833252 + "rows": 3, + "cost": 0.136562595 }, { "strategy": "SJ-Materialization", - "records": 3, - "cost": 10.64519043 + "rows": 3, + "cost": 0.059588485 }, { "strategy": "DuplicateWeedout", - "records": 3, - "dups_cost": 14.82019043, - "write_cost": 1.45, - "full_lookup_cost": 4.05, - "total_cost": 20.32019043 + "prefix_row_count": 3, + "tmp_table_rows": 1, + "sj_inner_fanout": 9, + "rows": 3, + "dups_cost": 0.037231395, + "write_cost": 0.02548291, + "full_lookup_cost": 0.00434619, + "total_cost": 0.067060495 }, { "chosen_strategy": "SJ-Materialization" } - ] + ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 3, + "sj_filtered": 11.11111111 } ] }, @@ -5412,7 +5431,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": ["t1"], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 5.642626953, + "cost_for_plan": 0.022028022, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -5422,7 +5441,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -5430,7 +5449,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -5454,7 +5473,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "best_join_order": ["t1", ""], "rows": 3, - "cost": 10.64519043 + "cost": 0.059588485 }, { "substitute_best_equal": { @@ -5506,11 +5525,11 @@ explain select * from t1 t_outer_1,t2 t_outer_2 where t_outer_1.a in (select t_ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t_outer_1 ALL NULL NULL NULL NULL 3 -1 PRIMARY t_inner_1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t_inner_2 ALL NULL NULL NULL NULL 9 FirstMatch(t_outer_1); Using join buffer (incremental, BNL join) +1 PRIMARY t_inner_1 ALL NULL NULL NULL NULL 3 Using where; Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY t_inner_2 ALL NULL NULL NULL NULL 9 End temporary; Using join buffer (incremental, BNL join) +1 PRIMARY t_inner_4 ALL NULL NULL NULL NULL 3 Start temporary; Using join buffer (incremental, BNL join) 1 PRIMARY t_outer_2 ALL NULL NULL NULL NULL 9 Using join buffer (incremental, BNL join) -1 PRIMARY t_inner_4 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) -1 PRIMARY t_inner_3 ALL NULL NULL NULL NULL 9 Using where; FirstMatch(t_outer_2); Using join buffer (incremental, BNL join) +1 PRIMARY t_inner_3 ALL NULL NULL NULL NULL 9 Using where; End temporary; Using join buffer (incremental, BNL join) select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES explain select * from t1 t_outer_1,t2 t_outer_2 where t_outer_1.a in (select t_inner_1.a from t2 t_inner_2, t1 t_inner_1) and @@ -5669,48 +5688,48 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "table": "t_outer_1", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } }, { "table": "t_outer_2", "table_scan": { "rows": 9, - "read_cost": 1.00769043, - "read_and_compare_cost": 3.25769043 + "read_cost": 0.011155245, + "read_and_compare_cost": 0.011443245 } }, { "table": "t_inner_2", "table_scan": { "rows": 9, - "read_cost": 1.00769043, - "read_and_compare_cost": 3.25769043 + "read_cost": 0.011155245, + "read_and_compare_cost": 0.011443245 } }, { "table": "t_inner_1", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } }, { "table": "t_inner_3", "table_scan": { "rows": 9, - "read_cost": 1.00769043, - "read_and_compare_cost": 3.25769043 + "read_cost": 0.011155245, + "read_and_compare_cost": 0.011443245 } }, { "table": "t_inner_4", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } } ] @@ -5745,18 +5764,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -5771,18 +5790,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -5797,18 +5816,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25769043, + "rows_out": 9, + "cost": 0.011443245, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 3.25769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.011443245, "uses_join_buffering": false } } @@ -5823,18 +5842,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25769043, + "rows_out": 9, + "cost": 0.011443245, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 3.25769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.011443245, "uses_join_buffering": false } } @@ -5849,18 +5868,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -5875,18 +5894,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25769043, + "rows_out": 9, + "cost": 0.011443245, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 3.25769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.011443245, "uses_join_buffering": false } } @@ -5897,7 +5916,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_outer_1", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -5913,18 +5932,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 3.890063477, + "rows_out": 3, + "cost": 0.011523207, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 3.890063477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.011523207, "uses_join_buffering": true } } @@ -5939,18 +5958,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 9.67019043, + "rows_out": 9, + "cost": 0.014133225, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 9.67019043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.014133225, "uses_join_buffering": true } } @@ -5965,18 +5984,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 9.67019043, + "rows_out": 9, + "cost": 0.014133225, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 9.67019043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.014133225, "uses_join_buffering": true } } @@ -5991,18 +6010,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 3.890063477, + "rows_out": 3, + "cost": 0.011523207, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 3.890063477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.011523207, "uses_join_buffering": true } } @@ -6017,18 +6036,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 9.67019043, + "rows_out": 9, + "cost": 0.014133225, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 9.67019043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.014133225, "uses_join_buffering": true } } @@ -6039,7 +6058,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_outer_2", "rows_for_plan": 27, - "cost_for_plan": 11.42275391, + "cost_for_plan": 0.02463804, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6055,18 +6074,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 70.08269043, + "rows_out": 9, + "cost": 0.050443503, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 70.08269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.050443503, "uses_join_buffering": true } } @@ -6081,18 +6100,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 24.02756348, + "rows_out": 3, + "cost": 0.024600489, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 24.02756348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.024600489, "uses_join_buffering": true } } @@ -6107,18 +6126,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 24.02756348, + "rows_out": 3, + "cost": 0.024600489, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 24.02756348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.024600489, "uses_join_buffering": true } } @@ -6133,18 +6152,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 70.08269043, + "rows_out": 9, + "cost": 0.050443503, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 70.08269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.050443503, "uses_join_buffering": true } } @@ -6155,7 +6174,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_1", "rows_for_plan": 81, - "cost_for_plan": 35.45031738, + "cost_for_plan": 0.049238529, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6171,18 +6190,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 231.0701904, + "rows_out": 9, + "cost": 0.172815333, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 231.0701904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.172815333, "uses_join_buffering": true } } @@ -6197,18 +6216,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 77.69006348, + "rows_out": 3, + "cost": 0.067582275, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 77.69006348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.067582275, "uses_join_buffering": true } } @@ -6223,18 +6242,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 231.0701904, + "rows_out": 9, + "cost": 0.172815333, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 231.0701904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.172815333, "uses_join_buffering": true } } @@ -6245,25 +6264,31 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 729, - "cost_for_plan": 266.5205078, + "cost_for_plan": 0.222053862, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 27, - "cost": 322.6148926 + "rows": 27, + "cost": 1.23517089 }, { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 266.5205078, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 380.9205078 + "prefix_row_count": 27, + "tmp_table_rows": 1, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.222053862, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.368747182 }, { - "chosen_strategy": "FirstMatch" + "chosen_strategy": "DuplicateWeedout" } ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704, "rest_of_plan": [ { "plan_prefix": [ @@ -6283,18 +6308,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 30.10256348, + "rows_out": 3, + "cost": 0.034460781, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 30.10256348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.034460781, "uses_join_buffering": true } } @@ -6309,18 +6334,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 88.30769043, + "rows_out": 9, + "cost": 0.080024379, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 88.30769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.080024379, "uses_join_buffering": true } } @@ -6336,7 +6361,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 352.7174561, + "cost_for_plan": 0.403207963, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6358,18 +6383,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 285.7451904, + "rows_out": 9, + "cost": 0.261557961, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 285.7451904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.261557961, "uses_join_buffering": true } } @@ -6386,25 +6411,31 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 638.4626465, + "cost_for_plan": 0.664765924, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 27, - "cost": 633.8070313 + "rows": 27, + "cost": 1.579280032 }, { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 638.4626465, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 752.8626465 + "prefix_row_count": 27, + "tmp_table_rows": 1, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.664765924, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.811459244 }, { - "chosen_strategy": "FirstMatch" + "chosen_strategy": "DuplicateWeedout" } - ] + ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704 } ] }, @@ -6417,7 +6448,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 410.922583, + "cost_for_plan": 0.448771561, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6427,7 +6458,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_4", "rows_for_plan": 243, - "cost_for_plan": 113.1403809, + "cost_for_plan": 0.116820804, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6448,18 +6479,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 768.7076904, + "rows_out": 9, + "cost": 0.628673451, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 768.7076904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, "uses_join_buffering": true } } @@ -6474,18 +6505,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 768.7076904, + "rows_out": 9, + "cost": 0.628673451, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 768.7076904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, "uses_join_buffering": true } } @@ -6501,11 +6532,86 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_2", "rows_for_plan": 2187, - "cost_for_plan": 881.8480713, + "cost_for_plan": 0.745494255, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 881.8480713, - "best_cost": 633.8071312 + "rest_of_plan": [ + { + "plan_prefix": [ + "t_outer_1", + "t_outer_2", + "t_inner_1", + "t_inner_4", + "t_inner_2" + ], + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "t_inner_3", + "plan_details": { + "record_count": 2187 + }, + "considered_access_paths": [ + { + "access_type": "scan_with_join_cache", + "rows": 9, + "rows_after_filter": 9, + "rows_out": 9, + "cost": 6.764540577, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 9, + "rows_out": 9, + "cost": 6.764540577, + "uses_join_buffering": true + } + } + } + ] + }, + { + "plan_prefix": [ + "t_outer_1", + "t_outer_2", + "t_inner_1", + "t_inner_4", + "t_inner_2" + ], + "table": "t_inner_3", + "rows_for_plan": 19683, + "cost_for_plan": 7.510034832, + "semijoin_strategy_choice": [ + { + "strategy": "FirstMatch", + "rows": 27, + "cost": 28.96624341 + }, + { + "strategy": "DuplicateWeedout", + "prefix_row_count": 27, + "tmp_table_rows": 1, + "sj_inner_fanout": 729, + "rows": 27, + "dups_cost": 7.510034832, + "write_cost": 0.02934619, + "full_lookup_cost": 3.16837251, + "total_cost": 10.70775353 + }, + { + "chosen_strategy": "FirstMatch" + } + ], + "sj_rows_out": 0.012345679, + "sj_rows_for_plan": 27, + "sj_filtered": 0.137174211, + "pruned_by_cost": true, + "current_cost": 28.96624341, + "best_cost": 0.811459244 + } + ] }, { "plan_prefix": [ @@ -6516,11 +6622,9 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 2187, - "cost_for_plan": 881.8480713, + "cost_for_plan": 0.745494255, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 881.8480713, - "best_cost": 633.8071312 + "pruned_by_heuristic": true } ] }, @@ -6528,7 +6632,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 266.5205078, + "cost_for_plan": 0.222053862, "semijoin_strategy_choice": [], "pruned_by_heuristic": "min_read_time" } @@ -6538,7 +6642,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_2", "rows_for_plan": 243, - "cost_for_plan": 81.50544434, + "cost_for_plan": 0.075081543, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6546,7 +6650,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 35.45031738, + "cost_for_plan": 0.049238529, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -6554,7 +6658,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 81.50544434, + "cost_for_plan": 0.075081543, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6564,7 +6668,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_1", "rows_for_plan": 9, - "cost_for_plan": 5.642626953, + "cost_for_plan": 0.022028022, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6580,18 +6684,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 25.53269043, + "rows_out": 9, + "cost": 0.024443331, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 25.53269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.024443331, "uses_join_buffering": true } } @@ -6606,18 +6710,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 25.53269043, + "rows_out": 9, + "cost": 0.024443331, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 25.53269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.024443331, "uses_join_buffering": true } } @@ -6632,18 +6736,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 9.177563477, + "rows_out": 3, + "cost": 0.015203373, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 9.177563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.015203373, "uses_join_buffering": true } } @@ -6658,18 +6762,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 25.53269043, + "rows_out": 9, + "cost": 0.024443331, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 25.53269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.024443331, "uses_join_buffering": true } } @@ -6680,7 +6784,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_outer_2", "rows_for_plan": 81, - "cost_for_plan": 31.17531738, + "cost_for_plan": 0.046471353, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6696,18 +6800,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 231.0701904, + "rows_out": 9, + "cost": 0.172815333, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 231.0701904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.172815333, "uses_join_buffering": true } } @@ -6722,18 +6826,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 77.69006348, + "rows_out": 3, + "cost": 0.067582275, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 77.69006348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.067582275, "uses_join_buffering": true } } @@ -6748,18 +6852,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 231.0701904, + "rows_out": 9, + "cost": 0.172815333, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 231.0701904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.172815333, "uses_join_buffering": true } } @@ -6770,20 +6874,26 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], "table": "t_inner_2", "rows_for_plan": 729, - "cost_for_plan": 262.2455078, + "cost_for_plan": 0.219286686, "semijoin_strategy_choice": [ { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 262.2455078, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 376.6455078 + "prefix_row_count": 3, + "tmp_table_rows": 9, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.219286686, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.365980006 }, { "chosen_strategy": "DuplicateWeedout" } ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704, "rest_of_plan": [ { "plan_prefix": [ @@ -6803,18 +6913,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 30.10256348, + "rows_out": 3, + "cost": 0.034460781, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 30.10256348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.034460781, "uses_join_buffering": true } } @@ -6829,18 +6939,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 88.30769043, + "rows_out": 9, + "cost": 0.080024379, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 88.30769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.080024379, "uses_join_buffering": true } } @@ -6856,7 +6966,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 406.7480713, + "cost_for_plan": 0.400440787, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6878,18 +6988,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 285.7451904, + "rows_out": 9, + "cost": 0.261557961, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 285.7451904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.261557961, "uses_join_buffering": true } } @@ -6906,28 +7016,31 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 692.4932617, + "cost_for_plan": 0.661998748, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 27, - "cost": 687.8376465 + "rows": 27, + "cost": 1.576512856 }, { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 692.4932617, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 806.8932617 + "prefix_row_count": 27, + "tmp_table_rows": 1, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.661998748, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.808692068 }, { - "chosen_strategy": "FirstMatch" + "chosen_strategy": "DuplicateWeedout" } ], - "pruned_by_cost": true, - "current_cost": 687.8376465, - "best_cost": 633.8071312 + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704 } ] }, @@ -6940,7 +7053,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 464.9531982, + "cost_for_plan": 0.446004385, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -6950,7 +7063,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], "table": "t_inner_4", "rows_for_plan": 243, - "cost_for_plan": 108.8653809, + "cost_for_plan": 0.114053628, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -6971,18 +7084,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 768.7076904, + "rows_out": 9, + "cost": 0.628673451, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 768.7076904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, "uses_join_buffering": true } } @@ -6997,18 +7110,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 768.7076904, + "rows_out": 9, + "cost": 0.628673451, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 768.7076904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, "uses_join_buffering": true } } @@ -7024,11 +7137,81 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_2", "rows_for_plan": 2187, - "cost_for_plan": 877.5730713, + "cost_for_plan": 0.742727079, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 877.5730713, - "best_cost": 633.8071312 + "rest_of_plan": [ + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_outer_2", + "t_inner_4", + "t_inner_2" + ], + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "t_inner_3", + "plan_details": { + "record_count": 2187 + }, + "considered_access_paths": [ + { + "access_type": "scan_with_join_cache", + "rows": 9, + "rows_after_filter": 9, + "rows_out": 9, + "cost": 6.764540577, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 9, + "rows_out": 9, + "cost": 6.764540577, + "uses_join_buffering": true + } + } + } + ] + }, + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_outer_2", + "t_inner_4", + "t_inner_2" + ], + "table": "t_inner_3", + "rows_for_plan": 19683, + "cost_for_plan": 7.507267656, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicateWeedout", + "prefix_row_count": 3, + "tmp_table_rows": 9, + "sj_inner_fanout": 729, + "rows": 27, + "dups_cost": 7.507267656, + "write_cost": 0.02934619, + "full_lookup_cost": 3.16837251, + "total_cost": 10.70498636 + }, + { + "chosen_strategy": "DuplicateWeedout" + } + ], + "sj_rows_out": 0.012345679, + "sj_rows_for_plan": 27, + "sj_filtered": 0.137174211, + "pruned_by_cost": true, + "current_cost": 10.70498636, + "best_cost": 0.808692068 + } + ] }, { "plan_prefix": [ @@ -7039,11 +7222,9 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 2187, - "cost_for_plan": 877.5730713, + "cost_for_plan": 0.742727079, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 877.5730713, - "best_cost": 633.8071312 + "pruned_by_heuristic": true } ] }, @@ -7051,7 +7232,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 262.2455078, + "cost_for_plan": 0.219286686, "semijoin_strategy_choice": [], "pruned_by_heuristic": "min_read_time" } @@ -7061,25 +7242,31 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 81, - "cost_for_plan": 31.17531738, + "cost_for_plan": 0.046471353, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 3, - "cost": 36.32946777 + "rows": 3, + "cost": 0.145008465 }, { "strategy": "DuplicateWeedout", - "records": 3, - "dups_cost": 31.17531738, - "write_cost": 1.45, - "full_lookup_cost": 12.15, - "total_cost": 44.77531738 + "prefix_row_count": 3, + "tmp_table_rows": 1, + "sj_inner_fanout": 27, + "rows": 3, + "dups_cost": 0.046471353, + "write_cost": 0.02548291, + "full_lookup_cost": 0.01303857, + "total_cost": 0.084992833 }, { - "chosen_strategy": "FirstMatch" + "chosen_strategy": "DuplicateWeedout" } ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 3, + "sj_filtered": 3.703703704, "rest_of_plan": [ { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], @@ -7094,18 +7281,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 11.69519043, + "rows_out": 9, + "cost": 0.017419989, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 11.69519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.017419989, "uses_join_buffering": true } } @@ -7120,18 +7307,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 4.565063477, + "rows_out": 3, + "cost": 0.012618795, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 4.565063477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.012618795, "uses_join_buffering": true } } @@ -7146,18 +7333,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 11.69519043, + "rows_out": 9, + "cost": 0.017419989, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 11.69519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.017419989, "uses_join_buffering": true } } @@ -7168,7 +7355,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_outer_2", "rows_for_plan": 27, - "cost_for_plan": 48.0246582, + "cost_for_plan": 0.102412822, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7189,18 +7376,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 30.10256348, + "rows_out": 3, + "cost": 0.034460781, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 30.10256348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.034460781, "uses_join_buffering": true } } @@ -7215,18 +7402,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 88.30769043, + "rows_out": 9, + "cost": 0.080024379, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 88.30769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.080024379, "uses_join_buffering": true } } @@ -7242,7 +7429,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 78.12722168, + "cost_for_plan": 0.136873603, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7264,18 +7451,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 285.7451904, + "rows_out": 9, + "cost": 0.261557961, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 285.7451904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.261557961, "uses_join_buffering": true } } @@ -7292,25 +7479,31 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 363.8724121, + "cost_for_plan": 0.398431564, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 27, - "cost": 359.2167969 + "rows": 27, + "cost": 1.312945672 }, { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 363.8724121, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 478.2724121 + "prefix_row_count": 27, + "tmp_table_rows": 1, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.398431564, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.545124884 }, { - "chosen_strategy": "FirstMatch" + "chosen_strategy": "DuplicateWeedout" } - ] + ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704 } ] }, @@ -7323,7 +7516,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 136.3323486, + "cost_for_plan": 0.182437201, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7333,7 +7526,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_inner_4", "rows_for_plan": 9, - "cost_for_plan": 40.89453125, + "cost_for_plan": 0.097611628, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7354,18 +7547,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 31.60769043, + "rows_out": 9, + "cost": 0.034303623, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 31.60769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.034303623, "uses_join_buffering": true } } @@ -7380,18 +7573,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 31.60769043, + "rows_out": 9, + "cost": 0.034303623, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 31.60769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.034303623, "uses_join_buffering": true } } @@ -7407,7 +7600,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_outer_2", "rows_for_plan": 81, - "cost_for_plan": 72.50222168, + "cost_for_plan": 0.131915251, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7429,18 +7622,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 285.7451904, + "rows_out": 9, + "cost": 0.261557961, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 285.7451904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.261557961, "uses_join_buffering": true } } @@ -7457,23 +7650,26 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 358.2474121, + "cost_for_plan": 0.393473212, "semijoin_strategy_choice": [ { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 358.2474121, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 472.6474121 + "prefix_row_count": 3, + "tmp_table_rows": 9, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.393473212, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.540166532 }, { "chosen_strategy": "DuplicateWeedout" } ], - "pruned_by_cost": true, - "current_cost": 472.6474121, - "best_cost": 359.2168969 + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704 } ] }, @@ -7486,7 +7682,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 81, - "cost_for_plan": 72.50222168, + "cost_for_plan": 0.131915251, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7496,7 +7692,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 48.0246582, + "cost_for_plan": 0.102412822, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7506,7 +7702,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_4", "rows_for_plan": 27, - "cost_for_plan": 14.82019043, + "cost_for_plan": 0.037231395, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7522,18 +7718,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 79.19519043, + "rows_out": 9, + "cost": 0.065233941, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 79.19519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.065233941, "uses_join_buffering": true } } @@ -7548,18 +7744,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 79.19519043, + "rows_out": 9, + "cost": 0.065233941, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 79.19519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.065233941, "uses_join_buffering": true } } @@ -7574,18 +7770,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 79.19519043, + "rows_out": 9, + "cost": 0.065233941, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 79.19519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.065233941, "uses_join_buffering": true } } @@ -7596,7 +7792,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], "table": "t_outer_2", "rows_for_plan": 243, - "cost_for_plan": 94.01538086, + "cost_for_plan": 0.102465336, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -7617,18 +7813,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 768.7076904, + "rows_out": 9, + "cost": 0.628673451, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 768.7076904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, "uses_join_buffering": true } } @@ -7643,18 +7839,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 768.7076904, + "rows_out": 9, + "cost": 0.628673451, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 768.7076904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, "uses_join_buffering": true } } @@ -7670,11 +7866,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_2", "rows_for_plan": 2187, - "cost_for_plan": 862.7230713, + "cost_for_plan": 0.731138787, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 862.7230713, - "best_cost": 359.2168969 + "current_cost": 0.731138787, + "best_cost": 0.540166532 }, { "plan_prefix": [ @@ -7685,11 +7881,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 2187, - "cost_for_plan": 862.7230713, + "cost_for_plan": 0.731138787, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 862.7230713, - "best_cost": 359.2168969 + "current_cost": 0.731138787, + "best_cost": 0.540166532 } ] }, @@ -7697,7 +7893,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], "table": "t_inner_2", "rows_for_plan": 243, - "cost_for_plan": 94.01538086, + "cost_for_plan": 0.102465336, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7705,7 +7901,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 94.01538086, + "cost_for_plan": 0.102465336, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7715,7 +7911,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_3", "rows_for_plan": 81, - "cost_for_plan": 31.17531738, + "cost_for_plan": 0.046471353, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7725,7 +7921,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_2", "rows_for_plan": 27, - "cost_for_plan": 11.42275391, + "cost_for_plan": 0.02463804, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7733,7 +7929,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_4", "rows_for_plan": 9, - "cost_for_plan": 5.642626953, + "cost_for_plan": 0.022028022, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7741,7 +7937,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 11.42275391, + "cost_for_plan": 0.02463804, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7751,7 +7947,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_outer_2", "rows_for_plan": 9, - "cost_for_plan": 3.25769043, + "cost_for_plan": 0.011443245, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7759,7 +7955,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7767,7 +7963,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 3.25769043, + "cost_for_plan": 0.011443245, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7775,7 +7971,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_4", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -7783,7 +7979,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_3", "rows_for_plan": 9, - "cost_for_plan": 3.25769043, + "cost_for_plan": 0.011443245, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -7792,122 +7988,10 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "fix_semijoin_strategies_for_picked_join_order": [ { - "semi_join_strategy": "FirstMatch", - "join_order": [ - { - "table": "t_inner_4", - "best_access_path": { - "table": "t_inner_4", - "plan_details": { - "record_count": 27 - }, - "considered_access_paths": [ - { - "access_type": "scan", - "rows": 3, - "rows_after_scan": 3, - "rows_after_filter": 3, - "cost": 47.31921387, - "index_only": false, - "chosen": true - } - ], - "chosen_access_method": { - "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 47.31921387, - "uses_join_buffering": false - } - } - }, - { - "table": "t_inner_3", - "best_access_path": { - "table": "t_inner_3", - "plan_details": { - "record_count": 81 - }, - "considered_access_paths": [ - { - "access_type": "scan", - "rows": 9, - "rows_after_scan": 9, - "rows_after_filter": 9, - "cost": 263.8729248, - "index_only": false, - "chosen": true - } - ], - "chosen_access_method": { - "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 263.8729248, - "uses_join_buffering": false - } - } - } - ] + "semi_join_strategy": "DuplicateWeedout" }, { - "semi_join_strategy": "FirstMatch", - "join_order": [ - { - "table": "t_inner_1", - "best_access_path": { - "table": "t_inner_1", - "plan_details": { - "record_count": 3 - }, - "considered_access_paths": [ - { - "access_type": "scan", - "rows": 3, - "rows_after_scan": 3, - "rows_after_filter": 3, - "cost": 5.25769043, - "index_only": false, - "chosen": true - } - ], - "chosen_access_method": { - "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 5.25769043, - "uses_join_buffering": false - } - } - }, - { - "table": "t_inner_2", - "best_access_path": { - "table": "t_inner_2", - "plan_details": { - "record_count": 9 - }, - "considered_access_paths": [ - { - "access_type": "scan", - "rows": 9, - "rows_after_scan": 9, - "rows_after_filter": 9, - "cost": 29.31921387, - "index_only": false, - "chosen": true - } - ], - "chosen_access_method": { - "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 29.31921387, - "uses_join_buffering": false - } - } - } - ] + "semi_join_strategy": "DuplicateWeedout" } ] }, @@ -7916,12 +8000,12 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "t_outer_1", "t_inner_1", "t_inner_2", - "t_outer_2", "t_inner_4", + "t_outer_2", "t_inner_3" ], "rows": 27, - "cost": 359.2167969 + "cost": 0.540166532 }, { "substitute_best_equal": { @@ -7946,11 +8030,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "attached": null }, { - "table": "t_outer_2", + "table": "t_inner_4", "attached": null }, { - "table": "t_inner_4", + "table": "t_outer_2", "attached": null }, { @@ -7976,8 +8060,8 @@ explain select * from t1 t_outer_1,t2 t_outer_2 where t_outer_1.a in (select t_ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t_outer_1 ALL NULL NULL NULL NULL 3 -1 PRIMARY t_outer_2 ALL NULL NULL NULL NULL 9 Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +1 PRIMARY t_outer_2 ALL NULL NULL NULL NULL 9 Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 2 MATERIALIZED t_inner_1 ALL NULL NULL NULL NULL 3 2 MATERIALIZED t_inner_2 ALL NULL NULL NULL NULL 9 Using join buffer (flat, BNL join) @@ -8141,48 +8225,48 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "table": "t_outer_1", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } }, { "table": "t_outer_2", "table_scan": { "rows": 9, - "read_cost": 1.00769043, - "read_and_compare_cost": 3.25769043 + "read_cost": 0.011155245, + "read_and_compare_cost": 0.011443245 } }, { "table": "t_inner_2", "table_scan": { "rows": 9, - "read_cost": 1.00769043, - "read_and_compare_cost": 3.25769043 + "read_cost": 0.011155245, + "read_and_compare_cost": 0.011443245 } }, { "table": "t_inner_1", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } }, { "table": "t_inner_3", "table_scan": { "rows": 9, - "read_cost": 1.00769043, - "read_and_compare_cost": 3.25769043 + "read_cost": 0.011155245, + "read_and_compare_cost": 0.011443245 } }, { "table": "t_inner_4", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } } ] @@ -8215,18 +8299,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -8241,18 +8325,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25769043, + "rows_out": 9, + "cost": 0.011443245, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 3.25769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.011443245, "uses_join_buffering": false } } @@ -8263,7 +8347,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "rest_of_plan": [ { "plan_prefix": ["t_inner_1"], @@ -8278,18 +8362,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 9.67019043, + "rows_out": 9, + "cost": 0.014133225, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 9.67019043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.014133225, "uses_join_buffering": true } } @@ -8300,7 +8384,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_inner_1"], "table": "t_inner_2", "rows_for_plan": 27, - "cost_for_plan": 11.42275391 + "cost_for_plan": 0.02463804 } ] }, @@ -8308,7 +8392,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 3.25769043, + "cost_for_plan": 0.011443245, "pruned_by_heuristic": true } ] @@ -8328,18 +8412,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -8354,18 +8438,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25769043, + "rows_out": 9, + "cost": 0.011443245, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 3.25769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.011443245, "uses_join_buffering": false } } @@ -8376,7 +8460,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_4", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "rest_of_plan": [ { "plan_prefix": ["t_inner_4"], @@ -8391,18 +8475,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 9.67019043, + "rows_out": 9, + "cost": 0.014133225, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 9.67019043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.014133225, "uses_join_buffering": true } } @@ -8413,7 +8497,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_inner_4"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 11.42275391 + "cost_for_plan": 0.02463804 } ] }, @@ -8421,7 +8505,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_3", "rows_for_plan": 9, - "cost_for_plan": 3.25769043, + "cost_for_plan": 0.011443245, "pruned_by_heuristic": true } ] @@ -8444,18 +8528,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -8470,18 +8554,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -8496,18 +8580,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25769043, + "rows_out": 9, + "cost": 0.011443245, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 3.25769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.011443245, "uses_join_buffering": false } } @@ -8522,18 +8606,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25769043, + "rows_out": 9, + "cost": 0.011443245, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 3.25769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.011443245, "uses_join_buffering": false } } @@ -8548,18 +8632,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -8574,18 +8658,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 3.25769043, + "rows_out": 9, + "cost": 0.011443245, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 3.25769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.011443245, "uses_join_buffering": false } } @@ -8596,7 +8680,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_outer_1", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -8612,18 +8696,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 3.890063477, + "rows_out": 3, + "cost": 0.011523207, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 3.890063477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.011523207, "uses_join_buffering": true } } @@ -8638,18 +8722,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 9.67019043, + "rows_out": 9, + "cost": 0.014133225, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 9.67019043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.014133225, "uses_join_buffering": true } } @@ -8664,18 +8748,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 9.67019043, + "rows_out": 9, + "cost": 0.014133225, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 9.67019043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.014133225, "uses_join_buffering": true } } @@ -8690,18 +8774,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 3.890063477, + "rows_out": 3, + "cost": 0.011523207, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 3.890063477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.011523207, "uses_join_buffering": true } } @@ -8716,18 +8800,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 9.67019043, + "rows_out": 9, + "cost": 0.014133225, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 9.67019043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.014133225, "uses_join_buffering": true } } @@ -8738,7 +8822,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_outer_2", "rows_for_plan": 27, - "cost_for_plan": 11.42275391, + "cost_for_plan": 0.02463804, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -8754,18 +8838,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 70.08269043, + "rows_out": 9, + "cost": 0.050443503, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 70.08269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.050443503, "uses_join_buffering": true } } @@ -8780,18 +8864,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 24.02756348, + "rows_out": 3, + "cost": 0.024600489, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 24.02756348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.024600489, "uses_join_buffering": true } } @@ -8806,18 +8890,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 24.02756348, + "rows_out": 3, + "cost": 0.024600489, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 24.02756348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.024600489, "uses_join_buffering": true } } @@ -8832,18 +8916,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 70.08269043, + "rows_out": 9, + "cost": 0.050443503, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 70.08269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.050443503, "uses_join_buffering": true } } @@ -8854,7 +8938,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_1", "rows_for_plan": 81, - "cost_for_plan": 35.45031738, + "cost_for_plan": 0.049238529, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -8870,18 +8954,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 231.0701904, + "rows_out": 9, + "cost": 0.172815333, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 231.0701904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.172815333, "uses_join_buffering": true } } @@ -8896,18 +8980,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 77.69006348, + "rows_out": 3, + "cost": 0.067582275, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 77.69006348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.067582275, "uses_join_buffering": true } } @@ -8922,18 +9006,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 231.0701904, + "rows_out": 9, + "cost": 0.172815333, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 231.0701904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.172815333, "uses_join_buffering": true } } @@ -8944,30 +9028,36 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 729, - "cost_for_plan": 266.5205078, + "cost_for_plan": 0.222053862, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 27, - "cost": 322.6148926 + "rows": 27, + "cost": 1.23517089 }, { "strategy": "SJ-Materialization", - "records": 27, - "cost": 35.99550781 + "rows": 27, + "cost": 0.083958496 }, { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 266.5205078, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 380.9205078 + "prefix_row_count": 27, + "tmp_table_rows": 1, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.222053862, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.368747182 }, { "chosen_strategy": "SJ-Materialization" } ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704, "rest_of_plan": [ { "plan_prefix": [ @@ -8987,18 +9077,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 30.10256348, + "rows_out": 3, + "cost": 0.034460781, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 30.10256348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.034460781, "uses_join_buffering": true } } @@ -9013,18 +9103,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 88.30769043, + "rows_out": 9, + "cost": 0.080024379, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 88.30769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.080024379, "uses_join_buffering": true } } @@ -9040,7 +9130,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 66.09807129, + "cost_for_plan": 0.118419277, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -9062,18 +9152,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 285.7451904, + "rows_out": 9, + "cost": 0.261557961, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 285.7451904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.261557961, "uses_join_buffering": true } } @@ -9090,30 +9180,36 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 351.8432617, + "cost_for_plan": 0.379977238, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 27, - "cost": 347.1876465 + "rows": 27, + "cost": 1.294491346 }, { "strategy": "SJ-Materialization", - "records": 27, - "cost": 60.56826172 + "rows": 27, + "cost": 0.143278952 }, { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 351.8432617, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 466.2432617 + "prefix_row_count": 27, + "tmp_table_rows": 1, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.379977238, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.526670558 }, { "chosen_strategy": "SJ-Materialization" } - ] + ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704 } ] }, @@ -9126,11 +9222,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 124.3031982, + "cost_for_plan": 0.163982875, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 124.3031982, - "best_cost": 60.56836172 + "current_cost": 0.163982875, + "best_cost": 0.143278952 } ] }, @@ -9138,21 +9234,19 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_4", "rows_for_plan": 243, - "cost_for_plan": 113.1403809, + "cost_for_plan": 0.116820804, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 113.1403809, - "best_cost": 60.56836172 + "pruned_by_heuristic": true }, { "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 266.5205078, + "cost_for_plan": 0.222053862, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 266.5205078, - "best_cost": 60.56836172 + "current_cost": 0.222053862, + "best_cost": 0.143278952 } ] }, @@ -9160,17 +9254,15 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_2", "rows_for_plan": 243, - "cost_for_plan": 81.50544434, + "cost_for_plan": 0.075081543, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 81.50544434, - "best_cost": 60.56836172 + "pruned_by_heuristic": true }, { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 35.45031738, + "cost_for_plan": 0.049238529, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -9178,11 +9270,9 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_outer_2"], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 81.50544434, + "cost_for_plan": 0.075081543, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 81.50544434, - "best_cost": 60.56836172 + "pruned_by_heuristic": true } ] }, @@ -9190,7 +9280,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_1", "rows_for_plan": 9, - "cost_for_plan": 5.642626953, + "cost_for_plan": 0.022028022, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -9206,18 +9296,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 25.53269043, + "rows_out": 9, + "cost": 0.024443331, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 25.53269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.024443331, "uses_join_buffering": true } } @@ -9232,18 +9322,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 25.53269043, + "rows_out": 9, + "cost": 0.024443331, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 25.53269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.024443331, "uses_join_buffering": true } } @@ -9258,18 +9348,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 9.177563477, + "rows_out": 3, + "cost": 0.015203373, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 9.177563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.015203373, "uses_join_buffering": true } } @@ -9284,18 +9374,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 25.53269043, + "rows_out": 9, + "cost": 0.024443331, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 25.53269043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.024443331, "uses_join_buffering": true } } @@ -9306,7 +9396,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_outer_2", "rows_for_plan": 81, - "cost_for_plan": 31.17531738, + "cost_for_plan": 0.046471353, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -9322,18 +9412,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 231.0701904, + "rows_out": 9, + "cost": 0.172815333, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 231.0701904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.172815333, "uses_join_buffering": true } } @@ -9348,18 +9438,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 77.69006348, + "rows_out": 3, + "cost": 0.067582275, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 77.69006348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.067582275, "uses_join_buffering": true } } @@ -9374,18 +9464,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 231.0701904, + "rows_out": 9, + "cost": 0.172815333, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 231.0701904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.172815333, "uses_join_buffering": true } } @@ -9396,43 +9486,222 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], "table": "t_inner_2", "rows_for_plan": 729, - "cost_for_plan": 262.2455078, + "cost_for_plan": 0.219286686, "semijoin_strategy_choice": [ { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 262.2455078, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 376.6455078 + "prefix_row_count": 3, + "tmp_table_rows": 9, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.219286686, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.365980006 }, { "chosen_strategy": "DuplicateWeedout" } ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704, "pruned_by_cost": true, - "current_cost": 376.6455078, - "best_cost": 60.56836172 + "current_cost": 0.365980006, + "best_cost": 0.143278952 }, { "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], "table": "t_inner_4", "rows_for_plan": 243, - "cost_for_plan": 108.8653809, + "cost_for_plan": 0.114053628, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 108.8653809, - "best_cost": 60.56836172 + "rest_of_plan": [ + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_outer_2", + "t_inner_4" + ], + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "t_inner_2", + "plan_details": { + "record_count": 243 + }, + "considered_access_paths": [ + { + "access_type": "scan_with_join_cache", + "rows": 9, + "rows_after_filter": 9, + "rows_out": 9, + "cost": 0.628673451, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, + "uses_join_buffering": true + } + } + }, + { + "best_access_path": { + "table": "t_inner_3", + "plan_details": { + "record_count": 243 + }, + "considered_access_paths": [ + { + "access_type": "scan_with_join_cache", + "rows": 9, + "rows_after_filter": 9, + "rows_out": 9, + "cost": 0.628673451, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, + "uses_join_buffering": true + } + } + } + ] + }, + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_outer_2", + "t_inner_4" + ], + "table": "t_inner_2", + "rows_for_plan": 2187, + "cost_for_plan": 0.742727079, + "semijoin_strategy_choice": [], + "pruned_by_cost": true, + "current_cost": 0.742727079, + "best_cost": 0.143278952 + }, + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_outer_2", + "t_inner_4" + ], + "table": "t_inner_3", + "rows_for_plan": 2187, + "cost_for_plan": 0.742727079, + "semijoin_strategy_choice": [ + { + "strategy": "SJ-Materialization", + "rows": 81, + "cost": 0.116338225 + }, + { + "chosen_strategy": "SJ-Materialization" + } + ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 81, + "sj_filtered": 3.703703704, + "rest_of_plan": [ + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_outer_2", + "t_inner_4", + "t_inner_3" + ], + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "t_inner_2", + "plan_details": { + "record_count": 81 + }, + "considered_access_paths": [ + { + "access_type": "scan_with_join_cache", + "rows": 9, + "rows_after_filter": 9, + "rows_out": 9, + "cost": 0.261557961, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 9, + "rows_out": 9, + "cost": 0.261557961, + "uses_join_buffering": true + } + } + } + ] + }, + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_outer_2", + "t_inner_4", + "t_inner_3" + ], + "table": "t_inner_2", + "rows_for_plan": 729, + "cost_for_plan": 0.377896186, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicateWeedout", + "prefix_row_count": 3, + "tmp_table_rows": 9, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 1.00428504, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 1.15097836 + }, + { + "chosen_strategy": "DuplicateWeedout" + } + ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704, + "pruned_by_cost": true, + "current_cost": 1.15097836, + "best_cost": 0.143278952 + } + ] + } + ] }, { "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 262.2455078, + "cost_for_plan": 0.219286686, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 262.2455078, - "best_cost": 60.56836172 + "current_cost": 0.219286686, + "best_cost": 0.143278952 } ] }, @@ -9440,30 +9709,36 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_2", "rows_for_plan": 81, - "cost_for_plan": 31.17531738, + "cost_for_plan": 0.046471353, "semijoin_strategy_choice": [ { "strategy": "FirstMatch", - "records": 3, - "cost": 36.32946777 + "rows": 3, + "cost": 0.145008465 }, { "strategy": "SJ-Materialization", - "records": 3, - "cost": 19.12531738 + "rows": 3, + "cost": 0.065137975 }, { "strategy": "DuplicateWeedout", - "records": 3, - "dups_cost": 31.17531738, - "write_cost": 1.45, - "full_lookup_cost": 12.15, - "total_cost": 44.77531738 + "prefix_row_count": 3, + "tmp_table_rows": 1, + "sj_inner_fanout": 27, + "rows": 3, + "dups_cost": 0.046471353, + "write_cost": 0.02548291, + "full_lookup_cost": 0.01303857, + "total_cost": 0.084992833 }, { "chosen_strategy": "SJ-Materialization" } ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 3, + "sj_filtered": 3.703703704, "rest_of_plan": [ { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], @@ -9478,18 +9753,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 11.69519043, + "rows_out": 9, + "cost": 0.017419989, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 11.69519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.017419989, "uses_join_buffering": true } } @@ -9504,18 +9779,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 4.565063477, + "rows_out": 3, + "cost": 0.012618795, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 4.565063477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.012618795, "uses_join_buffering": true } } @@ -9530,18 +9805,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 11.69519043, + "rows_out": 9, + "cost": 0.017419989, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 11.69519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.017419989, "uses_join_buffering": true } } @@ -9552,7 +9827,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_outer_2", "rows_for_plan": 27, - "cost_for_plan": 30.82050781, + "cost_for_plan": 0.082557964, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -9573,18 +9848,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 30.10256348, + "rows_out": 3, + "cost": 0.034460781, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 30.10256348, + "rows_read": 3, + "rows_out": 3, + "cost": 0.034460781, "uses_join_buffering": true } } @@ -9599,18 +9874,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 88.30769043, + "rows_out": 9, + "cost": 0.080024379, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 88.30769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.080024379, "uses_join_buffering": true } } @@ -9626,11 +9901,88 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_4", "rows_for_plan": 81, - "cost_for_plan": 60.92307129, + "cost_for_plan": 0.117018745, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 60.92307129, - "best_cost": 60.56836172 + "rest_of_plan": [ + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_inner_2", + "t_outer_2", + "t_inner_4" + ], + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "t_inner_3", + "plan_details": { + "record_count": 81 + }, + "considered_access_paths": [ + { + "access_type": "scan_with_join_cache", + "rows": 9, + "rows_after_filter": 9, + "rows_out": 9, + "cost": 0.261557961, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 9, + "rows_out": 9, + "cost": 0.261557961, + "uses_join_buffering": true + } + } + } + ] + }, + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_inner_2", + "t_outer_2", + "t_inner_4" + ], + "table": "t_inner_3", + "rows_for_plan": 729, + "cost_for_plan": 0.378576706, + "semijoin_strategy_choice": [ + { + "strategy": "FirstMatch", + "rows": 27, + "cost": 1.293090814 + }, + { + "strategy": "SJ-Materialization", + "rows": 27, + "cost": 0.14187842 + }, + { + "strategy": "DuplicateWeedout", + "prefix_row_count": 27, + "tmp_table_rows": 1, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.378576706, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.525270026 + }, + { + "chosen_strategy": "SJ-Materialization" + } + ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704 + } + ] }, { "plan_prefix": [ @@ -9641,11 +9993,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 119.1281982, + "cost_for_plan": 0.162582343, "semijoin_strategy_choice": [], "pruned_by_cost": true, - "current_cost": 119.1281982, - "best_cost": 60.56836172 + "current_cost": 0.162582343, + "best_cost": 0.14187842 } ] }, @@ -9653,7 +10005,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_inner_4", "rows_for_plan": 9, - "cost_for_plan": 23.69038086, + "cost_for_plan": 0.07775677, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -9674,18 +10026,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 31.60769043, + "rows_out": 9, + "cost": 0.034303623, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 31.60769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.034303623, "uses_join_buffering": true } } @@ -9700,18 +10052,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 31.60769043, + "rows_out": 9, + "cost": 0.034303623, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 31.60769043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.034303623, "uses_join_buffering": true } } @@ -9727,7 +10079,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_outer_2", "rows_for_plan": 81, - "cost_for_plan": 55.29807129, + "cost_for_plan": 0.112060393, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -9749,18 +10101,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 285.7451904, + "rows_out": 9, + "cost": 0.261557961, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 285.7451904, + "rows_read": 9, + "rows_out": 9, + "cost": 0.261557961, "uses_join_buffering": true } } @@ -9777,23 +10129,29 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 729, - "cost_for_plan": 341.0432617, + "cost_for_plan": 0.373618354, "semijoin_strategy_choice": [ { "strategy": "DuplicateWeedout", - "records": 27, - "dups_cost": 341.0432617, - "write_cost": 5.05, - "full_lookup_cost": 109.35, - "total_cost": 455.4432617 + "prefix_row_count": 3, + "tmp_table_rows": 9, + "sj_inner_fanout": 27, + "rows": 27, + "dups_cost": 0.373618354, + "write_cost": 0.02934619, + "full_lookup_cost": 0.11734713, + "total_cost": 0.520311674 }, { "chosen_strategy": "DuplicateWeedout" } ], + "sj_rows_out": 0.333333333, + "sj_rows_for_plan": 27, + "sj_filtered": 3.703703704, "pruned_by_cost": true, - "current_cost": 455.4432617, - "best_cost": 60.56836172 + "current_cost": 0.520311674, + "best_cost": 0.14187842 } ] }, @@ -9806,7 +10164,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ], "table": "t_inner_3", "rows_for_plan": 81, - "cost_for_plan": 55.29807129, + "cost_for_plan": 0.112060393, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -9816,7 +10174,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 30.82050781, + "cost_for_plan": 0.082557964, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -9826,7 +10184,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_4", "rows_for_plan": 27, - "cost_for_plan": 14.82019043, + "cost_for_plan": 0.037231395, "semijoin_strategy_choice": [], "rest_of_plan": [ { @@ -9842,18 +10200,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 79.19519043, + "rows_out": 9, + "cost": 0.065233941, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 79.19519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.065233941, "uses_join_buffering": true } } @@ -9868,18 +10226,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 79.19519043, + "rows_out": 9, + "cost": 0.065233941, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 79.19519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.065233941, "uses_join_buffering": true } } @@ -9894,18 +10252,18 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "access_type": "scan_with_join_cache", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 9, - "cost": 79.19519043, + "rows_out": 9, + "cost": 0.065233941, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 9, - "records_out": 9, - "cost": 79.19519043, + "rows_read": 9, + "rows_out": 9, + "cost": 0.065233941, "uses_join_buffering": true } } @@ -9916,31 +10274,118 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], "table": "t_outer_2", "rows_for_plan": 243, - "cost_for_plan": 94.01538086, + "cost_for_plan": 0.102465336, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 94.01538086, - "best_cost": 60.56836172 + "rest_of_plan": [ + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_inner_4", + "t_outer_2" + ], + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "t_inner_2", + "plan_details": { + "record_count": 243 + }, + "considered_access_paths": [ + { + "access_type": "scan_with_join_cache", + "rows": 9, + "rows_after_filter": 9, + "rows_out": 9, + "cost": 0.628673451, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, + "uses_join_buffering": true + } + } + }, + { + "best_access_path": { + "table": "t_inner_3", + "plan_details": { + "record_count": 243 + }, + "considered_access_paths": [ + { + "access_type": "scan_with_join_cache", + "rows": 9, + "rows_after_filter": 9, + "rows_out": 9, + "cost": 0.628673451, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 9, + "rows_out": 9, + "cost": 0.628673451, + "uses_join_buffering": true + } + } + } + ] + }, + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_inner_4", + "t_outer_2" + ], + "table": "t_inner_2", + "rows_for_plan": 2187, + "cost_for_plan": 0.731138787, + "semijoin_strategy_choice": [], + "pruned_by_cost": true, + "current_cost": 0.731138787, + "best_cost": 0.14187842 + }, + { + "plan_prefix": [ + "t_outer_1", + "t_inner_1", + "t_inner_4", + "t_outer_2" + ], + "table": "t_inner_3", + "rows_for_plan": 2187, + "cost_for_plan": 0.731138787, + "semijoin_strategy_choice": [], + "pruned_by_cost": true, + "current_cost": 0.731138787, + "best_cost": 0.14187842 + } + ] }, { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], "table": "t_inner_2", "rows_for_plan": 243, - "cost_for_plan": 94.01538086, + "cost_for_plan": 0.102465336, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 94.01538086, - "best_cost": 60.56836172 + "pruned_by_heuristic": true }, { "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], "table": "t_inner_3", "rows_for_plan": 243, - "cost_for_plan": 94.01538086, + "cost_for_plan": 0.102465336, "semijoin_strategy_choice": [], - "pruned_by_cost": true, - "current_cost": 94.01538086, - "best_cost": 60.56836172 + "pruned_by_heuristic": true } ] }, @@ -9948,7 +10393,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1", "t_inner_1"], "table": "t_inner_3", "rows_for_plan": 81, - "cost_for_plan": 31.17531738, + "cost_for_plan": 0.046471353, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -9958,7 +10403,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_2", "rows_for_plan": 27, - "cost_for_plan": 11.42275391, + "cost_for_plan": 0.02463804, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -9966,7 +10411,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_4", "rows_for_plan": 9, - "cost_for_plan": 5.642626953, + "cost_for_plan": 0.022028022, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -9974,7 +10419,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": ["t_outer_1"], "table": "t_inner_3", "rows_for_plan": 27, - "cost_for_plan": 11.42275391, + "cost_for_plan": 0.02463804, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -9984,7 +10429,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_outer_2", "rows_for_plan": 9, - "cost_for_plan": 3.25769043, + "cost_for_plan": 0.011443245, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -9992,7 +10437,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_1", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -10000,7 +10445,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_2", "rows_for_plan": 9, - "cost_for_plan": 3.25769043, + "cost_for_plan": 0.011443245, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -10008,7 +10453,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_4", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "pruned_by_heuristic": true }, @@ -10016,7 +10461,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "plan_prefix": [], "table": "t_inner_3", "rows_for_plan": 9, - "cost_for_plan": 3.25769043, + "cost_for_plan": 0.011443245, "semijoin_strategy_choice": [], "pruned_by_heuristic": true } @@ -10051,12 +10496,12 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "best_join_order": [ "t_outer_1", - "t_outer_2", "", + "t_outer_2", "" ], "rows": 27, - "cost": 60.56826172 + "cost": 0.14187842 }, { "substitute_best_equal": { @@ -10076,10 +10521,6 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "table": "t_outer_1", "attached": null }, - { - "table": "t_outer_2", - "attached": null - }, { "table": "t_inner_1", "attached": null @@ -10092,6 +10533,10 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "table": "", "attached": null }, + { + "table": "t_outer_2", + "attached": null + }, { "table": "t_inner_4", "attached": null @@ -10160,7 +10605,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.745829876, + "cost": 0.001388369, "chosen": true } ], @@ -10189,7 +10634,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 107, - "cost": 24.68379668, + "cost": 0.016044989, "chosen": true } ], @@ -10221,7 +10666,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1000, - "cost": 756.2522431, + "cost": 1.235599899, "chosen": true } ], @@ -10261,7 +10706,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 4, - "cost": 3.523710032, + "cost": 0.006185575, "chosen": true } ], @@ -10295,7 +10740,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.271171589, + "cost": 0.002483968, "chosen": true } ], @@ -10324,7 +10769,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.271171589, + "cost": 0.002483968, "chosen": true } ], @@ -10361,7 +10806,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.270927508, + "cost": 0.002483968, "chosen": true } ], @@ -10391,7 +10836,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.270878692, + "cost": 0.002483968, "chosen": true } ], @@ -10421,7 +10866,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.270927508, + "cost": 0.002483968, "chosen": true } ], @@ -10454,7 +10899,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.270878692, + "cost": 0.002483968, "chosen": true } ], @@ -10490,7 +10935,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.319255553, + "cost": 0.002483968, "chosen": true } ], @@ -10509,7 +10954,7 @@ INSERT INTO t1 VALUES (2, 'ab\n'); set optimizer_trace=1; EXPLAIN SELECT * FROM t1 WHERE b='ab\n'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL i_b NULL NULL NULL 2 Using where +1 SIMPLE t1 ref i_b i_b 13 const 2 Using index condition select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) [ @@ -10524,9 +10969,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2, - "cost": 2.021855016, - "chosen": false, - "cause": "cost" + "cost": 0.003717837, + "chosen": true } ], "analyzing_roworder_intersect": @@ -10580,7 +11024,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1000, - "cost": 756.2522431, + "cost": 1.235599899, "chosen": true } ], @@ -10647,9 +11091,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "rows": 10, - "rows_after_scan": 5, "rows_after_filter": 5, - "cost": 3.508544922, + "rows_out": 5, + "cost": 0.01159965, "index_only": false, "chosen": true } @@ -10657,9 +11101,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "chosen_access_method": { "type": "scan", - "records_read": 5, - "records_out": 5, - "cost": 3.508544922, + "rows_read": 5, + "rows_out": 5, + "cost": 0.01159965, "uses_join_buffering": false } } @@ -10677,9 +11121,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "rows": 1000, - "rows_after_scan": 800, "rows_after_filter": 800, - "cost": 252.0986328, + "rows_out": 800, + "cost": 0.1669214, "index_only": false, "chosen": true } @@ -10687,9 +11131,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "chosen_access_method": { "type": "scan", - "records_read": 800, - "records_out": 800, - "cost": 252.0986328, + "rows_read": 800, + "rows_out": 800, + "cost": 0.1669214, "uses_join_buffering": false } } @@ -10701,7 +11145,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "A", "rows_for_plan": 5, - "cost_for_plan": 3.508544922, + "cost_for_plan": 0.01159965, "rest_of_plan": [ { @@ -10722,9 +11166,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "rows": 1000, - "rows_after_scan": 800, "rows_after_filter": 800, - "cost": 1260.493164, + "rows_out": 800, + "cost": 0.834607, "index_only": false, "chosen": true } @@ -10732,9 +11176,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "chosen_access_method": { "type": "scan", - "records_read": 800, - "records_out": 800, - "cost": 1260.493164, + "rows_read": 800, + "rows_out": 800, + "cost": 0.834607, "uses_join_buffering": false } } @@ -10746,7 +11190,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ["A"], "table": "B", "rows_for_plan": 4000, - "cost_for_plan": 1264.001709 + "cost_for_plan": 0.84620665 } ] }, @@ -10755,7 +11199,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "B", "rows_for_plan": 800, - "cost_for_plan": 252.0986328, + "cost_for_plan": 0.1669214, "pruned_by_heuristic": true } ] @@ -10788,9 +11232,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "rows": 10, - "rows_after_scan": 10, "rows_after_filter": 10, - "cost": 3.508544922, + "rows_out": 10, + "cost": 0.01159965, "index_only": false, "chosen": true } @@ -10798,9 +11242,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "chosen_access_method": { "type": "scan", - "records_read": 10, - "records_out": 10, - "cost": 3.508544922, + "rows_read": 10, + "rows_out": 10, + "cost": 0.01159965, "uses_join_buffering": false } } @@ -10818,9 +11262,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "rows": 1000, - "rows_after_scan": 800, "rows_after_filter": 800, - "cost": 252.0986328, + "rows_out": 800, + "cost": 0.1669214, "index_only": false, "chosen": true } @@ -10828,9 +11272,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "chosen_access_method": { "type": "scan", - "records_read": 800, - "records_out": 800, - "cost": 252.0986328, + "rows_read": 800, + "rows_out": 800, + "cost": 0.1669214, "uses_join_buffering": false } } @@ -10842,7 +11286,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "A", "rows_for_plan": 10, - "cost_for_plan": 3.508544922, + "cost_for_plan": 0.01159965, "rest_of_plan": [ { @@ -10866,25 +11310,21 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "used_range_estimates": false, "reason": "not available", "rows": 1, - "cost": 12.50585794, + "cost": 0.01810946, "chosen": true }, { - "access_type": "scan_with_join_cache", - "rows": 1000, - "rows_after_scan": 600, - "rows_after_filter": 600, - "cost": 1677.098633, - "index_only": false, - "chosen": false + "type": "scan", + "chosen": false, + "cause": "cost" } ], "chosen_access_method": { "type": "ref", - "records_read": 1, - "records_out": 1, - "cost": 12.50585794, + "rows_read": 1, + "rows_out": 1, + "cost": 0.01810946, "uses_join_buffering": false } } @@ -10896,7 +11336,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ["A"], "table": "B", "rows_for_plan": 10, - "cost_for_plan": 16.01440287, + "cost_for_plan": 0.02970911, + "pushdown_cond_selectivity": 0.8, + "filtered": 80, + "rows_out": 0.8, "selectivity": 0.8, "estimated_join_cardinality": 8 } @@ -10907,10 +11350,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "B", "rows_for_plan": 800, - "cost_for_plan": 252.0986328, + "cost_for_plan": 0.1669214, "pruned_by_cost": true, - "current_cost": 252.0986328, - "best_cost": 16.01450287 + "current_cost": 0.1669214, + "best_cost": 0.02970911 } ] ] @@ -10939,7 +11382,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.282887479, + "cost": 0.002483968, "chosen": true } ], @@ -10964,9 +11407,9 @@ insert into t3 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); explain select * from t3 where (a,a) in (select t1.a, t2.a from t1, t2 where t1.b=t2.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 5 -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where -1 PRIMARY t3 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 10 Using where +1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 Using where select JSON_DETAILED(JSON_EXTRACT(trace, '$**.semijoin_table_pullout')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; JSON_DETAILED(JSON_EXTRACT(trace, '$**.semijoin_table_pullout')) [ @@ -10999,7 +11442,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.745829876, + "cost": 0.001388369, "chosen": true } ] @@ -11039,9 +11482,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "rows": 10, - "rows_after_scan": 10, "rows_after_filter": 10, - "cost": 3.510986328, + "rows_out": 10, + "cost": 0.01159965, "index_only": false, "chosen": true } @@ -11049,9 +11492,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "chosen_access_method": { "type": "scan", - "records_read": 10, - "records_out": 10, - "cost": 3.510986328, + "rows_read": 10, + "rows_out": 10, + "cost": 0.01159965, "uses_join_buffering": false } } @@ -11069,9 +11512,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", "rows": 100, - "rows_after_scan": 100, "rows_after_filter": 100, - "cost": 26.10986328, + "rows_out": 100, + "cost": 0.0256761, "index_only": false, "chosen": true, "use_tmp_table": true @@ -11080,9 +11523,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "chosen_access_method": { "type": "scan", - "records_read": 100, - "records_out": 100, - "cost": 26.10986328, + "rows_read": 100, + "rows_out": 100, + "cost": 0.0256761, "uses_join_buffering": false } } @@ -11094,7 +11537,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "t1", "rows_for_plan": 10, - "cost_for_plan": 3.510986328, + "cost_for_plan": 0.01159965, "rest_of_plan": [ { @@ -11118,25 +11561,21 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "used_range_estimates": false, "reason": "not available", "rows": 1, - "cost": 12.50585794, + "cost": 0.01749506, "chosen": true }, { - "access_type": "scan_with_join_cache", - "rows": 100, - "rows_after_scan": 75, - "rows_after_filter": 75, - "cost": 204.2348633, - "index_only": false, - "chosen": false + "type": "scan", + "chosen": false, + "cause": "cost" } ], "chosen_access_method": { "type": "ref", - "records_read": 1, - "records_out": 1, - "cost": 12.50585794, + "rows_read": 1, + "rows_out": 1, + "cost": 0.01749506, "uses_join_buffering": false } } @@ -11148,8 +11587,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ["t1"], "table": "t2", "rows_for_plan": 10, - "cost_for_plan": 16.01684427, - "cost_for_sorting": 10 + "cost_for_plan": 0.02909471, + "cost_for_sorting": 0.006368384 } ] }, @@ -11158,10 +11597,75 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "t2", "rows_for_plan": 100, - "cost_for_plan": 26.10986328, - "pruned_by_cost": true, - "current_cost": 26.10986328, - "best_cost": 26.01694427 + "cost_for_plan": 0.0256761, + "rest_of_plan": + [ + + { + "plan_prefix": + [ + "t2" + ], + "get_costs_for_tables": + [ + + { + "best_access_path": + { + "table": "t1", + "plan_details": + { + "record_count": 100 + }, + "considered_access_paths": + [ + + { + "access_type": "ref", + "index": "a", + "used_range_estimates": false, + "reason": "not available", + "rows": 1, + "cost": 0.1731074, + "chosen": true + }, + + { + "access_type": "scan_with_join_cache", + "rows": 10, + "rows_after_filter": 10, + "rows_out": 1, + "cost": 0.11055225, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": + { + "type": "scan", + "rows_read": 10, + "rows_out": 1, + "cost": 0.11055225, + "uses_join_buffering": true + } + } + } + ] + }, + + { + "plan_prefix": + [ + "t2" + ], + "table": "t1", + "rows_for_plan": 100, + "cost_for_plan": 0.13622835, + "pruned_by_cost": true, + "current_cost": 0.13622835, + "best_cost": 0.035463094 + } + ] } ] ] @@ -11179,7 +11683,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * from t1 WHERE a between 1 and 5 and b <= 5; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 100 1.00 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 0.25 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` between 1 and 5 and `test`.`t1`.`b` <= 5 select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -11259,7 +11763,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) "using_mrr": false, "index_only": false, "rows": 0, - "cost": 0.52, + "cost": 0.001340684, "chosen": true } ] @@ -11361,8 +11865,8 @@ select count(*) from seq_1_to_10000000 { "table": "seq_1_to_10000000", "table_scan": { "rows": 10000000, - "read_cost": 5000000, - "read_and_compare_cost": 7250000 + "read_cost": 124.7880673, + "read_and_compare_cost": 444.7880673 } } ] @@ -11382,18 +11886,18 @@ select count(*) from seq_1_to_10000000 { { "access_type": "scan", "rows": 10000000, - "rows_after_scan": 10000000, "rows_after_filter": 10000000, - "cost": 7250000, + "rows_out": 10000000, + "cost": 444.7880673, "index_only": true, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 10000000, - "records_out": 10000000, - "cost": 7250000, + "rows_read": 10000000, + "rows_out": 10000000, + "cost": 444.7880673, "uses_join_buffering": false } } @@ -11404,14 +11908,14 @@ select count(*) from seq_1_to_10000000 { "plan_prefix": [], "table": "seq_1_to_10000000", "rows_for_plan": 10000000, - "cost_for_plan": 7250000 + "cost_for_plan": 444.7880673 } ] }, { "best_join_order": ["seq_1_to_10000000"], "rows": 10000000, - "cost": 7250000 + "cost": 444.7880673 }, { "attaching_conditions_to_tables": { @@ -11450,7 +11954,7 @@ explain select * from t1 left join (t2 join t3 on t3.pk=1000) on t2.a=t1.a and t2.pk is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 const PRIMARY NULL NULL NULL 1 Impossible ON condition -1 SIMPLE t2 const PRIMARY NULL NULL NULL 1 Impossible ON condition +1 SIMPLE t2 const PRIMARY NULL NULL NULL 0 Impossible ON condition 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 select JSON_DETAILED(JSON_EXTRACT(trace, '$**.mark_join_nest_as_const')) from information_schema.optimizer_trace; @@ -11771,7 +12275,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "used_range_estimates": false, "reason": "not available", "rows": 1.8367, - "cost": 1.417925794, + "cost": 0.0019606, "chosen": true }, { @@ -11783,9 +12287,9 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "chosen_access_method": { "type": "ref", - "records_read": 1.8367, - "records_out": 1.8367, - "cost": 1.417925794, + "rows_read": 1.8367, + "rows_out": 1.8367, + "cost": 0.0019606, "uses_join_buffering": false } } @@ -11797,19 +12301,25 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) [], "table": "t2", "rows_for_plan": 1.8367, - "cost_for_plan": 1.417925794, - "cost_for_sorting": 1.8367 + "cost_for_plan": 0.0019606, + "cost_for_sorting": 0.001155201 } ] }, { - "best_splitting": + "split_materialized": { "table": "t2", "key": "idx_a", - "record_count": 4, - "cost": 4.157170953, - "unsplit_cost": 60.1794762 + "org_cost": 0.0019606, + "postjoin_cost": 0.001135418, + "one_splitting_cost": 0.003096018, + "unsplit_postjoin_cost": 0.036032575, + "unsplit_cost": 0.060625425, + "rows": 1.8367, + "outer_rows": 4, + "total_splitting_cost": 0.012384072, + "chosen": true } } ] @@ -11819,13 +12329,7 @@ json_detailed(json_extract(trace, '$**.lateral_derived')) from information_schema.optimizer_trace; json_detailed(json_extract(trace, '$**.lateral_derived')) -[ - { - "startup_cost": 16.62868381, - "splitting_cost": 4.157170953, - "records": 1 - } -] +NULL drop table t1,t2; # # Test table functions. @@ -11881,7 +12385,6 @@ set @save_histogram_size= @@histogram_size; set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; set optimizer_switch='rowid_filter=on'; set use_stat_tables='preferably'; -set optimizer_use_condition_selectivity=4; set histogram_size=127; create table t1 (a int, b int, c int, key(a),key(b)); insert into t1 select seq, seq*2, seq/10 from seq_1_to_1000; @@ -11949,7 +12452,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "range_analysis": { "table_scan": { "rows": 1000, - "cost": 252.5869141 + "cost": 0.1671618 }, "potential_range_indexes": [ { @@ -11973,7 +12476,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "using_mrr": false, "index_only": false, "rows": 9, - "cost": 7.27527215, + "cost": 0.01235492, "chosen": true }, { @@ -11983,7 +12486,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "using_mrr": false, "index_only": false, "rows": 21, - "cost": 16.28230168, + "cost": 0.027161348, "chosen": false, "cause": "cost" } @@ -12005,7 +12508,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "ranges": ["(NULL) < (a) < (10)"] }, "rows_for_plan": 9, - "cost_for_plan": 7.27527215, + "cost_for_plan": 0.01235492, "chosen": true } } @@ -12015,12 +12518,12 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "rowid_filters": [ { "key": "a", - "build_cost": 0.759047172, + "build_cost": 9.95653e-5, "rows": 9 }, { "key": "b", - "build_cost": 1.122236655, + "build_cost": 3.004222e-4, "rows": 21 } ] @@ -12061,33 +12564,37 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "considered_access_paths": [ { "filter": { - "rowid_filter_key": "b", - "index_only_cost": 0.50527215, - "filter_startup_cost": 1.122236655, - "find_key_and_filter_lookup_cost": 0.386507019, + "rowid_filter_index": "b", + "index_only_cost": 0.001515222, + "filter_startup_cost": 3.004222e-4, + "find_key_and_filter_lookup_cost": 6.445451e-4, "filter_selectivity": 0.021, - "orginal_rows": 9, + "original_rows": 9, "new_rows": 0.189, - "original_found_rows_cost": 5.45527215, - "new_found_rows_cost": 1.381168455, - "cost": 2.54120511, + "original_access_cost": 0.011516778, + "with_filter_access_cost": 0.0023698, + "original_found_rows_cost": 0.010001556, + "with_filter_found_rows_cost": 2.100327e-4, + "org_cost": 0.011804778, + "filter_cost": 0.00267627, "filter_used": true }, "access_type": "range", + "range_index": "a", "rows": 9, - "rows_after_scan": 9, "rows_after_filter": 0.189, - "cost": 2.54120511, + "rows_out": 0.017766, + "cost": 0.00267627, "chosen": true } ], "chosen_access_method": { "type": "range", - "records_read": 9, - "records_out": 0.017766, - "cost": 2.54120511, + "rows_read": 0.189, + "rows_out": 0.017766, + "cost": 0.00267627, "uses_join_buffering": false, - "rowid_filter_key": "b" + "rowid_filter_index": "b" } } } @@ -12096,23 +12603,22 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { { "plan_prefix": [], "table": "t1", - "rows_for_plan": 9, - "cost_for_plan": 2.54120511 + "rows_for_plan": 0.017766, + "cost_for_plan": 0.00267627, + "pushdown_cond_selectivity": 0.094, + "filtered": 0.1974, + "rows_out": 0.017766 } ] }, { "best_join_order": ["t1"], - "rows": 9, - "cost": 2.54120511 + "rows": 0.017766, + "cost": 0.00267627 }, { "table": "t1", "range_analysis": { - "table_scan": { - "rows": 1000, - "cost": 1.79769e308 - }, "potential_range_indexes": [ { "index": "a", @@ -12135,7 +12641,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "using_mrr": false, "index_only": true, "rows": 21, - "cost": 5.257301684, + "cost": 0.004153769, "chosen": true } ] @@ -12148,7 +12654,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "ranges": ["(10) <= (b) <= (50)"] }, "rows_for_plan": 21, - "cost_for_plan": 5.257301684, + "cost_for_plan": 0.004153769, "chosen": true } } @@ -12190,6 +12696,7 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status Table is already up to date +set optimizer_use_condition_selectivity=2; explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and t1.c<1000; EXPLAIN { @@ -12223,13 +12730,47 @@ EXPLAIN "selectivity_pct": 43.12 }, "rows": 1000, - "filtered": 4.307688236, + "filtered": 43.11999893, "attached_condition": "t1.b < 5000 and t1.c < 1000" } } ] } } +set optimizer_use_condition_selectivity=4; +explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and t1.c<1000; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "three", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": ["a", "b"], + "rows": 10000, + "filtered": 4.307688236, + "attached_condition": "t1.b < 5000 and t1.c < 1000" + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "attached_condition": "t1.a = three.a" + } + } + ] + } +} QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and t1.c<1000 { "steps": [ @@ -12300,8 +12841,8 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "table": "three", "table_scan": { "rows": 3, - "read_cost": 1.002563477, - "read_and_compare_cost": 1.752563477 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } }, { @@ -12309,7 +12850,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "range_analysis": { "table_scan": { "rows": 10000, - "cost": 2516.869141 + "cost": 1.581538 }, "potential_range_indexes": [ { @@ -12333,7 +12874,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "using_mrr": false, "index_only": false, "rows": 4312, - "cost": 3260.045946, + "cost": 5.325058827, "chosen": false, "cause": "cost" } @@ -12354,7 +12895,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "rowid_filters": [ { "key": "b", - "build_cost": 174.2257513, + "build_cost": 0.149564727, "rows": 4312 } ] @@ -12392,18 +12933,18 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and { "access_type": "scan", "rows": 3, - "rows_after_scan": 3, "rows_after_filter": 3, - "cost": 1.752563477, + "rows_out": 3, + "cost": 0.010504815, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 3, - "records_out": 3, - "cost": 1.752563477, + "rows_read": 3, + "rows_out": 3, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -12418,18 +12959,18 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and { "access_type": "scan", "rows": 10000, - "rows_after_scan": 430.7688, "rows_after_filter": 430.7688, - "cost": 2516.869141, + "rows_out": 430.7688, + "cost": 1.581538, "index_only": false, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records_read": 430.7688, - "records_out": 430.7688, - "cost": 2516.869141, + "rows_read": 430.7688, + "rows_out": 430.7688, + "cost": 1.581538, "uses_join_buffering": false } } @@ -12440,7 +12981,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "plan_prefix": [], "table": "three", "rows_for_plan": 3, - "cost_for_plan": 1.752563477, + "cost_for_plan": 0.010504815, "rest_of_plan": [ { "plan_prefix": ["three"], @@ -12458,39 +12999,41 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "used_range_estimates": false, "reason": "not available", "filter": { - "rowid_filter_key": "b", - "index_only_cost": 2.585794484, - "filter_startup_cost": 174.2257513, - "find_key_and_filter_lookup_cost": 96.19157113, + "rowid_filter_index": "b", + "index_only_cost": 0.092006157, + "filter_startup_cost": 0.149564727, + "find_key_and_filter_lookup_cost": 0.085742374, "filter_selectivity": 0.4312, - "orginal_rows": 1000, + "original_rows": 1000, "new_rows": 431.2, - "original_found_rows_cost": 552.5857945, - "new_found_rows_cost": 335.9373656, - "cost": 1440.757848, + "original_access_cost": 1.203290157, + "with_filter_access_cost": 0.656934192, + "original_found_rows_cost": 1.111284, + "with_filter_found_rows_cost": 0.479185661, + "org_cost": 3.705870471, + "filter_cost": 2.161762502, "filter_used": true }, "rows": 431.2, - "cost": 1440.757848, + "cost": 2.161762502, "chosen": true }, { "access_type": "scan_with_join_cache", "rows": 10000, - "rows_after_scan": 323.0766, - "rows_after_filter": 323.0766, - "cost": 2747.061218, + "rows_after_filter": 430.7688, + "rows_out": 430.7688, + "cost": 1.701731924, "index_only": false, - "chosen": false + "chosen": true } ], "chosen_access_method": { - "type": "ref", - "records_read": 1000, - "records_out": 323.0766, - "cost": 1440.757848, - "uses_join_buffering": false, - "rowid_filter_key": "b" + "type": "scan", + "rows_read": 430.7688, + "rows_out": 430.7688, + "cost": 1.701731924, + "uses_join_buffering": true } } } @@ -12499,10 +13042,8 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and { "plan_prefix": ["three"], "table": "t1", - "rows_for_plan": 3000, - "cost_for_plan": 1442.510412, - "selectivity": 0.04307688, - "estimated_join_cardinality": 129.23064 + "rows_for_plan": 1292.3064, + "cost_for_plan": 1.712236739 } ] }, @@ -12510,64 +13051,15 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "plan_prefix": [], "table": "t1", "rows_for_plan": 430.7688, - "cost_for_plan": 2516.869141, - "pruned_by_cost": true, - "current_cost": 2516.869141, - "best_cost": 1442.510512 + "cost_for_plan": 1.581538, + "pruned_by_heuristic": true } ] }, { "best_join_order": ["three", "t1"], - "rows": 129.23064, - "cost": 1442.510412 - }, - { - "table": "t1", - "range_analysis": { - "table_scan": { - "rows": 10000, - "cost": 1.79769e308 - }, - "potential_range_indexes": [ - { - "index": "a", - "usable": false, - "cause": "not applicable" - }, - { - "index": "b", - "usable": true, - "key_parts": ["b"] - } - ], - "setup_range_conditions": [], - "analyzing_range_alternatives": { - "range_scan_alternatives": [ - { - "index": "b", - "ranges": ["(NULL) < (b) < (5000)"], - "rowid_ordered": false, - "using_mrr": false, - "index_only": true, - "rows": 4312, - "cost": 996.2459458, - "chosen": true - } - ] - }, - "chosen_range_access_summary": { - "range_access_plan": { - "type": "range_scan", - "index": "b", - "rows": 4312, - "ranges": ["(NULL) < (b) < (5000)"] - }, - "rows_for_plan": 4312, - "cost_for_plan": 996.2459458, - "chosen": true - } - } + "rows": 1292.3064, + "cost": 1.712236739 }, { "substitute_best_equal": { @@ -12577,15 +13069,64 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and }, { "attaching_conditions_to_tables": { - "attached_conditions_computation": [], + "attached_conditions_computation": [ + { + "table": "t1", + "range_analysis": { + "table_scan": { + "rows": 10000, + "cost": 1.581538 + }, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": ["a"] + }, + { + "index": "b", + "usable": true, + "key_parts": ["b"] + } + ], + "setup_range_conditions": [], + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a" + }, + { + "index": "b", + "ranges": ["(NULL) < (b) < (5000)"], + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 4312, + "cost": 5.325058827, + "chosen": false, + "cause": "cost" + } + ], + "analyzing_roworder_intersect": { + "cause": "too few roworder scans" + }, + "analyzing_index_merge_union": [] + }, + "group_index_range": { + "chosen": false, + "cause": "not single_table" + } + } + } + ], "attached_conditions_summary": [ { "table": "three", - "attached": "three.a is not null" + "attached": null }, { "table": "t1", - "attached": "t1.b < 5000 and t1.c < 1000" + "attached": "t1.a = three.a and t1.b < 5000 and t1.c < 1000" } ] } diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test index e9ff91dce43..29da64616de 100644 --- a/mysql-test/main/opt_trace.test +++ b/mysql-test/main/opt_trace.test @@ -85,23 +85,7 @@ drop table t1,t2,t0; --echo # group_by min max optimization --echo # CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a INT NOT NULL, KEY(a)); ---disable_query_log -INSERT INTO t1(a) VALUES (1), (2), (3), (4); -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; -INSERT INTO t1(a) SELECT a FROM t1; ---enable_query_log +insert into t1 select seq, mod(seq,4)+1 from seq_1_to_65536; analyze table t1; EXPLAIN SELECT DISTINCT a FROM t1; @@ -115,6 +99,7 @@ CREATE TABLE t1 (a INT, b INT, c int, d int, KEY(a,b,c,d)); INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (1,0,1,1), (3,2,3,3), (4,5,4,4); ANALYZE TABLE t1; EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a; +set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a; select * from information_schema.OPTIMIZER_TRACE; DROP TABLE t1; @@ -138,10 +123,6 @@ drop table t1; --echo # Late ORDER BY optimization --echo # -create table ten(a int); -insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table one_k(a int primary key); -insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C; create table t1 ( pk int not null, a int, @@ -153,18 +134,16 @@ create table t1 ( KEY a_b(a,b) ); -insert into t1 -select a, a,a,a, 'filler-dataaa' from test.one_k; +insert into t1 select seq, seq,seq,seq, 'filler-dataaa' from seq_0_to_999; update t1 set a=1 where pk between 0 and 180; update t1 set b=2 where pk between 0 and 20; analyze table t1; +explain select * from t1 where a=1 and b=2 order by c limit 1; +update t1 set b=2 where pk between 20 and 40; set optimizer_trace='enabled=on'; explain select * from t1 where a=1 and b=2 order by c limit 1; - -update t1 set b=2 where pk between 20 and 40; -explain select * from t1 where a=1 and b=2 order by c limit 1; select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; -drop table t1,ten,one_k; +drop table t1; --echo # --echo # TABLE ELIMINATION @@ -204,34 +183,23 @@ drop table t0, t1, t2, t3; --echo # IN subquery to sem-join is traced --echo # -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - create table t1(a int, b int); -insert into t1 values (0,0),(1,1),(2,2); -create table t2 as select * from t1; +insert into t1 select seq,seq from seq_0_to_3; -create table t11(a int, b int); - -create table t10 (pk int, a int); -insert into t10 select a,a from t0; -create table t12 like t10; -insert into t12 select * from t10; - -analyze table t1,t10; +create table t2 (p int, a int); +insert into t2 select seq,seq from seq_1_to_10; set optimizer_trace='enabled=on'; -explain extended select * from t1 where a in (select pk from t10); +explain extended select * from t1 where a in (select p from t2); +insert into t2 select seq,seq from seq_10_to_100; +explain extended select * from t1 where a in (select p from t2); select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; -drop table t0,t1,t11,t10,t12,t2; +drop table t1,t2; --echo # --echo # Selectivities for columns and indexes. --echo # -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - create table t1 ( pk int, a int, @@ -239,7 +207,7 @@ b int, key pk(pk), key pk_a(pk,a), key pk_a_b(pk,a,b)); -insert into t1 select a,a,a from t0; +insert into t1 select seq,seq,seq from seq_0_to_9; ANALYZE TABLE t1 PERSISTENT FOR COLUMNS (a,b) INDEXES (); set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; @@ -251,7 +219,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1; select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set @@use_stat_tables= @save_use_stat_tables; -drop table t0,t1; +drop table t1; set optimizer_trace="enabled=off"; --echo # @@ -942,7 +910,6 @@ set @save_histogram_size= @@histogram_size; set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; set optimizer_switch='rowid_filter=on'; set use_stat_tables='preferably'; -set optimizer_use_condition_selectivity=4; set histogram_size=127; create table t1 (a int, b int, c int, key(a),key(b)); insert into t1 select seq, seq*2, seq/10 from seq_1_to_1000; @@ -957,8 +924,12 @@ create table t1 (a int, b int, c int, key(a),key(b)); insert into t1 select mod(seq,10), seq, seq from seq_1_to_10000; analyze table t1; +set optimizer_use_condition_selectivity=2; +explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and t1.c<1000; +set optimizer_use_condition_selectivity=4; --optimizer_trace explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and t1.c<1000; + drop table three, t1; set @@optimizer_switch= @save_optimizer_switch; diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result index 7bf2a89705c..a042a621d91 100644 --- a/mysql-test/main/opt_trace_index_merge.result +++ b/mysql-test/main/opt_trace_index_merge.result @@ -73,7 +73,7 @@ explain select * from t1 where a=1 or b=1 { "range_analysis": { "table_scan": { "rows": 1000, - "cost": 264.7939453 + "cost": 0.1729314 }, "potential_range_indexes": [ { @@ -98,7 +98,9 @@ explain select * from t1 where a=1 or b=1 { "analyzing_roworder_intersect": { "cause": "too few roworder scans" }, - "analyzing_sort_intersect": {}, + "analyzing_sort_intersect": { + "cutoff_cost": 0.1729314 + }, "analyzing_index_merge_union": [ { "indexes_to_merge": [ @@ -111,12 +113,12 @@ explain select * from t1 where a=1 or b=1 { "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.745585794, + "cost": 0.001388369, "chosen": true } ], "index_to_merge": "a", - "cumulated_cost": 0.745585794 + "cumulated_cost": 0.001388369 }, { "range_scan_alternatives": [ @@ -127,15 +129,15 @@ explain select * from t1 where a=1 or b=1 { "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.745585794, + "cost": 0.001388369, "chosen": true } ], "index_to_merge": "b", - "cumulated_cost": 1.491171589 + "cumulated_cost": 0.002776738 } ], - "cost_of_reading_ranges": 1.491171589, + "cost_of_reading_ranges": 0.002776738, "use_roworder_union": true, "cause": "always cheaper than non roworder retrieval", "analyzing_roworder_scans": [ @@ -158,7 +160,7 @@ explain select * from t1 where a=1 or b=1 { } } ], - "index_roworder_union_cost": 2.601171589, + "index_roworder_union_cost": 0.005004612, "members": 2, "chosen": true } @@ -187,7 +189,7 @@ explain select * from t1 where a=1 or b=1 { ] }, "rows_for_plan": 2, - "cost_for_plan": 2.601171589, + "cost_for_plan": 0.005004612, "chosen": true } } @@ -218,17 +220,17 @@ explain select * from t1 where a=1 or b=1 { { "access_type": "index_merge", "rows": 2, - "rows_after_scan": 2, "rows_after_filter": 2, - "cost": 2.601171589, + "rows_out": 2, + "cost": 0.005004612, "chosen": true } ], "chosen_access_method": { "type": "index_merge", - "records_read": 2, - "records_out": 2, - "cost": 2.601171589, + "rows_read": 2, + "rows_out": 2, + "cost": 0.005004612, "uses_join_buffering": false } } @@ -239,14 +241,14 @@ explain select * from t1 where a=1 or b=1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 2, - "cost_for_plan": 2.601171589 + "cost_for_plan": 0.005004612 } ] }, { "best_join_order": ["t1"], "rows": 2, - "cost": 2.601171589 + "cost": 0.005004612 }, { "substitute_best_equal": { @@ -327,7 +329,7 @@ set optimizer_trace='enabled=on'; # 3-way ROR-intersection explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge key1,key2,key3 key1,key2 5,5 NULL 77 Using intersect(key1,key2); Using where +1 SIMPLE t1 ref|filter key1,key2,key3 key1|key2 5|5 const 2243 (3%) Using where; Using rowid filter select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) [ @@ -342,7 +344,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2243, - "cost": 1695.083937, + "cost": 2.770260666, "chosen": true }, { @@ -353,7 +355,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2243, - "cost": 1695.083937, + "cost": 2.770260666, "chosen": false, "cause": "cost" }, @@ -365,7 +367,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2243, - "cost": 1695.083937, + "cost": 2.770260666, "chosen": false, "cause": "cost" } @@ -376,10 +378,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) [ { "index": "key1", - "index_scan_cost": 61.88893703, - "cumulated_index_scan_cost": 61.88893703, - "disk_sweep_cost": 1682.25, - "cumulative_total_cost": 1744.138937, + "index_scan_cost": 0.240986767, + "cumulated_index_scan_cost": 0.240986767, + "disk_sweep_cost": 2.564386012, + "cumulative_total_cost": 2.805372779, "usable": true, "matching_rows_now": 2243, "intersect_covering_with_this_index": false, @@ -387,10 +389,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) }, { "index": "key2", - "index_scan_cost": 61.88893703, - "cumulated_index_scan_cost": 123.7778741, - "disk_sweep_cost": 57.75, - "cumulative_total_cost": 181.5278741, + "index_scan_cost": 0.240986767, + "cumulated_index_scan_cost": 0.481973534, + "disk_sweep_cost": 0.088032868, + "cumulative_total_cost": 0.570006402, "usable": true, "matching_rows_now": 77.6360508, "intersect_covering_with_this_index": false, @@ -398,10 +400,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) }, { "index": "key3", - "index_scan_cost": 61.88893703, - "cumulated_index_scan_cost": 185.6668111, + "index_scan_cost": 0.240986767, + "cumulated_index_scan_cost": 0.722960301, "disk_sweep_cost": 0, - "cumulative_total_cost": 185.6668111, + "cumulative_total_cost": 0.722960301, "usable": true, "matching_rows_now": 2.687185191, "intersect_covering_with_this_index": true, @@ -415,12 +417,32 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "cause": "no clustered pk index" }, "rows": 77, - "cost": 197.0550842, + "cost": 0.572490756, "covering": false, "chosen": true }, "analyzing_index_merge_union": [] + }, + + { + "range_scan_alternatives": + [ + + { + "index": "key2", + "ranges": + [ + "(100) <= (key2) <= (100)" + ], + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 2243, + "cost": 0.312832109, + "chosen": true + } + ] } ] select JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -431,7 +453,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) { "type": "index_roworder_intersect", "rows": 77, - "cost": 197.0550842, + "cost": 0.572490756, "covering": false, "clustered_pk_scan": false, "intersect_of": @@ -453,7 +475,23 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) ] }, "rows_for_plan": 77, - "cost_for_plan": 197.0550842, + "cost_for_plan": 0.572490756, + "chosen": true + }, + + { + "range_access_plan": + { + "type": "range_scan", + "index": "key2", + "rows": 2243, + "ranges": + [ + "(100) <= (key2) <= (100)" + ] + }, + "rows_for_plan": 2243, + "cost_for_plan": 0.312832109, "chosen": true } ] @@ -487,7 +525,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 517.508937, + "cost": 0.312832109, "chosen": true }, { @@ -498,13 +536,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 517.508937, + "cost": 0.312832109, "chosen": false, "cause": "cost" } ], "index_to_merge": "key1", - "cumulated_cost": 517.508937 + "cumulated_cost": 0.312832109 }, { "range_scan_alternatives": @@ -517,7 +555,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 517.508937, + "cost": 0.312832109, "chosen": true }, { @@ -528,16 +566,16 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 517.508937, + "cost": 0.312832109, "chosen": false, "cause": "cost" } ], "index_to_merge": "key3", - "cumulated_cost": 1035.017874 + "cumulated_cost": 0.625664218 } ], - "cost_of_reading_ranges": 1035.017874, + "cost_of_reading_ranges": 0.625664218, "use_roworder_union": true, "cause": "always cheaper than non roworder retrieval", "analyzing_roworder_scans": @@ -554,10 +592,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) [ { "index": "key1", - "index_scan_cost": 61.88893703, - "cumulated_index_scan_cost": 61.88893703, - "disk_sweep_cost": 1682.25, - "cumulative_total_cost": 1744.138937, + "index_scan_cost": 0.240986767, + "cumulated_index_scan_cost": 0.240986767, + "disk_sweep_cost": 2.564386012, + "cumulative_total_cost": 2.805372779, "usable": true, "matching_rows_now": 2243, "intersect_covering_with_this_index": false, @@ -565,10 +603,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) }, { "index": "key2", - "index_scan_cost": 61.88893703, - "cumulated_index_scan_cost": 123.7778741, - "disk_sweep_cost": 57.75, - "cumulative_total_cost": 181.5278741, + "index_scan_cost": 0.240986767, + "cumulated_index_scan_cost": 0.481973534, + "disk_sweep_cost": 0.088032868, + "cumulative_total_cost": 0.570006402, "usable": true, "matching_rows_now": 77.6360508, "intersect_covering_with_this_index": false, @@ -581,7 +619,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "cause": "no clustered pk index" }, "rows": 77, - "cost": 197.0550842, + "cost": 0.572490756, "covering": false, "chosen": true } @@ -598,10 +636,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) [ { "index": "key3", - "index_scan_cost": 61.88893703, - "cumulated_index_scan_cost": 61.88893703, - "disk_sweep_cost": 1682.25, - "cumulative_total_cost": 1744.138937, + "index_scan_cost": 0.240986767, + "cumulated_index_scan_cost": 0.240986767, + "disk_sweep_cost": 2.564386012, + "cumulative_total_cost": 2.805372779, "usable": true, "matching_rows_now": 2243, "intersect_covering_with_this_index": false, @@ -609,10 +647,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) }, { "index": "key4", - "index_scan_cost": 61.88893703, - "cumulated_index_scan_cost": 123.7778741, - "disk_sweep_cost": 57.75, - "cumulative_total_cost": 181.5278741, + "index_scan_cost": 0.240986767, + "cumulated_index_scan_cost": 0.481973534, + "disk_sweep_cost": 0.088032868, + "cumulative_total_cost": 0.570006402, "usable": true, "matching_rows_now": 77.6360508, "intersect_covering_with_this_index": false, @@ -625,13 +663,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "cause": "no clustered pk index" }, "rows": 77, - "cost": 197.0550842, + "cost": 0.572490756, "covering": false, "chosen": true } } ], - "index_roworder_union_cost": 333.0257481, + "index_roworder_union_cost": 1.135493366, "members": 2, "chosen": true } @@ -650,7 +688,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) { "type": "index_roworder_intersect", "rows": 77, - "cost": 197.0550842, + "cost": 0.572490756, "covering": false, "clustered_pk_scan": false, "intersect_of": @@ -674,7 +712,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) { "type": "index_roworder_intersect", "rows": 77, - "cost": 197.0550842, + "cost": 0.572490756, "covering": false, "clustered_pk_scan": false, "intersect_of": @@ -698,7 +736,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) ] }, "rows_for_plan": 154, - "cost_for_plan": 333.0257481, + "cost_for_plan": 1.135493366, "chosen": true } ] diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result index d0a4f7cd24b..0b0f6f0d2fc 100644 --- a/mysql-test/main/opt_trace_index_merge_innodb.result +++ b/mysql-test/main/opt_trace_index_merge_innodb.result @@ -89,7 +89,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "range_analysis": { "table_scan": { "rows": 1000, - "cost": 253 + "cost": 0.1764192 }, "potential_range_indexes": [ { @@ -118,8 +118,9 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "using_mrr": false, "index_only": false, "rows": 1000, - "cost": 252.02, - "chosen": true + "cost": 0.19579056, + "chosen": false, + "cause": "cost" }, { "index": "key1", @@ -128,7 +129,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "using_mrr": false, "index_only": false, "rows": 1, - "cost": 1.270146475, + "cost": 0.00415068, "chosen": true } ], @@ -136,10 +137,10 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "intersecting_indexes": [ { "index": "key1", - "index_scan_cost": 0.525146475, - "cumulated_index_scan_cost": 0.525146475, - "disk_sweep_cost": 0.752076843, - "cumulative_total_cost": 1.277223319, + "index_scan_cost": 0.001661605, + "cumulated_index_scan_cost": 0.001661605, + "disk_sweep_cost": 0.00171364, + "cumulative_total_cost": 0.003375245, "usable": true, "matching_rows_now": 1, "intersect_covering_with_this_index": false, @@ -151,7 +152,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "cause": "cost" }, "chosen": false, - "cause": "cost" + "cause": "too few indexes to merge" }, "analyzing_index_merge_union": [] }, @@ -167,7 +168,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "ranges": ["(1) <= (key1) <= (1)"] }, "rows_for_plan": 1, - "cost_for_plan": 1.270146475, + "cost_for_plan": 0.00415068, "chosen": true } } @@ -177,7 +178,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "rowid_filters": [ { "key": "key1", - "build_cost": 0.526146475, + "build_cost": 0.000002653, "rows": 1 } ] @@ -215,7 +216,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "index": "key1", "used_range_estimates": true, "rows": 1, - "cost": 1.250146475, + "cost": 0.00335956, "chosen": true }, { @@ -226,9 +227,9 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { ], "chosen_access_method": { "type": "ref", - "records_read": 1, - "records_out": 1, - "cost": 1.250146475, + "rows_read": 1, + "rows_out": 1, + "cost": 0.00335956, "uses_join_buffering": false } } @@ -239,14 +240,14 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 1.250146475 + "cost_for_plan": 0.00335956 } ] }, { "best_join_order": ["t1"], "rows": 1, - "cost": 1.250146475 + "cost": 0.00335956 }, { "substitute_best_equal": { diff --git a/mysql-test/main/opt_trace_security.result b/mysql-test/main/opt_trace_security.result index f440aa381c3..d1b6900bddb 100644 --- a/mysql-test/main/opt_trace_security.result +++ b/mysql-test/main/opt_trace_security.result @@ -80,8 +80,8 @@ select * from db1.t1 { "table": "t1", "table_scan": { "rows": 3, - "read_cost": 0.010373215, - "read_and_compare_cost": 0.010469215 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } } ] @@ -103,7 +103,7 @@ select * from db1.t1 { "rows": 3, "rows_after_filter": 3, "rows_out": 3, - "cost": 0.010469215, + "cost": 0.010504815, "index_only": false, "chosen": true } @@ -112,7 +112,7 @@ select * from db1.t1 { "type": "scan", "rows_read": 3, "rows_out": 3, - "cost": 0.010469215, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -123,14 +123,14 @@ select * from db1.t1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 0.010469215 + "cost_for_plan": 0.010504815 } ] }, { "best_join_order": ["t1"], "rows": 3, - "cost": 0.010469215 + "cost": 0.010504815 }, { "attaching_conditions_to_tables": { @@ -219,8 +219,8 @@ select * from db1.v1 { "table": "t1", "table_scan": { "rows": 3, - "read_cost": 0.010373215, - "read_and_compare_cost": 0.010469215 + "read_cost": 0.010408815, + "read_and_compare_cost": 0.010504815 } } ] @@ -242,7 +242,7 @@ select * from db1.v1 { "rows": 3, "rows_after_filter": 3, "rows_out": 3, - "cost": 0.010469215, + "cost": 0.010504815, "index_only": false, "chosen": true } @@ -251,7 +251,7 @@ select * from db1.v1 { "type": "scan", "rows_read": 3, "rows_out": 3, - "cost": 0.010469215, + "cost": 0.010504815, "uses_join_buffering": false } } @@ -262,14 +262,14 @@ select * from db1.v1 { "plan_prefix": [], "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 0.010469215 + "cost_for_plan": 0.010504815 } ] }, { "best_join_order": ["t1"], "rows": 3, - "cost": 0.010469215 + "cost": 0.010504815 }, { "attaching_conditions_to_tables": { diff --git a/mysql-test/main/opt_trace_selectivity.result b/mysql-test/main/opt_trace_selectivity.result index bef3d62b0ce..60c0acc7216 100644 --- a/mysql-test/main/opt_trace_selectivity.result +++ b/mysql-test/main/opt_trace_selectivity.result @@ -53,7 +53,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "a", "used_range_estimates": true, "rows": 104, - "cost": 78.54062004, + "cost": 0.060906438, "chosen": true }, { @@ -61,7 +61,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "b", "used_range_estimates": true, "rows": 340, - "cost": 255.6327963, + "cost": 0.14153631, "chosen": false, "cause": "cost" }, @@ -70,25 +70,25 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "c", "used_range_estimates": true, "rows": 632, - "cost": 475.2468449, + "cost": 0.241743894, "chosen": false, "cause": "cost" }, { "access_type": "index_merge", "rows": 7, - "rows_after_scan": 7, "rows_after_filter": 7, - "cost": 13.79559815, + "rows_out": 7, + "cost": 0.045367017, "chosen": true } ], "chosen_access_method": { "type": "index_merge", - "records_read": 7, - "records_out": 7, - "cost": 13.79559815, + "rows_read": 7, + "rows_out": 7, + "cost": 0.045367017, "uses_join_buffering": false } } @@ -100,7 +100,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [], "table": "t1", "rows_for_plan": 7, - "cost_for_plan": 13.79559815 + "cost_for_plan": 0.045367017 } ] ] @@ -148,7 +148,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "a", "used_range_estimates": true, "rows": 6, - "cost": 5.002343464, + "cost": 0.005306142, "chosen": true }, { @@ -156,7 +156,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "b", "used_range_estimates": true, "rows": 232, - "cost": 174.5906139, + "cost": 0.104637894, "chosen": false, "cause": "cost" }, @@ -165,7 +165,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "c", "used_range_estimates": true, "rows": 293, - "cost": 220.3644392, + "cost": 0.125478666, "chosen": false, "cause": "cost" }, @@ -178,9 +178,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "chosen_access_method": { "type": "ref", - "records_read": 6, - "records_out": 0.6, - "cost": 5.002343464, + "rows_read": 6, + "rows_out": 0.6, + "cost": 0.005306142, "uses_join_buffering": false } } @@ -191,10 +191,11 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "plan_prefix": [], "table": "t1", - "rows_for_plan": 6, - "cost_for_plan": 5.002343464, - "selectivity": 0.1, - "estimated_join_cardinality": 0.6 + "rows_for_plan": 0.6, + "cost_for_plan": 0.005306142, + "pushdown_cond_selectivity": 0.1, + "filtered": 10, + "rows_out": 0.6 } ] ] diff --git a/mysql-test/main/opt_tvc.result b/mysql-test/main/opt_tvc.result index 8ec88f49997..c08c68eb7ee 100644 --- a/mysql-test/main/opt_tvc.result +++ b/mysql-test/main/opt_tvc.result @@ -530,11 +530,11 @@ a b 4 yq explain extended select * from t3 where a in (1,4); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY ALL NULL NULL NULL NULL 2 100.00 -1 PRIMARY t3 ref idx idx 5 tvc_0._col_1 3 100.00 +1 PRIMARY t3 ALL idx NULL NULL NULL 28 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t3.a 1 100.00 3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from (values (1),(4)) `tvc_0` join `test`.`t3` where `test`.`t3`.`a` = `tvc_0`.`_col_1` +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from (values (1),(4)) `tvc_0` join `test`.`t3` where `tvc_0`.`_col_1` = `test`.`t3`.`a` # use vectors in IN predeicate set @@in_predicate_conversion_threshold= 4; select * from t1 where (a,b) in ((1,2),(3,4)); diff --git a/mysql-test/main/optimizer_costs.result b/mysql-test/main/optimizer_costs.result new file mode 100644 index 00000000000..a00673df02c --- /dev/null +++ b/mysql-test/main/optimizer_costs.result @@ -0,0 +1,347 @@ +select table_name,engine from information_schema.tables where table_name="optimizer_costs"; +table_name engine +OPTIMIZER_COSTS MEMORY +show create table information_schema.optimizer_costs; +Table Create Table +OPTIMIZER_COSTS CREATE TEMPORARY TABLE `OPTIMIZER_COSTS` ( + `ENGINE` varchar(192) NOT NULL, + `OPTIMIZER_DISK_READ_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_INDEX_BLOCK_COPY_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_KEY_COMPARE_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_KEY_COPY_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_KEY_LOOKUP_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_KEY_NEXT_FIND_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_DISK_READ_RATIO` decimal(9,6) NOT NULL, + `OPTIMIZER_ROW_COPY_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_ROW_LOOKUP_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_ROW_NEXT_FIND_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_ROWID_COMPARE_COST` decimal(9,6) NOT NULL, + `OPTIMIZER_ROWID_COPY_COST` decimal(9,6) NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci +select * from information_schema.optimizer_costs where engine in +("memory","innodb","aria","default") order by engine; +ENGINE Aria +OPTIMIZER_DISK_READ_COST 10.240000 +OPTIMIZER_INDEX_BLOCK_COPY_COST 0.035600 +OPTIMIZER_KEY_COMPARE_COST 0.011361 +OPTIMIZER_KEY_COPY_COST 0.015685 +OPTIMIZER_KEY_LOOKUP_COST 0.435777 +OPTIMIZER_KEY_NEXT_FIND_COST 0.082347 +OPTIMIZER_DISK_READ_RATIO 0.020000 +OPTIMIZER_ROW_COPY_COST 0.060866 +OPTIMIZER_ROW_LOOKUP_COST 0.130839 +OPTIMIZER_ROW_NEXT_FIND_COST 0.045916 +OPTIMIZER_ROWID_COMPARE_COST 0.001000 +OPTIMIZER_ROWID_COPY_COST 0.001000 +ENGINE default +OPTIMIZER_DISK_READ_COST 10.240000 +OPTIMIZER_INDEX_BLOCK_COPY_COST 0.035600 +OPTIMIZER_KEY_COMPARE_COST 0.011361 +OPTIMIZER_KEY_COPY_COST 0.015685 +OPTIMIZER_KEY_LOOKUP_COST 0.435777 +OPTIMIZER_KEY_NEXT_FIND_COST 0.082347 +OPTIMIZER_DISK_READ_RATIO 0.020000 +OPTIMIZER_ROW_COPY_COST 0.060866 +OPTIMIZER_ROW_LOOKUP_COST 0.130839 +OPTIMIZER_ROW_NEXT_FIND_COST 0.045916 +OPTIMIZER_ROWID_COMPARE_COST 0.002653 +OPTIMIZER_ROWID_COPY_COST 0.002653 +ENGINE InnoDB +OPTIMIZER_DISK_READ_COST 10.240000 +OPTIMIZER_INDEX_BLOCK_COPY_COST 0.035600 +OPTIMIZER_KEY_COMPARE_COST 0.011361 +OPTIMIZER_KEY_COPY_COST 0.015685 +OPTIMIZER_KEY_LOOKUP_COST 0.791120 +OPTIMIZER_KEY_NEXT_FIND_COST 0.099000 +OPTIMIZER_DISK_READ_RATIO 0.020000 +OPTIMIZER_ROW_COPY_COST 0.060870 +OPTIMIZER_ROW_LOOKUP_COST 0.765970 +OPTIMIZER_ROW_NEXT_FIND_COST 0.070130 +OPTIMIZER_ROWID_COMPARE_COST 0.002653 +OPTIMIZER_ROWID_COPY_COST 0.002653 +ENGINE MEMORY +OPTIMIZER_DISK_READ_COST 0.000000 +OPTIMIZER_INDEX_BLOCK_COPY_COST 0.000000 +OPTIMIZER_KEY_COMPARE_COST 0.011361 +OPTIMIZER_KEY_COPY_COST 0.000000 +OPTIMIZER_KEY_LOOKUP_COST 0.000000 +OPTIMIZER_KEY_NEXT_FIND_COST 0.000000 +OPTIMIZER_DISK_READ_RATIO 0.000000 +OPTIMIZER_ROW_COPY_COST 0.002334 +OPTIMIZER_ROW_LOOKUP_COST 0.000000 +OPTIMIZER_ROW_NEXT_FIND_COST 0.000000 +OPTIMIZER_ROWID_COMPARE_COST 0.002653 +OPTIMIZER_ROWID_COPY_COST 0.002653 +show variables like "optimizer%cost"; +Variable_name Value +optimizer_disk_read_cost 10.240000 +optimizer_index_block_copy_cost 0.035600 +optimizer_key_compare_cost 0.011361 +optimizer_key_copy_cost 0.015685 +optimizer_key_lookup_cost 0.435777 +optimizer_key_next_find_cost 0.082347 +optimizer_row_copy_cost 0.060866 +optimizer_row_lookup_cost 0.130839 +optimizer_row_next_find_cost 0.045916 +optimizer_rowid_compare_cost 0.002653 +optimizer_rowid_copy_cost 0.002653 +optimizer_scan_setup_cost 10.000000 +optimizer_where_cost 0.032000 +show variables like "optimizer_disk_read_ratio"; +Variable_name Value +optimizer_disk_read_ratio 0.020000 +# +# Test change some 'default' variables +# +SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost; +@@optimizer_disk_read_ratio @@optimizer_index_block_copy_cost +0.020000 0.035600 +SET global optimizer_disk_read_ratio=0.8; +SET global optimizer_index_block_copy_cost=0.1; +SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost; +@@optimizer_disk_read_ratio @@optimizer_index_block_copy_cost +0.800000 0.100000 +select optimizer_disk_read_ratio,optimizer_index_block_copy_cost from information_schema.optimizer_costs where engine='default'; +optimizer_disk_read_ratio optimizer_index_block_copy_cost +0.800000 0.100000 +SET global optimizer_disk_read_ratio=default; +SET global optimizer_index_block_copy_cost=default; +SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost; +@@optimizer_disk_read_ratio @@optimizer_index_block_copy_cost +0.020000 0.035600 +# +# Test change some 'engine' variables +# +select @@MEMORY.optimizer_row_lookup_cost; +@@MEMORY.optimizer_row_lookup_cost +0.000000 +set @tmp=@@MEMORY.optimizer_row_lookup_cost; +set @@global.MEMORY.optimizer_row_lookup_cost=1; +select @@MEMORY.optimizer_row_lookup_cost; +@@MEMORY.optimizer_row_lookup_cost +1.000000 +set @@global.MEMORY.optimizer_row_lookup_cost=default; +select @@MEMORY.optimizer_row_lookup_cost; +@@MEMORY.optimizer_row_lookup_cost +0.130839 +set @@global.MEMORY.optimizer_row_lookup_cost=@tmp; +select @@MEMORY.optimizer_row_lookup_cost; +@@MEMORY.optimizer_row_lookup_cost +0.000000 +# +# Print variables with different syntaxes +# +SHOW VARIABLES like "optimizer_row_lookup_cost"; +Variable_name Value +optimizer_row_lookup_cost 0.130839 +SELECT @@optimizer_row_lookup_cost; +@@optimizer_row_lookup_cost +0.130839 +SELECT @@global.default.optimizer_row_lookup_cost; +@@global.default.optimizer_row_lookup_cost +0.130839 +SELECT @@global.default.`optimizer_row_lookup_cost`; +@@global.default.`optimizer_row_lookup_cost` +0.130839 +SELECT @@MEMORY.optimizer_row_lookup_cost; +@@MEMORY.optimizer_row_lookup_cost +0.000000 +SELECT @@memory.optimizer_row_lookup_cost; +@@memory.optimizer_row_lookup_cost +0.000000 +SELECT @@InnoDB.optimizer_row_lookup_cost; +@@InnoDB.optimizer_row_lookup_cost +0.765970 +# +# Accessing not existing cost +# +SELECT @@not_existing.optimizer_row_lookup_cost; +@@not_existing.optimizer_row_lookup_cost +0.130839 +SELECT @@NOT_existing.optimizer_row_lookup_cost; +@@NOT_existing.optimizer_row_lookup_cost +0.130839 +select engine from information_schema.optimizer_costs where engine like '%existing'; +engine +# +# Creating a new cost structure +# +SET global new_engine.optimizer_disk_read_cost=100; +select * from information_schema.optimizer_costs where engine like 'new_engine'; +ENGINE OPTIMIZER_DISK_READ_COST OPTIMIZER_INDEX_BLOCK_COPY_COST OPTIMIZER_KEY_COMPARE_COST OPTIMIZER_KEY_COPY_COST OPTIMIZER_KEY_LOOKUP_COST OPTIMIZER_KEY_NEXT_FIND_COST OPTIMIZER_DISK_READ_RATIO OPTIMIZER_ROW_COPY_COST OPTIMIZER_ROW_LOOKUP_COST OPTIMIZER_ROW_NEXT_FIND_COST OPTIMIZER_ROWID_COMPARE_COST OPTIMIZER_ROWID_COPY_COST +new_engine 100.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 +select @@new_engine.optimizer_disk_read_cost, @@new_engine.optimizer_row_copy_cost; +@@new_engine.optimizer_disk_read_cost @@new_engine.optimizer_row_copy_cost +100.000000 -1.000000 +# +# Errors +# +SELECT @@default.optimizer_disk_read_cost; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'default.optimizer_disk_read_cost' at line 1 +set global Aria.optimizer_disk_read_cost=NULL; +ERROR 42000: Incorrect argument type to variable 'optimizer_disk_read_cost' +set @tmp=@@Aria.optimizer_disk_read_cost; +SET global Aria.optimizer_disk_read_cost=-1; +Warnings: +Warning 1292 Truncated incorrect optimizer_disk_read_cost value: '-1' +select @@Aria.optimizer_disk_read_cost; +@@Aria.optimizer_disk_read_cost +0.000000 +SET global Aria.optimizer_disk_read_cost=200000; +Warnings: +Warning 1292 Truncated incorrect optimizer_disk_read_cost value: '200000' +select @@Aria.optimizer_disk_read_cost; +@@Aria.optimizer_disk_read_cost +10000.000000 +set global Aria.optimizer_disk_read_cost=@tmp; +select @@Aria.optimizer_disk_read_cost; +@@Aria.optimizer_disk_read_cost +10.240000 +# +# Test of cost of ref compared to table scan + join_cache +# +create or replace table t1 (p int primary key, a char(10)) engine=myisam; +create or replace table t2 (p int primary key, i int, a char(10), key k2(a)) engine=myisam; +insert into t2 select seq,seq,'a' from seq_1_to_512; +insert into t1 select seq,'a' from seq_1_to_4; +explain select count(*) from t1, t2 where t1.p = t2.i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index +1 SIMPLE t2 ALL NULL NULL NULL NULL 512 Using where; Using join buffer (flat, BNL join) +insert into t1 select seq,'a' from seq_5_to_10; +explain select count(*) from t1, t2 where t1.p = t2.i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 512 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.i 1 Using index +drop table t1,t2; +# +# Test of optimizer_scan_setup_cost +# +create table t1 (p int primary key, a char(10)) engine=myisam; +create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)) engine=myisam; +insert into t1 values (2, 'qqqq'), (11, 'yyyy'); +insert into t2 values (1, 2, 'qqqq'), (2, 2, 'pppp'), +(3, 2, 'yyyy'), (4, 3, 'zzzz'); +set @org_myisam_disk_read_ratio=@@myisam.optimizer_disk_read_ratio; +set @@optimizer_scan_setup_cost=10,@@global.myisam.optimizer_disk_read_ratio=0.2; +flush tables; +explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 +1 SIMPLE t2 ref k1 k1 5 test.t1.p 2 +set @@optimizer_scan_setup_cost=0.0, @@global.myisam.optimizer_disk_read_ratio=0.0; +flush tables; +explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 +1 SIMPLE t2 ALL k1 NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +set @@optimizer_scan_setup_cost=default,@@global.myisam.optimizer_disk_read_ratio=@org_myisam_disk_read_ratio; +flush tables; +drop table t1,t2; +# +# Test of group by optimization +# +set @@optimizer_scan_setup_cost=0; +CREATE TABLE t1 (id INT NOT NULL, a DATE, KEY(id,a)) engine=myisam; +INSERT INTO t1 values (1,'2001-01-01'),(1,'2001-01-02'), +(1,'2001-01-03'),(1,'2001-01-04'), +(2,'2001-01-01'),(2,'2001-01-02'), +(2,'2001-01-03'),(2,'2001-01-04'), +(3,'2001-01-01'),(3,'2001-01-02'), +(3,'2001-01-03'),(3,'2001-01-04'), +(4,'2001-01-01'),(4,'2001-01-02'), +(4,'2001-01-03'),(4,'2001-01-04'); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL id 8 NULL 16 Using where; Using index +insert into t1 values (3,'2001-01-03'),(3,'2001-01-04'); +insert into t1 values (3,'2001-01-03'),(3,'2001-01-04'); +insert into t1 values (3,'2001-01-03'),(3,'2001-01-04'); +insert into t1 values (3,'2001-01-03'),(3,'2001-01-04'); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL id 8 NULL 5 Using where; Using index for group-by +drop table t1; +set @@optimizer_scan_setup_cost=default; +# +# Test of straight join costs +# +create table t1 (l_orderkey int(11) NOT NULL, +l_partkey int(11) DEFAULT NULL, +l_suppkey int(11) DEFAULT NULL, +PRIMARY KEY (l_orderkey)) engine=aria; +insert into t1 select seq,seq,seq from seq_1_to_1000; +explain select straight_join count(*) from seq_1_to_10000,t1 where seq=l_orderkey; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE seq_1_to_10000 index PRIMARY PRIMARY 8 NULL 10000 Using index +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.seq_1_to_10000.seq 1 Using where; Using index +show status like "last_query_cost"; +Variable_name Value +Last_query_cost 5.641229 +set @org_cost=@@aria.optimizer_key_next_find_cost; +set global aria.optimizer_key_next_find_cost=1000; +flush tables; +explain select count(*) from seq_1_to_10000,t1 where seq=l_orderkey; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE seq_1_to_10000 index PRIMARY PRIMARY 8 NULL 10000 Using index +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.seq_1_to_10000.seq 1 Using where; Using index +show status like "last_query_cost"; +Variable_name Value +Last_query_cost 5.641229 +set global aria.optimizer_key_next_find_cost=@org_cost; +drop table t1; +# +# Testing distinct group optimization +# +create table t1 (a int, b int, key(a,b)); +insert into t1 select seq,seq from seq_1_to_1000; +explain select count(distinct a,b) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL a 10 NULL 1000 Using index for group-by (scanning) +explain select count(distinct a,b) from t1 where a>100; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 10 NULL 901 Using where; Using index for group-by (scanning) +explain select count(distinct a,b) from t1 where a>800; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 206 Using where; Using index +update t1 set a=mod(a,10); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +explain select count(distinct a,b) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL a 10 NULL 1000 Using index for group-by (scanning) +explain select count(distinct a,b) from t1 where a>1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 10 NULL 788 Using where; Using index for group-by (scanning) +explain select count(distinct a,b) from t1 where a>8; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 109 Using where; Using index +update t1 set b=mod(b,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +explain select count(distinct a,b) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL a 10 NULL 11 Using index for group-by +explain select count(distinct a,b) from t1 where a>1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 10 NULL 9 Using where; Using index for group-by +explain select count(distinct a,b) from t1 where a>8; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 10 NULL 1 Using where; Using index for group-by +drop table t1; +# +# cleanup +# +Start_engines: 9 End_engines: 10 diff --git a/mysql-test/main/optimizer_costs.test b/mysql-test/main/optimizer_costs.test new file mode 100644 index 00000000000..13ce927fb26 --- /dev/null +++ b/mysql-test/main/optimizer_costs.test @@ -0,0 +1,187 @@ +# +# Test of optimizer_costs +# +--source include/have_innodb.inc +--source include/have_sequence.inc + +select table_name,engine from information_schema.tables where table_name="optimizer_costs"; +show create table information_schema.optimizer_costs; +let $start_engines=`select count(*) from information_schema.optimizer_costs`; +--vertical_results +select * from information_schema.optimizer_costs where engine in +("memory","innodb","aria","default") order by engine; +--horizontal_results +show variables like "optimizer%cost"; +show variables like "optimizer_disk_read_ratio"; + +--echo # +--echo # Test change some 'default' variables +--echo # +SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost; +SET global optimizer_disk_read_ratio=0.8; +SET global optimizer_index_block_copy_cost=0.1; +SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost; +select optimizer_disk_read_ratio,optimizer_index_block_copy_cost from information_schema.optimizer_costs where engine='default'; +SET global optimizer_disk_read_ratio=default; +SET global optimizer_index_block_copy_cost=default; +SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost; + +--echo # +--echo # Test change some 'engine' variables +--echo # +select @@MEMORY.optimizer_row_lookup_cost; +set @tmp=@@MEMORY.optimizer_row_lookup_cost; +set @@global.MEMORY.optimizer_row_lookup_cost=1; +select @@MEMORY.optimizer_row_lookup_cost; +set @@global.MEMORY.optimizer_row_lookup_cost=default; +select @@MEMORY.optimizer_row_lookup_cost; +set @@global.MEMORY.optimizer_row_lookup_cost=@tmp; +select @@MEMORY.optimizer_row_lookup_cost; + +--echo # +--echo # Print variables with different syntaxes +--echo # +SHOW VARIABLES like "optimizer_row_lookup_cost"; +SELECT @@optimizer_row_lookup_cost; +SELECT @@global.default.optimizer_row_lookup_cost; +SELECT @@global.default.`optimizer_row_lookup_cost`; +SELECT @@MEMORY.optimizer_row_lookup_cost; +SELECT @@memory.optimizer_row_lookup_cost; +SELECT @@InnoDB.optimizer_row_lookup_cost; + +--echo # +--echo # Accessing not existing cost +--echo # +SELECT @@not_existing.optimizer_row_lookup_cost; +SELECT @@NOT_existing.optimizer_row_lookup_cost; +select engine from information_schema.optimizer_costs where engine like '%existing'; + +--echo # +--echo # Creating a new cost structure +--echo # +SET global new_engine.optimizer_disk_read_cost=100; +select * from information_schema.optimizer_costs where engine like 'new_engine'; +select @@new_engine.optimizer_disk_read_cost, @@new_engine.optimizer_row_copy_cost; + +--echo # +--echo # Errors +--echo # +--error ER_PARSE_ERROR +SELECT @@default.optimizer_disk_read_cost; +--error ER_WRONG_TYPE_FOR_VAR +set global Aria.optimizer_disk_read_cost=NULL; + +set @tmp=@@Aria.optimizer_disk_read_cost; +SET global Aria.optimizer_disk_read_cost=-1; +select @@Aria.optimizer_disk_read_cost; +SET global Aria.optimizer_disk_read_cost=200000; +select @@Aria.optimizer_disk_read_cost; +set global Aria.optimizer_disk_read_cost=@tmp; +select @@Aria.optimizer_disk_read_cost; + +--echo # +--echo # Test of cost of ref compared to table scan + join_cache +--echo # + +create or replace table t1 (p int primary key, a char(10)) engine=myisam; +create or replace table t2 (p int primary key, i int, a char(10), key k2(a)) engine=myisam; +insert into t2 select seq,seq,'a' from seq_1_to_512; + +insert into t1 select seq,'a' from seq_1_to_4; +explain select count(*) from t1, t2 where t1.p = t2.i; +insert into t1 select seq,'a' from seq_5_to_10; +explain select count(*) from t1, t2 where t1.p = t2.i; + +drop table t1,t2; + +--echo # +--echo # Test of optimizer_scan_setup_cost +--echo # + +create table t1 (p int primary key, a char(10)) engine=myisam; +create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)) engine=myisam; +insert into t1 values (2, 'qqqq'), (11, 'yyyy'); +insert into t2 values (1, 2, 'qqqq'), (2, 2, 'pppp'), + (3, 2, 'yyyy'), (4, 3, 'zzzz'); +set @org_myisam_disk_read_ratio=@@myisam.optimizer_disk_read_ratio; +set @@optimizer_scan_setup_cost=10,@@global.myisam.optimizer_disk_read_ratio=0.2; +flush tables; +explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i; +set @@optimizer_scan_setup_cost=0.0, @@global.myisam.optimizer_disk_read_ratio=0.0; +flush tables; +explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i; +set @@optimizer_scan_setup_cost=default,@@global.myisam.optimizer_disk_read_ratio=@org_myisam_disk_read_ratio; +flush tables; +drop table t1,t2; + +--echo # +--echo # Test of group by optimization +--echo # + +set @@optimizer_scan_setup_cost=0; +CREATE TABLE t1 (id INT NOT NULL, a DATE, KEY(id,a)) engine=myisam; +INSERT INTO t1 values (1,'2001-01-01'),(1,'2001-01-02'), +(1,'2001-01-03'),(1,'2001-01-04'), +(2,'2001-01-01'),(2,'2001-01-02'), +(2,'2001-01-03'),(2,'2001-01-04'), +(3,'2001-01-01'),(3,'2001-01-02'), +(3,'2001-01-03'),(3,'2001-01-04'), +(4,'2001-01-01'),(4,'2001-01-02'), +(4,'2001-01-03'),(4,'2001-01-04'); +analyze table t1; +EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id; +insert into t1 values (3,'2001-01-03'),(3,'2001-01-04'); +insert into t1 values (3,'2001-01-03'),(3,'2001-01-04'); +insert into t1 values (3,'2001-01-03'),(3,'2001-01-04'); +insert into t1 values (3,'2001-01-03'),(3,'2001-01-04'); +analyze table t1; +EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id; +drop table t1; +set @@optimizer_scan_setup_cost=default; + +--echo # +--echo # Test of straight join costs +--echo # +create table t1 (l_orderkey int(11) NOT NULL, + l_partkey int(11) DEFAULT NULL, + l_suppkey int(11) DEFAULT NULL, + PRIMARY KEY (l_orderkey)) engine=aria; +insert into t1 select seq,seq,seq from seq_1_to_1000; +explain select straight_join count(*) from seq_1_to_10000,t1 where seq=l_orderkey; +show status like "last_query_cost"; +set @org_cost=@@aria.optimizer_key_next_find_cost; +# Set cost for t1 high so that we cannot use it for index scans +set global aria.optimizer_key_next_find_cost=1000; +flush tables; +explain select count(*) from seq_1_to_10000,t1 where seq=l_orderkey; +show status like "last_query_cost"; +set global aria.optimizer_key_next_find_cost=@org_cost; +drop table t1; + +--echo # +--echo # Testing distinct group optimization +--echo # + +create table t1 (a int, b int, key(a,b)); +insert into t1 select seq,seq from seq_1_to_1000; +explain select count(distinct a,b) from t1; +explain select count(distinct a,b) from t1 where a>100; +explain select count(distinct a,b) from t1 where a>800; +update t1 set a=mod(a,10); +analyze table t1; +explain select count(distinct a,b) from t1; +explain select count(distinct a,b) from t1 where a>1; +explain select count(distinct a,b) from t1 where a>8; +update t1 set b=mod(b,2); +analyze table t1; +explain select count(distinct a,b) from t1; +explain select count(distinct a,b) from t1 where a>1; +explain select count(distinct a,b) from t1 where a>8; +drop table t1; + +--echo # +--echo # cleanup +--echo # + +let $end_engines=`select count(*) from information_schema.optimizer_costs`; +--echo Start_engines: $start_engines End_engines: $end_engines diff --git a/mysql-test/main/optimizer_costs2-master.opt b/mysql-test/main/optimizer_costs2-master.opt new file mode 100644 index 00000000000..718ccafc05e --- /dev/null +++ b/mysql-test/main/optimizer_costs2-master.opt @@ -0,0 +1 @@ +--optimizer_disk_read_ratio=0.9 --MEMORY.optimizer_disk_read_ratio=0.1 --memory.optimizer_disk_read_ratio=0.3 --memory.optimizer_row_lookup_cost=0.8 diff --git a/mysql-test/main/optimizer_costs2.result b/mysql-test/main/optimizer_costs2.result new file mode 100644 index 00000000000..688dcb51110 --- /dev/null +++ b/mysql-test/main/optimizer_costs2.result @@ -0,0 +1,8 @@ +select engine,optimizer_disk_read_ratio from information_schema.optimizer_costs where engine in ("memory","aria","default"); +engine optimizer_disk_read_ratio +default 0.900000 +MEMORY 0.300000 +Aria 0.900000 +select @@memory.optimizer_row_lookup_cost; +@@memory.optimizer_row_lookup_cost +0.800000 diff --git a/mysql-test/main/optimizer_costs2.test b/mysql-test/main/optimizer_costs2.test new file mode 100644 index 00000000000..0445ce523cd --- /dev/null +++ b/mysql-test/main/optimizer_costs2.test @@ -0,0 +1,6 @@ +# +# Check default optimizer_cost_arguments +# + +select engine,optimizer_disk_read_ratio from information_schema.optimizer_costs where engine in ("memory","aria","default"); +select @@memory.optimizer_row_lookup_cost; diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index b59089bee80..cb5459532ee 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -1192,7 +1192,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index k2 k3 5 NULL 111 Using where EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref k2 k2 5 const 7341 Using where; Using filesort +1 SIMPLE t2 range k2 k2 5 NULL 7341 Using index condition; Using filesort +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 6000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL k2 NULL NULL NULL 40960 Using where; Using filesort EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index k2 k3 5 NULL 73 Using where @@ -1577,19 +1580,20 @@ ANALYZE "r_sort_mode": "sort_key,addon_fields", "table": { "table_name": "t1", - "access_type": "index", + "access_type": "ref_or_null", "possible_keys": ["a_c", "a"], "key": "a_c", "key_length": "10", "used_key_parts": ["a", "c"], + "ref": ["const", "const"], "r_loops": 1, "rows": 2, - "r_rows": 2, + "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 50, - "r_filtered": 50, - "attached_condition": "t1.a = 2 and (t1.c = 10 or t1.c is null)", + "r_filtered": 100, + "attached_condition": "t1.c = 10 or t1.c is null", "using_index": true } } @@ -1601,26 +1605,11 @@ ANALYZE EXPLAIN SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a_c,a a_c 10 NULL 2 Using where; Using index; Using filesort +1 SIMPLE t1 ref_or_null a_c,a a_c 10 const,const 2 Using where; Using index; Using filesort # Must return 1 row SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; col 1 -# With more rows "filesort" is removed -INSERT INTO t1 select seq,seq from seq_1_to_2; -EXPLAIN -SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a_c,a a_c 10 NULL 2 Using where; Using index -SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; -col -1 -# With more rows "range" changes to "ref_or_null" -INSERT INTO t1 select seq,seq from seq_3_to_10; -EXPLAIN -SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null a_c,a a_c 10 const,const 2 Using where; Using index; Using filesort # Must use ref-or-null on the a_c index EXPLAIN SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; @@ -3130,7 +3119,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 1 PRIMARY t3a ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary -1 PRIMARY t3b ref f3_key f3_key 6 test.t3a.f3 1 100.00 Using where; End temporary +1 PRIMARY t3b ref f3_key f3_key 6 test.t3a.f3 1 41.67 Using where; End temporary Warnings: Note 1003 select concat('foo',`test`.`t2`.`f2`) AS `field` from `test`.`t2` semi join ((`test`.`t3` `t3a` join `test`.`t3` `t3b`)) where `test`.`t3a`.`f3` < 'foo' or `test`.`t3b`.`f3` <> 'foo' order by concat('foo',`test`.`t2`.`f2`) DROP TABLE t1,t2,t3; @@ -3184,7 +3173,7 @@ id select_type table type possible_keys key key_len ref rows Extra # See above query EXPLAIN SELECT id1 FROM t2 WHERE id2=1 AND id3=1 ORDER BY date DESC LIMIT 0,4; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range id_23_date,id_234_date id_23_date 2 NULL 8 Using where +1 SIMPLE t2 ref id_23_date,id_234_date id_23_date 2 const,const 8 Using where drop table t1,t2; # # MDEV-8989: ORDER BY optimizer ignores equality propagation @@ -3565,8 +3554,8 @@ WHERE books.library_id = 8663 AND books.scheduled_for_removal=0 ) ORDER BY wings.id; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY wings ALL PRIMARY NULL NULL NULL 2 100.00 Using temporary; Using filesort -1 PRIMARY books ALL library_idx NULL NULL NULL 2 100.00 Using where; FirstMatch(wings); Using join buffer (flat, BNL join) +1 PRIMARY wings ALL PRIMARY NULL NULL NULL 2 100.00 Using filesort +1 PRIMARY books ref library_idx library_idx 4 const 2 50.00 Using where; FirstMatch(wings) Warnings: Note 1003 select `test`.`wings`.`id` AS `wing_id`,`test`.`wings`.`department_id` AS `department_id` from `test`.`wings` semi join (`test`.`books`) where `test`.`books`.`library_id` = 8663 and `test`.`books`.`scheduled_for_removal` = 0 and `test`.`books`.`wings_id` = `test`.`wings`.`id` order by `test`.`wings`.`id` set optimizer_switch= @save_optimizer_switch; @@ -3700,8 +3689,8 @@ WHERE t2.key1 = t1.a and t2.key1 IS NOT NULL ORDER BY t2.key2 ASC -LIMIT 1) -from t1; +LIMIT 1) as "con" + from t1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 10 2 DEPENDENT SUBQUERY t2 ref key1 key1 5 test.t1.a 10 Using index condition; Using where; Using filesort @@ -3712,15 +3701,9 @@ WHERE t2.key1 = t1.a and t2.key1 IS NOT NULL ORDER BY t2.key2 ASC -LIMIT 1) -from t1; -(SELECT concat(id, '-', key1, '-', col1) -FROM t2 -WHERE -t2.key1 = t1.a and t2.key1 IS NOT NULL -ORDER BY -t2.key2 ASC -LIMIT 1) +LIMIT 1) as "con" + from t1; +con 100-0-123456 101-1-123456 102-2-123456 @@ -4463,7 +4446,8 @@ CREATE TABLE t1 (a INT, b int, primary key(a)); CREATE TABLE t2 (a INT, b INT); INSERT INTO t1 (a,b) VALUES (58,1),(96,2),(273,3),(23,4),(231,5),(525,6), (2354,7),(321421,3),(535,2),(4535,3); -INSERT INTO t2 (a,b) VALUES (58,3),(96,3),(273,3),(1000,1000),(2000,2000); +INSERT INTO t2 (a,b) VALUES (58,3),(96,3),(273,3),(1000,1000),(2000,2000),(3000,3000); +INSERT INTO t2 select seq,seq from seq_10_to_100; # Join order should have the SJM scan table as the first table for both # the queries with GROUP BY and ORDER BY clause. EXPLAIN SELECT t1.a @@ -4471,9 +4455,9 @@ FROM t1 WHERE t1.a IN (SELECT a FROM t2 WHERE b=3) ORDER BY t1.a DESC; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 5 Using filesort -1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 10 Using index +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 97 Using where EXPLAIN FORMAT=JSON SELECT t1.a FROM t1 WHERE t1.a IN (SELECT a FROM t2 WHERE b=3) @@ -4483,50 +4467,48 @@ EXPLAIN "query_block": { "select_id": 1, "nested_loop": [ - { - "read_sorted_file": { - "filesort": { - "sort_key": "t1.a desc", - "table": { - "table_name": "", - "access_type": "ALL", - "possible_keys": ["distinct_key"], - "rows": 5, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "nested_loop": [ - { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t2.b = 3 and t2.a is not null" - } - } - ] - } - } - } - } - } - }, { "table": { "table_name": "t1", - "access_type": "eq_ref", + "access_type": "index", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 1, + "rows": 10, "filtered": 100, "using_index": true } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "4", + "used_key_parts": ["a"], + "ref": ["func"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 97, + "filtered": 100, + "attached_condition": "t2.b = 3" + } + } + ] + } + } + } } ] } @@ -4544,9 +4526,9 @@ FROM t1 WHERE t1.a IN (SELECT a FROM t2 WHERE b=3) GROUP BY t1.a DESC; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 5 Using filesort -1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 10 Using filesort +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 97 Using where EXPLAIN FORMAT=JSON SELECT t1.a, group_concat(t1.b) FROM t1 WHERE t1.a IN (SELECT a FROM t2 WHERE b=3) @@ -4561,43 +4543,43 @@ EXPLAIN "filesort": { "sort_key": "t1.a desc", "table": { - "table_name": "", + "table_name": "t1", "access_type": "ALL", - "possible_keys": ["distinct_key"], - "rows": 5, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "nested_loop": [ - { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t2.b = 3 and t2.a is not null" - } - } - ] - } - } + "possible_keys": ["PRIMARY"], + "rows": 10, + "filtered": 100 } } } }, { "table": { - "table_name": "t1", + "table_name": "", "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", + "possible_keys": ["distinct_key"], + "key": "distinct_key", "key_length": "4", "used_key_parts": ["a"], - "ref": ["test.t2.a"], + "ref": ["func"], "rows": 1, - "filtered": 100 + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 97, + "filtered": 100, + "attached_condition": "t2.b = 3" + } + } + ] + } + } } } ] diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index 24c90a62041..c336a6784a5 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -922,17 +922,6 @@ SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; --echo # Must return 1 row SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; ---echo # With more rows "filesort" is removed -INSERT INTO t1 select seq,seq from seq_1_to_2; -EXPLAIN -SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; -SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; - ---echo # With more rows "range" changes to "ref_or_null" -INSERT INTO t1 select seq,seq from seq_3_to_10; -EXPLAIN -SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; - # part 2 of the problem : DESC test cases --echo # Must use ref-or-null on the a_c index --replace_column 1 x 2 x 3 x 6 x 7 x 8 x 9 x 10 x @@ -2409,7 +2398,7 @@ let $query= select t2.key1 = t1.a and t2.key1 IS NOT NULL ORDER BY t2.key2 ASC - LIMIT 1) + LIMIT 1) as "con" from t1; --echo # here type should show ref not index @@ -2692,8 +2681,8 @@ CREATE TABLE t2 (a INT, b INT); INSERT INTO t1 (a,b) VALUES (58,1),(96,2),(273,3),(23,4),(231,5),(525,6), (2354,7),(321421,3),(535,2),(4535,3); -INSERT INTO t2 (a,b) VALUES (58,3),(96,3),(273,3),(1000,1000),(2000,2000); - +INSERT INTO t2 (a,b) VALUES (58,3),(96,3),(273,3),(1000,1000),(2000,2000),(3000,3000); +INSERT INTO t2 select seq,seq from seq_10_to_100; --echo # Join order should have the SJM scan table as the first table for both --echo # the queries with GROUP BY and ORDER BY clause. diff --git a/mysql-test/main/order_by_innodb.result b/mysql-test/main/order_by_innodb.result index 7462b8e6688..11287f25698 100644 --- a/mysql-test/main/order_by_innodb.result +++ b/mysql-test/main/order_by_innodb.result @@ -256,7 +256,7 @@ d1 > '2019-02-06 00:00:00' dd.d1, dd.d2, dd.id limit 1 ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL # 1 PRIMARY t2 eq_ref PRIMARY,id2 id2 8 test.t1.id,func # Using where; Using index 2 DEPENDENT SUBQUERY dd ref id2,for_latest_sort id2 4 test.t1.id # Using where; Using filesort drop table t1,t2,t3; diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result index 0d37d4cb168..ad4c3cf1ad3 100644 --- a/mysql-test/main/partition.result +++ b/mysql-test/main/partition.result @@ -2361,11 +2361,11 @@ b c EXPLAIN SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range bc bc 10 NULL 8 Using where; Using index for group-by +1 SIMPLE t1 ref bc bc 5 const 23 Using where; Using index EXPLAIN SELECT b, c FROM t1 WHERE b = 1 or b=2 GROUP BY b, c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range bc bc 10 NULL 8 Using where; Using index for group-by +1 SIMPLE t1 range bc bc 5 NULL 23 Using where; Using index DROP TABLE t1; # # Bug #45807: crash accessing partitioned table and sql_mode diff --git a/mysql-test/main/partition_explicit_prune.result b/mysql-test/main/partition_explicit_prune.result index 07af2d58a42..b7f4abe2952 100644 --- a/mysql-test/main/partition_explicit_prune.result +++ b/mysql-test/main/partition_explicit_prune.result @@ -470,7 +470,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE TableAlias p0-9_subp3 index NULL b 71 NULL 3 Using index EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 PARTITION (`p10-99`); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p10-99_subp4,p10-99_subp5 index NULL PRIMARY 4 NULL 2 Using index +1 SIMPLE t1 p10-99_subp4,p10-99_subp5 index NULL b 71 NULL 2 Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 1000000; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -1939,7 +1939,7 @@ MOD(seq, 100), seq_1_to_5000; explain select * from t1 partition (p1) where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where +1 SIMPLE t1 ref|filter a,b a|b 5|5 const 49 (1%) Using where; Using rowid filter flush tables; select * from t1 partition (p1)where a=10 and b=10; pk a b filler diff --git a/mysql-test/main/partition_mrr_aria.result b/mysql-test/main/partition_mrr_aria.result index 7ff5c9b63ed..c7983007281 100644 --- a/mysql-test/main/partition_mrr_aria.result +++ b/mysql-test/main/partition_mrr_aria.result @@ -130,7 +130,7 @@ set optimizer_switch='mrr=on'; explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index -1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE t0 ALL idx NULL NULL NULL 50 25.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1 select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; @@ -164,7 +164,7 @@ tp a b c a explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index -1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE t0 ALL idx NULL NULL NULL 50 25.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4 select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; diff --git a/mysql-test/main/partition_mrr_innodb.result b/mysql-test/main/partition_mrr_innodb.result index 98819021a6d..7d91fafef7c 100644 --- a/mysql-test/main/partition_mrr_innodb.result +++ b/mysql-test/main/partition_mrr_innodb.result @@ -130,7 +130,7 @@ set optimizer_switch='mrr=on'; explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index -1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE t0 ALL idx NULL NULL NULL 50 25.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1 select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; @@ -164,7 +164,7 @@ tp a b c a explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index -1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE t0 ALL idx NULL NULL NULL 50 25.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4 select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; diff --git a/mysql-test/main/partition_mrr_myisam.result b/mysql-test/main/partition_mrr_myisam.result index c3ce2935417..9155851a60a 100644 --- a/mysql-test/main/partition_mrr_myisam.result +++ b/mysql-test/main/partition_mrr_myisam.result @@ -130,7 +130,7 @@ set optimizer_switch='mrr=on'; explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index -1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE t0 ALL idx NULL NULL NULL 50 25.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1 select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; @@ -164,7 +164,7 @@ tp a b c a explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index -1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE t0 ALL idx NULL NULL NULL 50 25.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4 select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; @@ -288,7 +288,7 @@ explain select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index -1 SIMPLE t0 ref idx idx 5 test.t2.a 12 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE t0 ALL idx NULL NULL NULL 50 Using where; Using join buffer (flat, BNL join) # This will use "Using index condition(BKA)" explain select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result index dcc25892276..7f07a6c4257 100644 --- a/mysql-test/main/partition_pruning.result +++ b/mysql-test/main/partition_pruning.result @@ -18,7 +18,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra # # # # range # # # # 3 # EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7; id select_type table partitions type possible_keys key key_len ref rows Extra -# # # # range # # # # 8 # +# # # # index # # # # 10 # EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; id select_type table partitions type possible_keys key key_len ref rows Extra # # # # range # # # # 3 # @@ -92,7 +92,7 @@ a 5 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5 range PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a < 7; a -1 @@ -105,7 +105,7 @@ a 6 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index SELECT * FROM t1 WHERE a <= 1; a -1 @@ -155,7 +155,7 @@ a 5 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5 range PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a <= 6; a -1 @@ -168,7 +168,7 @@ a 6 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index SELECT * FROM t1 WHERE a <= 7; a -1 @@ -182,7 +182,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 7; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index SELECT * FROM t1 WHERE a = 1; a 1 @@ -237,7 +237,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index +1 SIMPLE t1 p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 8 Using where; Using index SELECT * FROM t1 WHERE a >= 2; a 2 @@ -424,7 +424,7 @@ a 5 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index SELECT * FROM t1 WHERE a <= 1; a -1 @@ -474,7 +474,7 @@ a 5 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index SELECT * FROM t1 WHERE a <= 6; a -1 @@ -487,7 +487,7 @@ a 6 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index SELECT * FROM t1 WHERE a = 1; a 1 @@ -2888,12 +2888,12 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where explain extended select * from t2 where b in (2,4,6); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 range b b 5 NULL 231 100.00 Using where +1 SIMPLE t2 ALL b NULL NULL NULL 910 25.38 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` in (2,4,6) explain partitions select * from t2 where b in (2,4,6); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p0,p1,p2,p3,p4 range b b 5 NULL 231 Using where +1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where explain extended select * from t2 where b in (7,8,9); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL b NULL NULL NULL 910 36.81 Using where @@ -2912,12 +2912,12 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where explain extended select * from t2 where b > 5 and b < 8; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 range b b 5 NULL 202 100.00 Using where +1 SIMPLE t2 ALL b NULL NULL NULL 910 22.20 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` > 5 and `test`.`t2`.`b` < 8 explain partitions select * from t2 where b > 5 and b < 8; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p0,p1,p2,p3,p4 range b b 5 NULL 202 Using where +1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where explain extended select * from t2 where b > 5 and b < 7; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range b b 5 NULL 77 100.00 Using where @@ -2946,10 +2946,10 @@ flush status; update t2 set a = 111 where b in (5,6); show status like 'Handler_read_rnd_next'; Variable_name Value -Handler_read_rnd_next 0 +Handler_read_rnd_next 915 show status like 'Handler_read_key'; Variable_name Value -Handler_read_key 10 +Handler_read_key 0 flush status; update t2 set a = 222 where b = 7; show status like 'Handler_read_rnd_next'; @@ -3378,7 +3378,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1 const PRIMARY PRIMARY 8 const,const 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 >= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1,p2 ref PRIMARY PRIMARY 4 const 1 Using where +1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 > 1; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where @@ -3387,7 +3387,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1 range PRIMARY PRIMARY 8 NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1,p2 ref PRIMARY PRIMARY 4 const 1 Using where +1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 3; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where @@ -3405,7 +3405,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1,p2 ref PRIMARY PRIMARY 4 const 1 Using where +1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 = 4; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p2 const PRIMARY PRIMARY 8 const,const 1 @@ -3465,7 +3465,7 @@ select * from t1 where company_id = 1000 and dept_id in (select dept_id from t2 where COMPANY_ID = 1000); id select_type table partitions type possible_keys key key_len ref rows Extra -1 PRIMARY t1 p_1000 ALL PRIMARY NULL NULL NULL 6 Using where +1 PRIMARY t1 p_1000 ref PRIMARY PRIMARY 8 const 6 Using where 1 PRIMARY t2 p_1000 eq_ref PRIMARY PRIMARY 16 const,test.t1.dept_id 1 Using index drop table t1,t2; # diff --git a/mysql-test/main/partition_range.result b/mysql-test/main/partition_range.result index 3c1ff311bf5..be1689b218e 100644 --- a/mysql-test/main/partition_range.result +++ b/mysql-test/main/partition_range.result @@ -19,11 +19,11 @@ insert into t1 (a,b) select seq,seq from seq_4001_to_4100; insert into t1 (a,b) select seq,seq from seq_10001_to_10100; EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index for group-by alter table t1 partition by hash(a) partitions 1; EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index for group-by DROP TABLE t1; create table t1 (a DATETIME) partition by range (TO_DAYS(a)) @@ -958,6 +958,11 @@ CREATE TABLE t1 ( a INT, b INT, KEY ( a, b ) +); +CREATE TABLE t1_part ( +a INT, +b INT, +KEY ( a, b ) ) PARTITION BY HASH (a) PARTITIONS 1; CREATE TABLE t2 ( a INT, @@ -969,36 +974,68 @@ INSERT INTO t1 SELECT a + 5, b + 5 FROM t1; INSERT INTO t1 SELECT a + 10, b + 10 FROM t1; INSERT INTO t1 SELECT a + 20, b + 20 FROM t1; INSERT INTO t1 SELECT a + 40, b + 40 FROM t1; +INSERT INTO t1 values(10,0),(10,1),(10,2),(100,0),(100,1); +select count(*) from t1; +count(*) +85 +select count(*) from t1 where a=10; +count(*) +4 +select count(*) from t1 where a=100; +count(*) +2 +INSERT INTO t1_part SELECT * FROM t1; INSERT INTO t2 SELECT * FROM t1; -ANALYZE TABLE t1,t2; +ANALYZE TABLE t1_part,t2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status OK +test.t1_part analyze status Engine-independent statistics collected +test.t1_part analyze status OK test.t2 analyze status Engine-independent statistics collected test.t2 analyze status Table is already up to date # plans should be identical -EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10,100) GROUP BY a; +EXPLAIN SELECT a, MAX(b) FROM t1_part WHERE a IN (10,100) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index +1 SIMPLE t1_part range a a 5 NULL 2 Using where; Using index for group-by EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index +1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index for group-by FLUSH status; -SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100) GROUP BY a; +SELECT a, MAX(b) FROM t1_part WHERE a IN (10, 100) GROUP BY a; a MAX(b) 10 10 -# Should be no more than 4 reads. -SHOW status LIKE 'handler_read_key'; +100 1 +SHOW status LIKE 'handler_read%'; Variable_name Value -Handler_read_key 2 +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_retry 0 +Handler_read_rnd 0 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 0 FLUSH status; SELECT a, MAX(b) FROM t2 WHERE a IN (10, 100) GROUP BY a; a MAX(b) 10 10 -# Should be no more than 4 reads. -SHOW status LIKE 'handler_read_key'; +100 1 +SHOW status LIKE 'handler_read%'; Variable_name Value -Handler_read_key 2 +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_retry 0 +Handler_read_rnd 0 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 0 +insert into t2 select 100,seq from seq_1_to_100; +EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index for group-by +DROP TABLE t1,t1_part,t2; # # MDEV-18501 Partition pruning doesn't work for historical queries # @@ -1026,7 +1063,7 @@ d select * from t1 partition (p1); d 2000-01-01 00:00:01.000000 -DROP TABLE t1, t2; +DROP TABLE t1; # # MDEV-21195 INSERT chooses wrong partition for RANGE partitioning by DECIMAL column # diff --git a/mysql-test/main/partition_range.test b/mysql-test/main/partition_range.test index 740cbcd7d7b..cfd2b42513f 100644 --- a/mysql-test/main/partition_range.test +++ b/mysql-test/main/partition_range.test @@ -942,10 +942,17 @@ drop table t1, t2; --echo # Bug#50939: Loose Index Scan unduly relies on engine to remember range --echo # endpoints --echo # + CREATE TABLE t1 ( a INT, b INT, KEY ( a, b ) +); + +CREATE TABLE t1_part ( + a INT, + b INT, + KEY ( a, b ) ) PARTITION BY HASH (a) PARTITIONS 1; CREATE TABLE t2 ( @@ -960,24 +967,32 @@ INSERT INTO t1 SELECT a + 5, b + 5 FROM t1; INSERT INTO t1 SELECT a + 10, b + 10 FROM t1; INSERT INTO t1 SELECT a + 20, b + 20 FROM t1; INSERT INTO t1 SELECT a + 40, b + 40 FROM t1; +INSERT INTO t1 values(10,0),(10,1),(10,2),(100,0),(100,1); +select count(*) from t1; +select count(*) from t1 where a=10; +select count(*) from t1 where a=100; +INSERT INTO t1_part SELECT * FROM t1; INSERT INTO t2 SELECT * FROM t1; -ANALYZE TABLE t1,t2; +ANALYZE TABLE t1_part,t2; --echo # plans should be identical -EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10,100) GROUP BY a; +EXPLAIN SELECT a, MAX(b) FROM t1_part WHERE a IN (10,100) GROUP BY a; EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a; FLUSH status; -SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100) GROUP BY a; ---echo # Should be no more than 4 reads. -SHOW status LIKE 'handler_read_key'; +SELECT a, MAX(b) FROM t1_part WHERE a IN (10, 100) GROUP BY a; +SHOW status LIKE 'handler_read%'; FLUSH status; SELECT a, MAX(b) FROM t2 WHERE a IN (10, 100) GROUP BY a; ---echo # Should be no more than 4 reads. -SHOW status LIKE 'handler_read_key'; +SHOW status LIKE 'handler_read%'; + +insert into t2 select 100,seq from seq_1_to_100; +EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a; + +DROP TABLE t1,t1_part,t2; --echo # --echo # MDEV-18501 Partition pruning doesn't work for historical queries @@ -1006,7 +1021,7 @@ insert into t1 values select * from t1 partition (p0); select * from t1 partition (p1); -DROP TABLE t1, t2; +DROP TABLE t1; --echo # --echo # MDEV-21195 INSERT chooses wrong partition for RANGE partitioning by DECIMAL column diff --git a/mysql-test/main/percona_nonflushing_analyze_debug.result b/mysql-test/main/percona_nonflushing_analyze_debug.result index 78da085f26f..c3388fa42ed 100644 --- a/mysql-test/main/percona_nonflushing_analyze_debug.result +++ b/mysql-test/main/percona_nonflushing_analyze_debug.result @@ -1,7 +1,7 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1), (2), (3); connect con1,localhost,root; -SET DEBUG_SYNC="handler_ha_index_next_end SIGNAL idx_scan_in_progress WAIT_FOR finish_scan"; +SET DEBUG_SYNC="handler_rnd_next_end SIGNAL idx_scan_in_progress WAIT_FOR finish_scan"; SELECT * FROM t1; connection default; SET DEBUG_SYNC="now WAIT_FOR idx_scan_in_progress"; diff --git a/mysql-test/main/pool_of_threads.result b/mysql-test/main/pool_of_threads.result index 91ad7ab098f..718cb7dc8ce 100644 --- a/mysql-test/main/pool_of_threads.result +++ b/mysql-test/main/pool_of_threads.result @@ -1,5 +1,6 @@ SET optimizer_switch='outer_join_with_cache=off'; drop table if exists t1,t2,t3,t4; +set @@default_storage_engine="aria"; CREATE TABLE t1 ( Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL @@ -600,6 +601,9 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index +# +# Some test with ORDER BY and limit +# explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort @@ -1289,7 +1293,7 @@ companynr tinyint(2) unsigned zerofill NOT NULL default '00', companyname char(30) NOT NULL default '', PRIMARY KEY (companynr), UNIQUE KEY companyname(companyname) -) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; companynr companyname 00 Unknown @@ -1379,6 +1383,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE delete from t2 where fld1=999999; +# +# Test left join optimization +# explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where @@ -1393,15 +1400,15 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; id select_type table type possible_keys key key_len ref rows Extra @@ -1417,11 +1424,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index a2ecc66c570..0bd56723d4b 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -252,7 +252,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref x x 5 const 1 Using index explain select count(*) from t1 where x in (1,2,3,4); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index x x 5 NULL 9 Using where; Using index +1 SIMPLE t1 range x x 5 NULL 4 Using where; Using index drop table t1; CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); @@ -261,12 +261,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); explain select * from t1, t2 where (t1.key1 'x'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL a NULL NULL NULL 2 Using where +1 SIMPLE t1 range a a 2 NULL 2 Using where select a from t1 where a > 'x'; a xx @@ -723,7 +733,7 @@ WHERE v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE v ALL OXLEFT,OXRIGHT,OXROOTID NULL NULL NULL 12 Using where +1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 6 Using index condition 1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4) SELECT s.oxid FROM t1 v, t1 s WHERE @@ -1138,7 +1148,7 @@ INSERT INTO t1 VALUES ('A2','2005-12-01 08:00:00',1000); EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where +1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 3 Using index condition SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; item started price Warnings: @@ -1236,13 +1246,16 @@ insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t2 (a int, b int, filler char(100)); insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, t1 B, t1 C where A.a < 5; -insert into t2 select 1000, b, 'filler' from t2 limit 250; +insert into t2 select 1000, b, 'filler' from t2 limit 50; +select count(*) from t2; +count(*) +550 alter table t2 add index (a,b); -# In following EXPLAIN the access method should be ref, #rows~=250 +# In following EXPLAIN the access method should be ref, #rows~=50 # (and not 2) when we are not using rowid-ordered scans explain select * from t2 where a=1000 and b<11; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range a a 10 NULL 253 Using index condition +1 SIMPLE t2 range a a 10 NULL 63 Using index condition drop table t1, t2; CREATE TABLE t1( a INT, b INT, KEY( a, b ) ); CREATE TABLE t2( a INT, b INT, KEY( a, b ) ); @@ -1954,7 +1967,7 @@ select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 64 -1 SIMPLE t1 range i1,i2 i1 4 NULL 12 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t1 range|filter i1,i2 i1|i2 4|4 NULL 12 (89%) Using where; Using join buffer (flat, BNL join); Using rowid filter select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000; count(*) @@ -2541,7 +2554,7 @@ insert into t2 values explain select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(2,2)); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range idx1,idx2 idx1 5 NULL 3 Using index condition; Using where +1 SIMPLE t2 range|filter idx1,idx2 idx1|idx2 5|5 NULL 3 (60%) Using index condition; Using where; Using rowid filter 1 SIMPLE t1 ref idx idx 5 test.t2.d 8 explain format=json select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(2,2)); @@ -2558,8 +2571,16 @@ EXPLAIN "key": "idx1", "key_length": "5", "used_key_parts": ["d"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["e"] + }, + "rows": 12, + "selectivity_pct": 60 + }, "rows": 3, - "filtered": 100, + "filtered": 60, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((3,3)),((7,7)),((2,2)))" } @@ -2619,8 +2640,8 @@ insert into t2 values explain select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(8,8)) and length(f) = 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx idx 5 NULL 6 Using index condition -1 SIMPLE t2 ref|filter idx1,idx2 idx1|idx2 5|5 test.t1.a 12 (14%) Using where; Using rowid filter +1 SIMPLE t2 range|filter idx1,idx2 idx1|idx2 5|5 NULL 8 (14%) Using index condition; Using where; Using rowid filter +1 SIMPLE t1 ref idx idx 5 test.t2.d 8 explain format=json select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(8,8)) and length(f) = 1; EXPLAIN @@ -2628,28 +2649,14 @@ EXPLAIN "query_block": { "select_id": 1, "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 6, - "filtered": 100, - "index_condition": "t1.a is not null" - } - }, { "table": { "table_name": "t2", - "access_type": "ref", + "access_type": "range", "possible_keys": ["idx1", "idx2"], "key": "idx1", "key_length": "5", "used_key_parts": ["d"], - "ref": ["test.t1.a"], "rowid_filter": { "range": { "key": "idx2", @@ -2658,9 +2665,23 @@ EXPLAIN "rows": 15, "selectivity_pct": 14.42307692 }, - "rows": 12, + "rows": 8, "filtered": 14.42307663, - "attached_condition": "(t1.a,t2.e) in (((3,3)),((7,7)),((8,8))) and octet_length(t2.f) = 1" + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (((3,3)),((7,7)),((8,8))) and octet_length(t2.f) = 1" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 8, + "filtered": 73.17073059 } } ] @@ -2689,40 +2710,40 @@ prepare stmt from "select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(8,8)) and length(f) = 1"; execute stmt; a b c d e f -3 2 uuuw 3 3 i -3 2 uuuw 3 3 i 3 2 uuua 3 3 i 3 2 uuua 3 3 i -3 3 zzzz 3 3 i -3 3 zzzz 3 3 i +3 2 uuuw 3 3 i +3 2 uuuw 3 3 i +3 3 zyxa 3 3 i +3 3 zyxa 3 3 i 3 3 zyxw 3 3 i 3 3 zyxw 3 3 i 3 3 zzza 3 3 i 3 3 zzza 3 3 i -3 3 zyxa 3 3 i -3 3 zyxa 3 3 i -7 7 xxxyy 7 7 h +3 3 zzzz 3 3 i +3 3 zzzz 3 3 i 7 7 xxxya 7 7 h -7 8 xxxxx 7 7 h +7 7 xxxyy 7 7 h 7 8 xxxxa 7 7 h +7 8 xxxxx 7 7 h execute stmt; a b c d e f -3 2 uuuw 3 3 i -3 2 uuuw 3 3 i 3 2 uuua 3 3 i 3 2 uuua 3 3 i -3 3 zzzz 3 3 i -3 3 zzzz 3 3 i +3 2 uuuw 3 3 i +3 2 uuuw 3 3 i +3 3 zyxa 3 3 i +3 3 zyxa 3 3 i 3 3 zyxw 3 3 i 3 3 zyxw 3 3 i 3 3 zzza 3 3 i 3 3 zzza 3 3 i -3 3 zyxa 3 3 i -3 3 zyxa 3 3 i -7 7 xxxyy 7 7 h +3 3 zzzz 3 3 i +3 3 zzzz 3 3 i 7 7 xxxya 7 7 h -7 8 xxxxx 7 7 h +7 7 xxxyy 7 7 h 7 8 xxxxa 7 7 h +7 8 xxxxx 7 7 h deallocate prepare stmt; insert into t1 select * from t1; # join order: (t2,t1) with ref access of t1 @@ -2730,8 +2751,8 @@ insert into t1 select * from t1; explain select * from t1,t2 where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx idx 5 NULL 15 Using index condition -1 SIMPLE t2 ref|filter idx1,idx2 idx1|idx2 5|5 test.t1.a 12 (7%) Using where; Using rowid filter +1 SIMPLE t2 range|filter idx1,idx2 idx1|idx2 5|5 NULL 7 (7%) Using index condition; Using where; Using rowid filter +1 SIMPLE t1 ref idx idx 5 test.t2.d 11 explain format=json select * from t1,t2 where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; EXPLAIN @@ -2739,28 +2760,14 @@ EXPLAIN "query_block": { "select_id": 1, "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 15, - "filtered": 100, - "index_condition": "t1.a is not null" - } - }, { "table": { "table_name": "t2", - "access_type": "ref", + "access_type": "range", "possible_keys": ["idx1", "idx2"], "key": "idx1", "key_length": "5", "used_key_parts": ["d"], - "ref": ["test.t1.a"], "rowid_filter": { "range": { "key": "idx2", @@ -2769,9 +2776,23 @@ EXPLAIN "rows": 7, "selectivity_pct": 6.730769231 }, - "rows": 12, + "rows": 7, "filtered": 6.730769157, - "attached_condition": "(t1.a,t2.e) in (((4,4)),((7,7)),((8,8))) and octet_length(t2.f) = 1" + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (((4,4)),((7,7)),((8,8))) and octet_length(t2.f) = 1" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 11, + "filtered": 100 } } ] @@ -3372,7 +3393,7 @@ insert into t2 select A.a + B.a*10 + C.a*100 from ten A, ten B,ten C where A.a + # expected type=range, rows=1487 , reason=using index dives analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198); id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 range a a 5 NULL 1487 1199.00 100.00 100.00 Using where; Using index +1 SIMPLE t1 index a a 5 NULL 2000 2000.00 74.35 59.95 Using where; Using index insert into t2 values (200),(201); # expected type=range, rows=201 , reason=using index statistics analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,200,201); diff --git a/mysql-test/main/range.test b/mysql-test/main/range.test index a8c56fcc35c..2dc110c1422 100644 --- a/mysql-test/main/range.test +++ b/mysql-test/main/range.test @@ -3,6 +3,8 @@ # Problem with range optimizer # --source include/have_innodb.inc +--source include/have_sequence.inc + SET optimizer_use_condition_selectivity=4; set @innodb_stats_persistent_save= @@innodb_stats_persistent; @@ -263,9 +265,9 @@ WHERE ); DROP TABLE t1; -# -# Test of problem with IN on many different keyparts. (Bug #4157) -# +--echo # +--echo # Test of problem with IN on many different keyparts. (Bug #4157) +--echo # CREATE TABLE t1 ( id int( 11 ) unsigned NOT NULL AUTO_INCREMENT , @@ -284,7 +286,10 @@ KEY recount( owner, line ) ) ENGINE = MYISAM; INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5); +INSERT into t1 (owner,id,columnid,line) select 11,seq+20,seq,seq from seq_1_to_100; +explain SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; +--sorted_result SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; drop table t1; @@ -1025,7 +1030,8 @@ create table t2 (a int, b int, filler char(100)); insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, t1 B, t1 C where A.a < 5; -insert into t2 select 1000, b, 'filler' from t2 limit 250; +insert into t2 select 1000, b, 'filler' from t2 limit 50; +select count(*) from t2; alter table t2 add index (a,b); # t2 values # ( 1 , 10, 'filler') @@ -1033,11 +1039,11 @@ alter table t2 add index (a,b); # ( 3 , 10, 'filler') # (... , 10, 'filler') # ... -# (1000, 10, 'filler') - 250 times +# (1000, 10, 'filler') - 100 times -# 250 rows, 1 row +# 50 rows, 1 row ---echo # In following EXPLAIN the access method should be ref, #rows~=250 +--echo # In following EXPLAIN the access method should be ref, #rows~=50 --echo # (and not 2) when we are not using rowid-ordered scans explain select * from t2 where a=1000 and b<11; @@ -1984,7 +1990,9 @@ eval explain format=json $q5; --sorted_result eval $q5; eval prepare stmt from "$q5"; +--sorted_result execute stmt; +--sorted_result execute stmt; deallocate prepare stmt; diff --git a/mysql-test/main/range_innodb.result b/mysql-test/main/range_innodb.result index 011ae411b21..826c0e4d90a 100644 --- a/mysql-test/main/range_innodb.result +++ b/mysql-test/main/range_innodb.result @@ -53,8 +53,8 @@ set optimizer_switch='extended_keys=on'; explain select pk, a, b from t1,t2,t3 where b >= d and pk < c and b = '0'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL # -1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL # Using where; Using join buffer (flat, BNL join) +1 SIMPLE t1 ref PRIMARY,idx1,idx2 idx1 5 const # +1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where; Using join buffer (flat, BNL join) 1 SIMPLE t3 ALL NULL NULL NULL NULL # Using where; Using join buffer (incremental, BNL join) select pk, a, b from t1,t2,t3 where b >= d and pk < c and b = '0'; pk a b @@ -98,7 +98,7 @@ SET @saved_dbug = @@GLOBAL.debug_dbug; set @@global.debug_dbug="+d,ha_index_init_fail"; explain select * from t1 where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where +1 SIMPLE t1 ref|filter a,b a|b 5|5 const 50 (2%) Using where; Using rowid filter select * from t1 where a=10 and b=10; ERROR HY000: Table definition has changed, please retry transaction DROP TABLE t0,t1; diff --git a/mysql-test/main/range_interrupted-13751.result b/mysql-test/main/range_interrupted-13751.result index 68610cdda8e..eadd32bffa0 100644 --- a/mysql-test/main/range_interrupted-13751.result +++ b/mysql-test/main/range_interrupted-13751.result @@ -1,11 +1,11 @@ CREATE TABLE t1 (i INT AUTO_INCREMENT, c VARCHAR(1), KEY(i), KEY(c,i)) ENGINE=MyISAM; -INSERT INTO t1 (c) VALUES ('a'),('b'),('c'),('d'); -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; +INSERT INTO t1 (c) select mid("abcdefgh", mod(seq,8)+1, 1) from seq_1_to_256; +explain SELECT 1 FROM t1 AS alias1, t1 AS alias2, t1 AS alias3 +WHERE alias1.c = alias2.c OR alias1.i <= 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE alias2 index c c 8 NULL 256 Using index +1 SIMPLE alias3 index NULL i 4 NULL 256 Using index; Using join buffer (flat, BNL join) +1 SIMPLE alias1 ALL i,c NULL NULL NULL 256 Range checked for each record (index map: 0x3) set @old_dbug=@@session.debug_dbug; SET debug_dbug="+d,kill_join_init_read_record"; SELECT 1 FROM t1 AS alias1, t1 AS alias2, t1 AS alias3 diff --git a/mysql-test/main/range_interrupted-13751.test b/mysql-test/main/range_interrupted-13751.test index b0793edeb9d..939f15b2145 100644 --- a/mysql-test/main/range_interrupted-13751.test +++ b/mysql-test/main/range_interrupted-13751.test @@ -1,17 +1,15 @@ --- source include/have_debug.inc +--source include/have_debug.inc --source include/default_optimizer_switch.inc +--source include/have_sequence.inc # # MDEV-13751 Interrupted SELECT fails with 1030: 'Got error 1 "Operation not permitted" from storage engine MyISAM' # CREATE TABLE t1 (i INT AUTO_INCREMENT, c VARCHAR(1), KEY(i), KEY(c,i)) ENGINE=MyISAM; -INSERT INTO t1 (c) VALUES ('a'),('b'),('c'),('d'); -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; -INSERT INTO t1 (c) SELECT c FROM t1; +INSERT INTO t1 (c) select mid("abcdefgh", mod(seq,8)+1, 1) from seq_1_to_256; + +explain SELECT 1 FROM t1 AS alias1, t1 AS alias2, t1 AS alias3 +WHERE alias1.c = alias2.c OR alias1.i <= 1; set @old_dbug=@@session.debug_dbug; SET debug_dbug="+d,kill_join_init_read_record"; diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result index a3c8bb7b8c2..1373faedf8e 100644 --- a/mysql-test/main/range_mrr_icp.result +++ b/mysql-test/main/range_mrr_icp.result @@ -255,7 +255,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref x x 5 const 1 Using index explain select count(*) from t1 where x in (1,2,3,4); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index x x 5 NULL 9 Using where; Using index +1 SIMPLE t1 range x x 5 NULL 4 Using where; Using index drop table t1; CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); @@ -264,12 +264,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); explain select * from t1, t2 where (t1.key1 'x'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL a NULL NULL NULL 2 Using where +1 SIMPLE t1 range a a 2 NULL 2 Using where select a from t1 where a > 'x'; a xx @@ -726,7 +736,7 @@ WHERE v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE v ALL OXLEFT,OXRIGHT,OXROOTID NULL NULL NULL 12 Using where +1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 6 Using index condition 1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4) SELECT s.oxid FROM t1 v, t1 s WHERE @@ -1141,7 +1151,7 @@ INSERT INTO t1 VALUES ('A2','2005-12-01 08:00:00',1000); EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where +1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 3 Using index condition SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; item started price Warnings: @@ -1239,13 +1249,16 @@ insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t2 (a int, b int, filler char(100)); insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, t1 B, t1 C where A.a < 5; -insert into t2 select 1000, b, 'filler' from t2 limit 250; +insert into t2 select 1000, b, 'filler' from t2 limit 50; +select count(*) from t2; +count(*) +550 alter table t2 add index (a,b); -# In following EXPLAIN the access method should be ref, #rows~=250 +# In following EXPLAIN the access method should be ref, #rows~=50 # (and not 2) when we are not using rowid-ordered scans explain select * from t2 where a=1000 and b<11; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range a a 10 NULL 253 Using index condition; Rowid-ordered scan +1 SIMPLE t2 range a a 10 NULL 63 Using index condition; Rowid-ordered scan drop table t1, t2; CREATE TABLE t1( a INT, b INT, KEY( a, b ) ); CREATE TABLE t2( a INT, b INT, KEY( a, b ) ); @@ -2565,7 +2578,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "rows": 3, - "filtered": 100, + "filtered": 60, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((3,3)),((7,7)),((2,2)))", "mrr_type": "Rowid-ordered scan" @@ -2644,7 +2657,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "rows": 8, - "filtered": 100, + "filtered": 14.42307663, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((3,3)),((7,7)),((8,8))) and octet_length(t2.f) = 1", "mrr_type": "Rowid-ordered scan" @@ -2660,7 +2673,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.d"], "rows": 8, - "filtered": 100 + "filtered": 73.17073059 } } ] @@ -2689,40 +2702,40 @@ prepare stmt from "select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(8,8)) and length(f) = 1"; execute stmt; a b c d e f -3 2 uuuw 3 3 i 3 2 uuua 3 3 i -3 3 zzzz 3 3 i +3 2 uuua 3 3 i +3 2 uuuw 3 3 i +3 2 uuuw 3 3 i +3 3 zyxa 3 3 i +3 3 zyxa 3 3 i +3 3 zyxw 3 3 i 3 3 zyxw 3 3 i 3 3 zzza 3 3 i -3 3 zyxa 3 3 i -7 7 xxxyy 7 7 h +3 3 zzza 3 3 i +3 3 zzzz 3 3 i +3 3 zzzz 3 3 i 7 7 xxxya 7 7 h -7 8 xxxxx 7 7 h +7 7 xxxyy 7 7 h 7 8 xxxxa 7 7 h -3 2 uuuw 3 3 i -3 2 uuua 3 3 i -3 3 zzzz 3 3 i -3 3 zyxw 3 3 i -3 3 zzza 3 3 i -3 3 zyxa 3 3 i +7 8 xxxxx 7 7 h execute stmt; a b c d e f -3 2 uuuw 3 3 i 3 2 uuua 3 3 i -3 3 zzzz 3 3 i +3 2 uuua 3 3 i +3 2 uuuw 3 3 i +3 2 uuuw 3 3 i +3 3 zyxa 3 3 i +3 3 zyxa 3 3 i +3 3 zyxw 3 3 i 3 3 zyxw 3 3 i 3 3 zzza 3 3 i -3 3 zyxa 3 3 i -7 7 xxxyy 7 7 h +3 3 zzza 3 3 i +3 3 zzzz 3 3 i +3 3 zzzz 3 3 i 7 7 xxxya 7 7 h -7 8 xxxxx 7 7 h +7 7 xxxyy 7 7 h 7 8 xxxxa 7 7 h -3 2 uuuw 3 3 i -3 2 uuua 3 3 i -3 3 zzzz 3 3 i -3 3 zyxw 3 3 i -3 3 zzza 3 3 i -3 3 zyxa 3 3 i +7 8 xxxxx 7 7 h deallocate prepare stmt; insert into t1 select * from t1; # join order: (t2,t1) with ref access of t1 @@ -2748,7 +2761,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "rows": 7, - "filtered": 100, + "filtered": 6.730769157, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((4,4)),((7,7)),((8,8))) and octet_length(t2.f) = 1", "mrr_type": "Rowid-ordered scan" @@ -3369,7 +3382,7 @@ insert into t2 select A.a + B.a*10 + C.a*100 from ten A, ten B,ten C where A.a + # expected type=range, rows=1487 , reason=using index dives analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198); id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 range a a 5 NULL 1487 1199.00 100.00 100.00 Using where; Using index +1 SIMPLE t1 index a a 5 NULL 2000 2000.00 74.35 59.95 Using where; Using index insert into t2 values (200),(201); # expected type=range, rows=201 , reason=using index statistics analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,200,201); diff --git a/mysql-test/main/range_notembedded.result b/mysql-test/main/range_notembedded.result index b3d2dfbb43b..d774c81d6e1 100644 --- a/mysql-test/main/range_notembedded.result +++ b/mysql-test/main/range_notembedded.result @@ -13,13 +13,19 @@ set @tmp_21958=@@optimizer_trace; set optimizer_trace=1; explain select * from t2 where key1 in (1,2,3) and pk not in (1,2,3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL PRIMARY,key1 NULL NULL NULL 5 Using where +1 SIMPLE t2 range PRIMARY,key1 key1 5 NULL 3 Using index condition # This should show only ranges in form "(1) <= (key1) <= (1)" # ranges over "pk" should not be constructed. select json_detailed(JSON_EXTRACT(trace, '$**.ranges')) from information_schema.optimizer_trace; json_detailed(JSON_EXTRACT(trace, '$**.ranges')) [ + [ + "(1) <= (key1) <= (1)", + "(2) <= (key1) <= (2)", + "(3) <= (key1) <= (3)" + ], + [ "(1) <= (key1) <= (1)", "(2) <= (key1) <= (2)", diff --git a/mysql-test/main/range_vs_index_merge.result b/mysql-test/main/range_vs_index_merge.result index 3babbc989b3..19848d6d388 100644 --- a/mysql-test/main/range_vs_index_merge.result +++ b/mysql-test/main/range_vs_index_merge.result @@ -333,7 +333,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT * FROM City WHERE (ID < 600) OR (ID BETWEEN 900 AND 1500); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range PRIMARY PRIMARY 4 NULL 1200 Using index condition +1 SIMPLE City ALL PRIMARY NULL NULL NULL 4079 Using where EXPLAIN SELECT * FROM City WHERE Country > 'A' AND Country < 'ARG'; id select_type table type possible_keys key key_len ref rows Extra @@ -1325,11 +1325,11 @@ WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) AND (Population >= 100000 AND Population < 120000) ORDER BY Population LIMIT 5; ID Name Country Population +3792 Tartu EST 101246 +518 Basildon GBR 100924 519 Worthing GBR 100000 638 al-Arish EGY 100447 -518 Basildon GBR 100924 707 Marbella ESP 101144 -3792 Tartu EST 101246 SHOW STATUS LIKE 'Handler_read_%'; Variable_name Value Handler_read_first 0 @@ -1750,6 +1750,9 @@ SELECT * FROM t1,t2,t3 WHERE (t2.f3 = 1 OR t3.f1=t2.f1) AND t3.f1 <> t2.f2 AND t3.f2 = t2.f4; f1 f1 f2 f3 f4 f1 f2 DROP TABLE t1,t2,t3; +# +# LP bug #823301: index merge sort union with possible index scan +# CREATE TABLE t1 ( a int, b int, c int, d int, PRIMARY KEY(b), INDEX idx1(d), INDEX idx2(d,b,c) @@ -1766,7 +1769,7 @@ EXPLAIN SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where +1 SIMPLE t1 range PRIMARY,idx1,idx2 idx1 5 NULL 5 Using index condition; Using where SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; a b c d @@ -1780,7 +1783,7 @@ EXPLAIN SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where +1 SIMPLE t1 range PRIMARY,idx1,idx2 idx1 5 NULL 5 Using index condition; Using where SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; a b c d @@ -1894,37 +1897,6 @@ INDEX (Percentage) DROP INDEX Country ON City; CREATE INDEX CountryName ON City(Country,Name); CREATE INDEX Name ON City(Name); -select * from City -where -Country='FIN' AND Name IN ('Lahti','Imatra') OR -Country='RUS' AND Name IN ('St Petersburg', 'Moscow') OR -Country='SWE' AND Name IN ('Stockholm', 'Uppsala') OR -Country='DEU' AND Name IN ('Berlin', 'Bonn') OR -Country='BEL' AND Name IN ('Antwerpen', 'Gent') OR -Country='PRT' AND Name IN ('Braga', 'Porto') OR -Country='FRA' AND Name IN ('Paris', 'Marcel') OR -Country='POL' AND Name IN ('Warszawa', 'Wroclaw') OR -Country='NOR' AND Name IN ('Oslo', 'Bergen') OR -Country='ITA' AND Name IN ('Napoli', 'Venezia'); -ID Name Country Population -175 Antwerpen BEL 446525 -176 Gent BEL 224180 -3068 Berlin DEU 3386667 -3087 Bonn DEU 301048 -3242 Lahti FIN 96921 -2974 Paris FRA 2125246 -1466 Napoli ITA 1002619 -1474 Venezia ITA 277305 -2808 Bergen NOR 230948 -2807 Oslo NOR 508726 -2928 Warszawa POL 1615369 -2931 Wroclaw POL 636765 -2918 Braga PRT 90535 -2915 Porto PRT 273060 -3580 Moscow RUS 8389200 -3581 St Petersburg RUS 4694000 -3048 Stockholm SWE 750348 -3051 Uppsala SWE 189569 explain select * from City where Country='FIN' AND Name IN ('Lahti','Imatra') OR @@ -1939,5 +1911,36 @@ Country='NOR' AND Name IN ('Oslo', 'Bergen') OR Country='ITA' AND Name IN ('Napoli', 'Venezia'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City range CountryName,Name CountryName 38 NULL 20 Using index condition +select * from City +where +Country='FIN' AND Name IN ('Lahti','Imatra') OR +Country='RUS' AND Name IN ('St Petersburg', 'Moscow') OR +Country='SWE' AND Name IN ('Stockholm', 'Uppsala') OR +Country='DEU' AND Name IN ('Berlin', 'Bonn') OR +Country='BEL' AND Name IN ('Antwerpen', 'Gent') OR +Country='PRT' AND Name IN ('Braga', 'Porto') OR +Country='FRA' AND Name IN ('Paris', 'Marcel') OR +Country='POL' AND Name IN ('Warszawa', 'Wroclaw') OR +Country='NOR' AND Name IN ('Oslo', 'Bergen') OR +Country='ITA' AND Name IN ('Napoli', 'Venezia'); +ID Name Country Population +1466 Napoli ITA 1002619 +1474 Venezia ITA 277305 +175 Antwerpen BEL 446525 +176 Gent BEL 224180 +2807 Oslo NOR 508726 +2808 Bergen NOR 230948 +2915 Porto PRT 273060 +2918 Braga PRT 90535 +2928 Warszawa POL 1615369 +2931 Wroclaw POL 636765 +2974 Paris FRA 2125246 +3048 Stockholm SWE 750348 +3051 Uppsala SWE 189569 +3068 Berlin DEU 3386667 +3087 Bonn DEU 301048 +3242 Lahti FIN 96921 +3580 Moscow RUS 8389200 +3581 St Petersburg RUS 4694000 DROP DATABASE world; set session optimizer_switch='index_merge_sort_intersection=default'; diff --git a/mysql-test/main/range_vs_index_merge.test b/mysql-test/main/range_vs_index_merge.test index 6517beab0be..14d75b88bfa 100644 --- a/mysql-test/main/range_vs_index_merge.test +++ b/mysql-test/main/range_vs_index_merge.test @@ -714,6 +714,7 @@ SELECT * FROM City ORDER BY Population LIMIT 5; FLUSH STATUS; +--sorted_result SELECT * FROM City WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) AND (Population >= 100000 AND Population < 120000) @@ -1174,9 +1175,9 @@ SELECT * FROM t1,t2,t3 DROP TABLE t1,t2,t3; -# -# LP bug #823301: index merge sort union with possible index scan -# +--echo # +--echo # LP bug #823301: index merge sort union with possible index scan +--echo # CREATE TABLE t1 ( a int, b int, c int, d int, @@ -1192,12 +1193,14 @@ SET SESSION optimizer_switch='index_merge_sort_union=off'; EXPLAIN SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +--sorted_result SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; SET SESSION optimizer_switch='index_merge_sort_union=on'; EXPLAIN SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +--sorted_result SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; SET SESSION optimizer_switch=DEFAULT; @@ -1320,12 +1323,11 @@ where Country='NOR' AND Name IN ('Oslo', 'Bergen') OR Country='ITA' AND Name IN ('Napoli', 'Venezia'); -eval $q; eval explain $q; - +--sorted_result +eval $q; DROP DATABASE world; #the following command must be the last one in the file set session optimizer_switch='index_merge_sort_intersection=default'; - diff --git a/mysql-test/main/range_vs_index_merge_innodb.result b/mysql-test/main/range_vs_index_merge_innodb.result index de345f66161..8e0bf58fbc3 100644 --- a/mysql-test/main/range_vs_index_merge_innodb.result +++ b/mysql-test/main/range_vs_index_merge_innodb.result @@ -365,7 +365,7 @@ WHERE ((ID < 800) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG'))) OR ((ID BETWEEN 900 AND 1500) AND (Name LIKE 'Pa%' OR (Population > 103000 AND Population < 105000))); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,Population 39,3,4 NULL 212 Using sort_union(Name,Country,Population); Using where +1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,PRIMARY 39,3,4 NULL 683 Using sort_union(Name,Country,PRIMARY); Using where EXPLAIN SELECT * FROM City WHERE ((ID < 200) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG'))) @@ -620,7 +620,7 @@ WHERE ((Population > 101000 AND Population < 102000) AND ((ID BETWEEN 3400 AND 3800) AND (Country < 'AGO' OR Name LIKE 'Pa%')); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City index_merge PRIMARY,Population,Country,Name Country,Name,Population 3,39,4 NULL 115 Using sort_union(Country,Name,Population); Using where +1 SIMPLE City index_merge PRIMARY,Population,Country,Name Population,PRIMARY 4,4 NULL 440 Using sort_union(Population,PRIMARY); Using where EXPLAIN SELECT * FROM City WHERE ((Population > 101000 AND Population < 110000) AND @@ -1331,11 +1331,11 @@ WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) AND (Population >= 100000 AND Population < 120000) ORDER BY Population LIMIT 5; ID Name Country Population +3792 Tartu EST 101246 +518 Basildon GBR 100924 519 Worthing GBR 100000 638 al-Arish EGY 100447 -518 Basildon GBR 100924 707 Marbella ESP 101144 -3792 Tartu EST 101246 SHOW STATUS LIKE 'Handler_read_%'; Variable_name Value Handler_read_first 0 @@ -1756,6 +1756,9 @@ SELECT * FROM t1,t2,t3 WHERE (t2.f3 = 1 OR t3.f1=t2.f1) AND t3.f1 <> t2.f2 AND t3.f2 = t2.f4; f1 f1 f2 f3 f4 f1 f2 DROP TABLE t1,t2,t3; +# +# LP bug #823301: index merge sort union with possible index scan +# CREATE TABLE t1 ( a int, b int, c int, d int, PRIMARY KEY(b), INDEX idx1(d), INDEX idx2(d,b,c) @@ -1772,7 +1775,7 @@ EXPLAIN SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where +1 SIMPLE t1 range PRIMARY,idx1,idx2 idx1 5 NULL 5 Using index condition SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; a b c d @@ -1786,7 +1789,7 @@ EXPLAIN SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where +1 SIMPLE t1 range PRIMARY,idx1,idx2 idx1 5 NULL 5 Using index condition SELECT * FROM t1 WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; a b c d @@ -1900,37 +1903,6 @@ INDEX (Percentage) DROP INDEX Country ON City; CREATE INDEX CountryName ON City(Country,Name); CREATE INDEX Name ON City(Name); -select * from City -where -Country='FIN' AND Name IN ('Lahti','Imatra') OR -Country='RUS' AND Name IN ('St Petersburg', 'Moscow') OR -Country='SWE' AND Name IN ('Stockholm', 'Uppsala') OR -Country='DEU' AND Name IN ('Berlin', 'Bonn') OR -Country='BEL' AND Name IN ('Antwerpen', 'Gent') OR -Country='PRT' AND Name IN ('Braga', 'Porto') OR -Country='FRA' AND Name IN ('Paris', 'Marcel') OR -Country='POL' AND Name IN ('Warszawa', 'Wroclaw') OR -Country='NOR' AND Name IN ('Oslo', 'Bergen') OR -Country='ITA' AND Name IN ('Napoli', 'Venezia'); -ID Name Country Population -175 Antwerpen BEL 446525 -2808 Bergen NOR 230948 -3068 Berlin DEU 3386667 -3087 Bonn DEU 301048 -2918 Braga PRT 90535 -176 Gent BEL 224180 -3242 Lahti FIN 96921 -3580 Moscow RUS 8389200 -1466 Napoli ITA 1002619 -2807 Oslo NOR 508726 -2974 Paris FRA 2125246 -2915 Porto PRT 273060 -3581 St Petersburg RUS 4694000 -3048 Stockholm SWE 750348 -3051 Uppsala SWE 189569 -1474 Venezia ITA 277305 -2928 Warszawa POL 1615369 -2931 Wroclaw POL 636765 explain select * from City where Country='FIN' AND Name IN ('Lahti','Imatra') OR @@ -1945,6 +1917,37 @@ Country='NOR' AND Name IN ('Oslo', 'Bergen') OR Country='ITA' AND Name IN ('Napoli', 'Venezia'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City range CountryName,Name Name 35 NULL 20 Using index condition; Using where +select * from City +where +Country='FIN' AND Name IN ('Lahti','Imatra') OR +Country='RUS' AND Name IN ('St Petersburg', 'Moscow') OR +Country='SWE' AND Name IN ('Stockholm', 'Uppsala') OR +Country='DEU' AND Name IN ('Berlin', 'Bonn') OR +Country='BEL' AND Name IN ('Antwerpen', 'Gent') OR +Country='PRT' AND Name IN ('Braga', 'Porto') OR +Country='FRA' AND Name IN ('Paris', 'Marcel') OR +Country='POL' AND Name IN ('Warszawa', 'Wroclaw') OR +Country='NOR' AND Name IN ('Oslo', 'Bergen') OR +Country='ITA' AND Name IN ('Napoli', 'Venezia'); +ID Name Country Population +1466 Napoli ITA 1002619 +1474 Venezia ITA 277305 +175 Antwerpen BEL 446525 +176 Gent BEL 224180 +2807 Oslo NOR 508726 +2808 Bergen NOR 230948 +2915 Porto PRT 273060 +2918 Braga PRT 90535 +2928 Warszawa POL 1615369 +2931 Wroclaw POL 636765 +2974 Paris FRA 2125246 +3048 Stockholm SWE 750348 +3051 Uppsala SWE 189569 +3068 Berlin DEU 3386667 +3087 Bonn DEU 301048 +3242 Lahti FIN 96921 +3580 Moscow RUS 8389200 +3581 St Petersburg RUS 4694000 DROP DATABASE world; set session optimizer_switch='index_merge_sort_intersection=default'; set global innodb_stats_persistent= @innodb_stats_persistent_save; diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index b68d9891bf1..48a01b31e64 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -242,7 +242,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 509, - "filtered": 100, + "filtered": 11.69025803, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" } @@ -254,7 +254,7 @@ set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_orderkey, WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 509 510.00 100.00 11.76 Using index condition; Using where +1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 509 510.00 11.69 11.76 Using index condition; Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45; @@ -281,7 +281,7 @@ ANALYZE "r_rows": 510, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 11.69025803, "r_filtered": 11.76470588, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -647,8 +647,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 139 Using index condition -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (9%) Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -659,23 +659,10 @@ EXPLAIN "query_block": { "select_id": 1, "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 139, - "filtered": 100, - "index_condition": "orders.o_totalprice between 180000 and 230000" - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", @@ -683,21 +670,43 @@ EXPLAIN "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_orderkey", + "key": "i_l_shipdate", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], + "used_key_parts": ["l_shipDATE"], "rowid_filter": { "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] }, - "rows": 509, - "selectivity_pct": 8.476269775 + "rows": 702, + "selectivity_pct": 11.69025812 }, - "rows": 4, - "filtered": 0.990897834, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "rows": 509, + "filtered": 11.69025803, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 139, + "selectivity_pct": 9.266666667 + }, + "rows": 1, + "filtered": 9.266666412, + "attached_condition": "orders.o_totalprice between 180000 and 230000" } } ] @@ -709,8 +718,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 139 144.00 100.00 100.00 Using index condition -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) 0.54 (8%) 0.99 20.51 Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) 60.00 (11%) 11.69 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (9%) 0.27 (25%) 9.27 100.00 Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -726,28 +735,10 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 139, - "r_rows": 144, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "index_condition": "orders.o_totalprice between 180000 and 230000" - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", @@ -755,31 +746,63 @@ ANALYZE "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_orderkey", + "key": "i_l_shipdate", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], + "used_key_parts": ["l_shipDATE"], "rowid_filter": { "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] }, - "rows": 509, - "selectivity_pct": 8.476269775, - "r_rows": 510, - "r_lookups": 954, - "r_selectivity_pct": 8.176100629, + "rows": 702, + "selectivity_pct": 11.69025812, + "r_rows": 605, + "r_lookups": 510, + "r_selectivity_pct": 11.76470588, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, - "r_loops": 144, - "rows": 4, - "r_rows": 0.541666667, + "r_loops": 1, + "rows": 509, + "r_rows": 60, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 0.990897834, - "r_filtered": 20.51282051, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "filtered": 11.69025803, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 139, + "selectivity_pct": 9.266666667, + "r_rows": 144, + "r_lookups": 59, + "r_selectivity_pct": 25.42372881, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 60, + "rows": 1, + "r_rows": 0.266666667, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 9.266666412, + "r_filtered": 100, + "attached_condition": "orders.o_totalprice between 180000 and 230000" } } ] @@ -813,8 +836,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 139 Using index condition -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 509 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -825,23 +848,10 @@ EXPLAIN "query_block": { "select_id": 1, "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 139, - "filtered": 100, - "index_condition": "orders.o_totalprice between 180000 and 230000" - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", @@ -849,13 +859,27 @@ EXPLAIN "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_orderkey", + "key": "i_l_shipdate", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 0.990897834, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "used_key_parts": ["l_shipDATE"], + "rows": 509, + "filtered": 11.69025803, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 9.266666412, + "attached_condition": "orders.o_totalprice between 180000 and 230000" } } ] @@ -867,8 +891,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 139 144.00 100.00 100.00 Using index condition -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.62 0.99 1.68 Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 509 510.00 11.69 11.76 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.27 26.67 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -884,28 +908,10 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 139, - "r_rows": 144, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "index_condition": "orders.o_totalprice between 180000 and 230000" - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", @@ -913,18 +919,37 @@ ANALYZE "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_orderkey", + "key": "i_l_shipdate", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 144, - "rows": 4, - "r_rows": 6.625, + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 509, + "r_rows": 510, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 0.990897834, - "r_filtered": 1.677148847, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "filtered": 11.69025803, + "r_filtered": 11.76470588, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 60, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 9.266666412, + "r_filtered": 26.66666667, + "attached_condition": "orders.o_totalprice between 180000 and 230000" } } ] @@ -1341,7 +1366,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, - "filtered": 100, + "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" } @@ -1370,7 +1395,7 @@ l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND o_totalprice BETWEEN 200000 AND 250000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 100.00 38.89 Using index condition; Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 0.57 38.89 Using index condition; Using where 1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 7.47 14.29 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice FROM orders, lineitem @@ -1407,7 +1432,7 @@ ANALYZE "r_rows": 18, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 0.566194832, "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" @@ -1478,7 +1503,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, - "filtered": 100, + "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" } @@ -1507,7 +1532,7 @@ l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND o_totalprice BETWEEN 200000 AND 250000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 100.00 38.89 Using index condition; Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 0.57 38.89 Using index condition; Using where 1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 7.47 14.29 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice FROM orders, lineitem @@ -1544,7 +1569,7 @@ ANALYZE "r_rows": 18, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 0.566194832, "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" @@ -1595,7 +1620,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) Using where; Using rowid filter +1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1616,7 +1641,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 39, - "filtered": 100, + "filtered": 3.200000048, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" } @@ -1631,7 +1656,7 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "i_l_orderkey", + "key": "PRIMARY", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -1658,8 +1683,8 @@ o_totaldiscount BETWEEN 18000 AND 20000 AND o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 100.00 2.44 Using index condition; Using where -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) 4.00 (66%) 3.05 100.00 Using where; Using rowid filter +1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 3.20 2.44 Using index condition; Using where +1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) 4.00 (66%) 3.05 100.00 Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1689,7 +1714,7 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 3.200000048, "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" @@ -1705,7 +1730,7 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "i_l_orderkey", + "key": "PRIMARY", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -1754,7 +1779,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1775,7 +1800,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 39, - "filtered": 100, + "filtered": 3.200000048, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" } @@ -1790,7 +1815,7 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "i_l_orderkey", + "key": "PRIMARY", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -1809,8 +1834,8 @@ o_totaldiscount BETWEEN 18000 AND 20000 AND o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 100.00 2.44 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where +1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 3.20 2.44 Using index condition; Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1840,7 +1865,7 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 3.200000048, "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" @@ -1856,7 +1881,7 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "i_l_orderkey", + "key": "PRIMARY", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -1895,7 +1920,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) Using where; Using rowid filter +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM v1, lineitem WHERE o_orderkey=l_orderkey AND @@ -1936,18 +1961,10 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "i_l_orderkey", + "key": "PRIMARY", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 183, - "selectivity_pct": 3.04746045 - }, "rows": 4, "filtered": "REPLACED", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" @@ -1964,7 +1981,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 # 2.44 Using index condition; Using where -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) 4.00 (66%) # 100.00 Using where; Using rowid filter +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM v1, lineitem WHERE o_orderkey=l_orderkey AND @@ -2015,30 +2032,17 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "i_l_orderkey", + "key": "PRIMARY", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 183, - "selectivity_pct": 3.04746045, - "r_rows": 183, - "r_lookups": 6, - "r_selectivity_pct": 66.66666667, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, "r_loops": 1, "rows": 4, - "r_rows": 4, + "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", - "r_filtered": 100, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -2064,7 +2068,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM v1, lineitem WHERE o_orderkey=l_orderkey AND @@ -2105,7 +2109,7 @@ EXPLAIN "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "i_l_orderkey", + "key": "PRIMARY", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -2125,7 +2129,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 # 2.44 Using index condition; Using where -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM v1, lineitem WHERE o_orderkey=l_orderkey AND @@ -2176,7 +2180,7 @@ ANALYZE "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "i_l_orderkey", + "key": "PRIMARY", "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], @@ -2277,7 +2281,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING -2 SUBQUERY t2 ref i1,i2 i1 5 const 1 100.00 Using index condition; Using where +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` having 0 DROP TABLE t1,t2; @@ -2324,6 +2328,15 @@ pk1 a1 b1 pk2 a2 b2 EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 +1 PRIMARY t1 ALL a1,b1 NULL NULL NULL 400 2.61 Using where; Using join buffer (flat, BNL join) +2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t1`.`pk1` + 1 = `test`.`t2`.`pk2` + 2 +set @@optimizer_where_cost=0.0356*4; +EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) +WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); +id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where 1 PRIMARY t1 ref|filter a1,b1 a1|b1 5|4 test.t2.a2 36 (29%) 28.75 Using where; Using rowid filter 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition @@ -2392,6 +2405,7 @@ EXPLAIN ] } } +set @@optimizer_where_cost=default; DROP TABLE t1,t2; # # MDEV-21794: Optimizer flag rowid_filter leads to long query @@ -2436,87 +2450,16 @@ drop table t10, t11, t1; set @save_optimizer_switch= @@optimizer_switch; SET @@optimizer_switch="index_merge_sort_union=OFF"; CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)); -INSERT INTO t1 VALUES (0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4); -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -ANALYZE table t1 PERSISTENT FOR ALL; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status OK +INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0); explain SELECT * FROM t1 WHERE a > 0 AND b=0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range|filter a,b a|b 5|5 NULL 77 (34%) Using index condition; Using where; Using rowid filter +1 SIMPLE t1 ref|filter a,b b|a 5|5 const 7 (47%) Using where; Using rowid filter SELECT * FROM t1 WHERE a > 0 AND b=0; a b 1 0 1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 +2 0 drop table t1; SET @@optimizer_switch=@save_optimizer_switch; # @@ -2579,7 +2522,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 49.20000076, "r_filtered": 100, "index_condition": "t1.nm like '500%'", "attached_condition": "t1.fl2 = 0" @@ -2632,7 +2575,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 49.20000076, "r_filtered": 100, "index_condition": "t1.nm like '500%'", "attached_condition": "t1.fl2 = 0" @@ -2819,13 +2762,26 @@ ANALYZE "key": "idx1", "key_length": "256", "used_key_parts": ["nm"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["fl2"] + }, + "rows": 863, + "selectivity_pct": 8.63, + "r_rows": 1000, + "r_lookups": 44, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, "r_loops": 1, "rows": 44, - "r_rows": 44, + "r_rows": 0, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 0, + "filtered": 8.630000114, + "r_filtered": 100, "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", "attached_condition": "t1.fl2 = 0" } @@ -2872,12 +2828,25 @@ ANALYZE "key": "idx1", "key_length": "256", "used_key_parts": ["nm"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["fl2"] + }, + "rows": 853, + "selectivity_pct": 8.53, + "r_rows": 987, + "r_lookups": 0, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, "r_loops": 1, "rows": 44, "r_rows": 0, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 8.529999733, "r_filtered": 100, "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", "attached_condition": "t1.fl2 = 0" @@ -2927,8 +2896,8 @@ pk a b c 7 5 k 5 explain SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where -1 SIMPLE t1 ref|filter PRIMARY,a,a_2 a|PRIMARY 5|4 test.t2.c 3 (4%) Using where; Using rowid filter +1 SIMPLE t1 range|filter PRIMARY,a,a_2 PRIMARY|a 4|5 NULL 4 (11%) Using index condition; Using where; Using rowid filter +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) SET optimizer_switch='rowid_filter=off'; SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; pk a b c diff --git a/mysql-test/main/rowid_filter.test b/mysql-test/main/rowid_filter.test index 3718ba051bd..519723b4f29 100644 --- a/mysql-test/main/rowid_filter.test +++ b/mysql-test/main/rowid_filter.test @@ -361,7 +361,10 @@ SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) eval $q; eval EXPLAIN EXTENDED $q; +set @@optimizer_where_cost=0.0356*4; +eval EXPLAIN EXTENDED $q; eval EXPLAIN FORMAT=JSON $q; +set @@optimizer_where_cost=default; DROP TABLE t1,t2; @@ -410,16 +413,7 @@ drop table t10, t11, t1; set @save_optimizer_switch= @@optimizer_switch; SET @@optimizer_switch="index_merge_sort_union=OFF"; CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)); -INSERT INTO t1 VALUES (0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4); -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; - -ANALYZE table t1 PERSISTENT FOR ALL; - +INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0); explain SELECT * FROM t1 WHERE a > 0 AND b=0; SELECT * FROM t1 WHERE a > 0 AND b=0; diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index d4507d224d0..56a7061ddf7 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -362,8 +362,8 @@ FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 71 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 Using where; Using index +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND @@ -373,37 +373,37 @@ EXPLAIN "query_block": { "select_id": 1, "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 71, - "filtered": 100, - "attached_condition": "orders.o_totalprice between 200000 and 230000", - "using_index": true - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", "i_l_orderkey", "i_l_orderkey_quantity" ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 98, + "filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], "key": "PRIMARY", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 1.633319736, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 4.733333111, + "attached_condition": "orders.o_totalprice between 200000 and 230000" } } ] @@ -414,8 +414,8 @@ FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 71 71.00 100.00 100.00 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.70 1.63 2.31 Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 98.00 100.00 100.00 Using where; Using index +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 4.73 11.22 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND @@ -430,47 +430,47 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 71, - "r_rows": 71, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "orders.o_totalprice between 200000 and 230000", - "using_index": true - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_shipdate", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 71, - "rows": 4, - "r_rows": 6.704225352, + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 98, + "r_rows": 98, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 1.633319736, - "r_filtered": 2.31092437, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + "filtered": 100, + "r_filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 98, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.733333111, + "r_filtered": 11.2244898, + "attached_condition": "orders.o_totalprice between 200000 and 230000" } } ] @@ -497,8 +497,8 @@ FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 71 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 Using where; Using index +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND @@ -508,37 +508,37 @@ EXPLAIN "query_block": { "select_id": 1, "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 71, - "filtered": 100, - "attached_condition": "orders.o_totalprice between 200000 and 230000", - "using_index": true - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", "i_l_orderkey", "i_l_orderkey_quantity" ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 98, + "filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], "key": "PRIMARY", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 1.633319736, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 4.733333111, + "attached_condition": "orders.o_totalprice between 200000 and 230000" } } ] @@ -549,8 +549,8 @@ FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 71 71.00 100.00 100.00 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.70 1.63 2.31 Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 98.00 100.00 100.00 Using where; Using index +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 4.73 11.22 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND @@ -565,47 +565,47 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 71, - "r_rows": 71, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "orders.o_totalprice between 200000 and 230000", - "using_index": true - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", "i_l_orderkey", "i_l_orderkey_quantity" ], - "key": "PRIMARY", + "key": "i_l_shipdate", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 71, - "rows": 4, - "r_rows": 6.704225352, + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 98, + "r_rows": 98, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 1.633319736, - "r_filtered": 2.31092437, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + "filtered": 100, + "r_filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 98, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.733333111, + "r_filtered": 11.2244898, + "attached_condition": "orders.o_totalprice between 200000 and 230000" } } ] @@ -633,8 +633,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 144 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -645,24 +645,10 @@ EXPLAIN "query_block": { "select_id": 1, "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 144, - "filtered": 100, - "attached_condition": "orders.o_totalprice between 180000 and 230000", - "using_index": true - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", @@ -670,13 +656,35 @@ EXPLAIN "i_l_orderkey_quantity", "i_l_quantity" ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 605, + "selectivity_pct": 10.07493755 + }, + "rows": 510, + "filtered": 10.07493782, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], "key": "PRIMARY", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 0.856362581, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 9.600000381, + "attached_condition": "orders.o_totalprice between 180000 and 230000" } } ] @@ -688,8 +696,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 144 144.00 100.00 100.00 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.62 0.86 1.68 Using where +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) 60.00 (11%) 10.07 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.60 26.67 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -705,29 +713,10 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ - { - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 144, - "r_rows": 144, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "orders.o_totalprice between 180000 and 230000", - "using_index": true - } - }, { "table": { "table_name": "lineitem", - "access_type": "ref", + "access_type": "range", "possible_keys": [ "PRIMARY", "i_l_shipdate", @@ -735,18 +724,50 @@ ANALYZE "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "PRIMARY", + "key": "i_l_shipdate", "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 144, - "rows": 4, - "r_rows": 6.625, + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 605, + "selectivity_pct": 10.07493755, + "r_rows": 605, + "r_lookups": 510, + "r_selectivity_pct": 11.76470588, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 510, + "r_rows": 60, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 0.856362581, - "r_filtered": 1.677148847, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "filtered": 10.07493782, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 60, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 9.600000381, + "r_filtered": 26.66666667, + "attached_condition": "orders.o_totalprice between 180000 and 230000" } } ] @@ -822,7 +843,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 0.856362581, + "filtered": 0.855656624, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" } } @@ -891,7 +912,7 @@ ANALYZE "r_rows": 6.625, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 0.856362581, + "filtered": 0.855656624, "r_filtered": 1.677148847, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" } @@ -974,7 +995,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 8.499929428, + "filtered": 8.492922783, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -987,7 +1008,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 71 71.00 100.00 100.00 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.70 8.50 7.77 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.70 8.49 7.77 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -1040,7 +1061,7 @@ ANALYZE "r_rows": 6.704225352, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 8.499929428, + "filtered": 8.492922783, "r_filtered": 7.773109244, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } @@ -1135,7 +1156,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 8.499929428, + "filtered": 8.492922783, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } @@ -1148,7 +1169,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 71 71.00 100.00 100.00 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.70 8.50 7.77 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.70 8.49 7.77 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -1201,7 +1222,7 @@ ANALYZE "r_rows": 6.704225352, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 8.499929428, + "filtered": 8.492922783, "r_filtered": 7.773109244, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } @@ -1588,7 +1609,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 3.04997468, + "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1658,7 +1679,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 3.04997468, + "filtered": 3.047460556, "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1726,7 +1747,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, - "filtered": 3.04997468, + "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } @@ -1796,7 +1817,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 3.04997468, + "filtered": 3.047460556, "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -2187,7 +2208,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING -2 SUBQUERY t2 ref i1,i2 i1 5 const 1 10.00 Using index condition; Using where +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` having 0 DROP TABLE t1,t2; @@ -2234,6 +2255,15 @@ pk1 a1 b1 pk2 a2 b2 EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 +1 PRIMARY t1 ALL a1,b1 NULL NULL NULL 400 2.61 Using where; Using join buffer (flat, BNL join) +2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t1`.`pk1` + 1 = `test`.`t2`.`pk2` + 2 +set @@optimizer_where_cost=0.0356*4; +EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) +WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); +id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where 1 PRIMARY t1 ref|filter a1,b1 a1|b1 5|4 test.t2.a2 36 (29%) 28.75 Using where; Using rowid filter 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition @@ -2264,9 +2294,17 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a1"], "ref": ["test.t2.a2"], - "rows": 1, - "filtered": 87, - "attached_condition": "t1.b1 <= (subquery#2)" + "rowid_filter": { + "range": { + "key": "b1", + "used_key_parts": ["b1"] + }, + "rows": 115, + "selectivity_pct": 28.75 + }, + "rows": 36, + "filtered": 28.75, + "attached_condition": "t1.b1 <= (subquery#2) and t1.pk1 + 1 = t2.pk2 + 2" } } ], @@ -2294,6 +2332,7 @@ EXPLAIN ] } } +set @@optimizer_where_cost=default; DROP TABLE t1,t2; # # MDEV-21794: Optimizer flag rowid_filter leads to long query @@ -2330,7 +2369,7 @@ explain select * from t1 where el_index like '10%' and (el_index_60 like '10%' or el_index_60 like '20%'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL el_index,el_index_60 NULL NULL NULL 10000 Using where +1 SIMPLE t1 range el_index,el_index_60 el_index 62 NULL 1000 Using where drop table t10, t11, t1; # # MDEV-22160: SIGSEGV in st_join_table::save_explain_data on SELECT @@ -2338,87 +2377,16 @@ drop table t10, t11, t1; set @save_optimizer_switch= @@optimizer_switch; SET @@optimizer_switch="index_merge_sort_union=OFF"; CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)); -INSERT INTO t1 VALUES (0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4); -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -ANALYZE table t1 PERSISTENT FOR ALL; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status OK +INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0); explain SELECT * FROM t1 WHERE a > 0 AND b=0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range|filter a,b a|b 5|5 NULL 64 (29%) Using index condition; Using where; Using rowid filter +1 SIMPLE t1 ref|filter a,b b|a 5|5 const 7 (47%) Using where; Using rowid filter SELECT * FROM t1 WHERE a > 0 AND b=0; a b 1 0 1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 +2 0 drop table t1; SET @@optimizer_switch=@save_optimizer_switch; # @@ -2481,7 +2449,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 49.20000076, "r_filtered": 100, "index_condition": "t1.nm like '500%'", "attached_condition": "t1.fl2 = 0" @@ -2534,7 +2502,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 49.20000076, "r_filtered": 100, "index_condition": "t1.nm like '500%'", "attached_condition": "t1.fl2 = 0" @@ -2721,13 +2689,26 @@ ANALYZE "key": "idx1", "key_length": "256", "used_key_parts": ["nm"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["fl2"] + }, + "rows": 863, + "selectivity_pct": 8.63, + "r_rows": 1000, + "r_lookups": 44, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, "r_loops": 1, "rows": 44, - "r_rows": 44, + "r_rows": 0, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 0, + "filtered": 8.630000114, + "r_filtered": 100, "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", "attached_condition": "t1.fl2 = 0" } @@ -2774,12 +2755,25 @@ ANALYZE "key": "idx1", "key_length": "256", "used_key_parts": ["nm"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["fl2"] + }, + "rows": 853, + "selectivity_pct": 8.53, + "r_rows": 987, + "r_lookups": 0, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, "r_loops": 1, "rows": 44, "r_rows": 0, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 100, + "filtered": 8.529999733, "r_filtered": 100, "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", "attached_condition": "t1.fl2 = 0" @@ -2879,8 +2873,8 @@ union ( select * from t1 where (f1 is null and f2 is null) and (f2 between 'a' and 'z' or f1 in ('a'))); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index_merge f1,f2 f1,f2 13,33 NULL 1 Using intersect(f1,f2); Using where -2 UNION t1 index_merge f1,f2 f1,f2 13,33 NULL 1 Using intersect(f1,f2); Using where +1 PRIMARY t1 ref|filter f1,f2 f1|f1 13|13 const 1 (2%) Using index condition; Using where; Using rowid filter +2 UNION t1 ref|filter f1,f2 f1|f1 13|13 const 1 (2%) Using index condition; Using where; Using rowid filter NULL UNION RESULT ALL NULL NULL NULL NULL NULL explain format=json ( select * from t1 where (f1 is null and f2 is null) and (f2 between 'a' and 'z' or f1 in ('a'))) @@ -2901,28 +2895,24 @@ EXPLAIN { "table": { "table_name": "t1", - "access_type": "index_merge", + "access_type": "ref", "possible_keys": ["f1", "f2"], - "key_length": "13,33", - "index_merge": { - "intersect": [ - { - "range": { - "key": "f1", - "used_key_parts": ["f1"] - } - }, - { - "range": { - "key": "f2", - "used_key_parts": ["f2"] - } - } - ] + "key": "f1", + "key_length": "13", + "used_key_parts": ["f1"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "f1", + "used_key_parts": ["f1"] + }, + "rows": 1, + "selectivity_pct": 1.587301587 }, "rows": 1, "filtered": 1.587301612, - "attached_condition": "t1.f1 is null and t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" + "index_condition": "t1.f1 is null", + "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" } } ] @@ -2936,28 +2926,24 @@ EXPLAIN { "table": { "table_name": "t1", - "access_type": "index_merge", + "access_type": "ref", "possible_keys": ["f1", "f2"], - "key_length": "13,33", - "index_merge": { - "intersect": [ - { - "range": { - "key": "f1", - "used_key_parts": ["f1"] - } - }, - { - "range": { - "key": "f2", - "used_key_parts": ["f2"] - } - } - ] + "key": "f1", + "key_length": "13", + "used_key_parts": ["f1"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "f1", + "used_key_parts": ["f1"] + }, + "rows": 1, + "selectivity_pct": 1.587301587 }, "rows": 1, "filtered": 1.587301612, - "attached_condition": "t1.f1 is null and t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" + "index_condition": "t1.f1 is null", + "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" } } ] @@ -2983,8 +2969,8 @@ id y x 1 2 1 explain extended select * from t1 join t2 on t1.id = t2.x where t2.y = 2 and t1.id = 1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 # -1 SIMPLE t2 index_merge x,y y,x 5,5 NULL 1 # Using intersect(y,x); Using where; Using index +1 SIMPLE t1 const PRIMARY PRIMARY 4 const # # +1 SIMPLE t2 ref|filter x,y y|x 5|5 const # # Using where; Using rowid filter Warnings: Note 1003 select 1 AS `id`,`test`.`t2`.`y` AS `y`,`test`.`t2`.`x` AS `x` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`y` = 2 and `test`.`t2`.`x` = 1 drop table t1, t2; @@ -3005,7 +2991,7 @@ count(*) 5 explain extended select count(*) from t1 where a between 21 and 30 and b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range b,a a 5 NULL 33 5.90 Using index condition; Using where +1 SIMPLE t1 ref b,a b 5 const 24 9.60 Using where Warnings: Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` between 21 and 30 select * from t1 where a between 21 and 30 and b=2; @@ -3058,12 +3044,12 @@ Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED -SELECT a FROM t1 WHERE c < 'k' AND b > 't' ORDER BY a; +SELECT a FROM t1 WHERE c < 'e' AND b > 't' ORDER BY a; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range|filter b,c b|c 13|1027 NULL 5 (42%) 41.67 Using index condition; Using where; Using filesort; Using rowid filter +1 SIMPLE t1 range|filter b,c b|c 13|1027 NULL 5 (21%) 20.83 Using index condition; Using where; Using filesort; Using rowid filter Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`c` < 'k' and `test`.`t1`.`b` > 't' order by `test`.`t1`.`a` -SELECT a FROM t1 WHERE c < 'k' AND b > 't' ORDER BY a; +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`c` < 'e' and `test`.`t1`.`b` > 't' order by `test`.`t1`.`a` +SELECT a FROM t1 WHERE c < 'e' AND b > 't' ORDER BY a; a 1 5 @@ -3106,11 +3092,11 @@ t1.id2 = t1.id); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 1 100.00 Using where 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 10 100.00 Using where -3 DEPENDENT SUBQUERY t2 range PRIMARY,col_date_key,ch2,id2 ch2 4 NULL 2 100.00 Using where; Using index -3 DEPENDENT SUBQUERY bt1 ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED t2 range PRIMARY,col_date_key,ch2,id2 ch2 4 NULL 2 100.00 Using where; Using index +3 MATERIALIZED bt1 ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.t3.id' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t3` where (1,<`test`.`t3`.`id`>(exists(/* select#2 */ select 1 from `test`.`t1` where <`test`.`t3`.`id`>((`test`.`t3`.`id`,(/* select#3 */ select `test`.`bt1`.`id` from `test`.`t2` join `test`.`t1` `bt1` where `test`.`bt1`.`id` = `test`.`t2`.`pk` and `test`.`t2`.`ch2` <= 'g' and (`test`.`t3`.`id`) = `test`.`bt1`.`id`))) or `test`.`t1`.`id2` = `test`.`t1`.`id` limit 1))) +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t3` where (1,<`test`.`t3`.`id`>(exists(/* select#2 */ select 1 from `test`.`t1` where <`test`.`t3`.`id`>((`test`.`t3`.`id`,`test`.`t3`.`id` in ( (/* select#3 */ select `test`.`bt1`.`id` from `test`.`t2` join `test`.`t1` `bt1` where `test`.`bt1`.`id` = `test`.`t2`.`pk` and `test`.`t2`.`ch2` <= 'g' ), (`test`.`t3`.`id` in on distinct_key where `test`.`t3`.`id` = ``.`id`)))) or `test`.`t1`.`id2` = `test`.`t1`.`id` limit 1))) SELECT 1 FROM t3 WHERE EXISTS ( SELECT 1 FROM t1 WHERE t3.id IN ( SELECT bt1.id FROM t2, t1 AS bt1 @@ -3129,11 +3115,11 @@ t1.id2 = t1.id); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 1 100.00 Using where 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 10 100.00 Using where -3 DEPENDENT SUBQUERY t2 range PRIMARY,col_date_key,ch2,id2 ch2 4 NULL 2 100.00 Using where; Using index -3 DEPENDENT SUBQUERY bt1 ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED t2 range PRIMARY,col_date_key,ch2,id2 ch2 4 NULL 2 100.00 Using where; Using index +3 MATERIALIZED bt1 ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.t3.id' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t3` where (1,<`test`.`t3`.`id`>(exists(/* select#2 */ select 1 from `test`.`t1` where <`test`.`t3`.`id`>((`test`.`t3`.`id`,(/* select#3 */ select `test`.`bt1`.`id` from `test`.`t2` join `test`.`t1` `bt1` where `test`.`bt1`.`ch` = `test`.`t2`.`ch2` and `test`.`bt1`.`id` = `test`.`t2`.`pk` and `test`.`t2`.`ch2` <= 'g' and (`test`.`t3`.`id`) = `test`.`bt1`.`id`))) or `test`.`t1`.`id2` = `test`.`t1`.`id` limit 1))) +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t3` where (1,<`test`.`t3`.`id`>(exists(/* select#2 */ select 1 from `test`.`t1` where <`test`.`t3`.`id`>((`test`.`t3`.`id`,`test`.`t3`.`id` in ( (/* select#3 */ select `test`.`bt1`.`id` from `test`.`t2` join `test`.`t1` `bt1` where `test`.`bt1`.`ch` = `test`.`t2`.`ch2` and `test`.`bt1`.`id` = `test`.`t2`.`pk` and `test`.`t2`.`ch2` <= 'g' ), (`test`.`t3`.`id` in on distinct_key where `test`.`t3`.`id` = ``.`id`)))) or `test`.`t1`.`id2` = `test`.`t1`.`id` limit 1))) SELECT 1 FROM t3 WHERE EXISTS ( SELECT 1 FROM t1 WHERE t3.id IN ( SELECT bt1.id FROM t2, t1 AS bt1 @@ -3170,7 +3156,7 @@ test.t1 analyze status OK explain extended select count(0) from t1 where id=15066 and (match s against ('+"fttest"' in boolean mode)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ref id,s id 5 const 1 100.00 Using where +1 SIMPLE t1 fulltext id,s s 0 1 1.64 Using where Warnings: Note 1003 select count(0) AS `count(0)` from `test`.`t1` where `test`.`t1`.`id` = 15066 and (match `test`.`t1`.`s` against ('+"fttest"' in boolean mode)) select count(0) from t1 @@ -3474,16 +3460,16 @@ WHERE 1 = 1 AND domain = 'www.mailhost.i-dev.fr' AND timestamp >= DATE_ADD('2017-01-30 08:24:51', INTERVAL -1 MONTH) ORDER BY timestamp DESC; id domain registrant_name registrant_organization registrant_street1 registrant_street2 registrant_street3 registrant_street4 registrant_street5 registrant_city registrant_postal_code registrant_country registrant_email registrant_telephone administrative_name administrative_organization administrative_street1 administrative_street2 administrative_street3 administrative_street4 administrative_street5 administrative_city administrative_postal_code administrative_country administrative_email administrative_telephone technical_name technical_organization technical_street1 technical_street2 technical_street3 technical_street4 technical_street5 technical_city technical_postal_code technical_country technical_email technical_telephone json timestamp -80609 www.mailhost.i-dev.fr NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2017-01-30 10:00:56 -80594 www.mailhost.i-dev.fr NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2017-01-30 10:00:56 -80579 www.mailhost.i-dev.fr NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2017-01-30 10:00:56 80551 www.mailhost.i-dev.fr NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2017-01-30 10:00:56 +80579 www.mailhost.i-dev.fr NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2017-01-30 10:00:56 +80594 www.mailhost.i-dev.fr NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2017-01-30 10:00:56 +80609 www.mailhost.i-dev.fr NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2017-01-30 10:00:56 EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1 = 1 AND domain = 'www.mailhost.i-dev.fr' AND timestamp >= DATE_ADD('2017-01-30 08:24:51', INTERVAL -1 MONTH) ORDER BY timestamp DESC; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range ixEventWhoisDomainDomain,ixEventWhoisDomainTimestamp ixEventWhoisDomainTimestamp 4 NULL 1 28.57 Using where +1 SIMPLE t1 ALL ixEventWhoisDomainDomain,ixEventWhoisDomainTimestamp NULL NULL NULL 60 22.22 Using where; Using filesort Warnings: Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`domain` AS `domain`,`test`.`t1`.`registrant_name` AS `registrant_name`,`test`.`t1`.`registrant_organization` AS `registrant_organization`,`test`.`t1`.`registrant_street1` AS `registrant_street1`,`test`.`t1`.`registrant_street2` AS `registrant_street2`,`test`.`t1`.`registrant_street3` AS `registrant_street3`,`test`.`t1`.`registrant_street4` AS `registrant_street4`,`test`.`t1`.`registrant_street5` AS `registrant_street5`,`test`.`t1`.`registrant_city` AS `registrant_city`,`test`.`t1`.`registrant_postal_code` AS `registrant_postal_code`,`test`.`t1`.`registrant_country` AS `registrant_country`,`test`.`t1`.`registrant_email` AS `registrant_email`,`test`.`t1`.`registrant_telephone` AS `registrant_telephone`,`test`.`t1`.`administrative_name` AS `administrative_name`,`test`.`t1`.`administrative_organization` AS `administrative_organization`,`test`.`t1`.`administrative_street1` AS `administrative_street1`,`test`.`t1`.`administrative_street2` AS `administrative_street2`,`test`.`t1`.`administrative_street3` AS `administrative_street3`,`test`.`t1`.`administrative_street4` AS `administrative_street4`,`test`.`t1`.`administrative_street5` AS `administrative_street5`,`test`.`t1`.`administrative_city` AS `administrative_city`,`test`.`t1`.`administrative_postal_code` AS `administrative_postal_code`,`test`.`t1`.`administrative_country` AS `administrative_country`,`test`.`t1`.`administrative_email` AS `administrative_email`,`test`.`t1`.`administrative_telephone` AS `administrative_telephone`,`test`.`t1`.`technical_name` AS `technical_name`,`test`.`t1`.`technical_organization` AS `technical_organization`,`test`.`t1`.`technical_street1` AS `technical_street1`,`test`.`t1`.`technical_street2` AS `technical_street2`,`test`.`t1`.`technical_street3` AS `technical_street3`,`test`.`t1`.`technical_street4` AS `technical_street4`,`test`.`t1`.`technical_street5` AS `technical_street5`,`test`.`t1`.`technical_city` AS `technical_city`,`test`.`t1`.`technical_postal_code` AS `technical_postal_code`,`test`.`t1`.`technical_country` AS `technical_country`,`test`.`t1`.`technical_email` AS `technical_email`,`test`.`t1`.`technical_telephone` AS `technical_telephone`,`test`.`t1`.`json` AS `json`,`test`.`t1`.`timestamp` AS `timestamp` from `test`.`t1` where `test`.`t1`.`domain` = 'www.mailhost.i-dev.fr' and `test`.`t1`.`timestamp` >= ('2017-01-30 08:24:51' + interval -1 month) order by `test`.`t1`.`timestamp` desc SET optimizer_switch=@save_optimizer_switch; @@ -3675,7 +3661,7 @@ fi.fh in (6311439873746261694,-397087483897438286, id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index 1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where -1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 1 26.09 Using where +1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 24 14.46 Using where Warnings: Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) set statement optimizer_switch='rowid_filter=off' for select t.id, fi.* @@ -3732,7 +3718,7 @@ fi.fh in (6311439873746261694,-397087483897438286, id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index 1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where -1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 1 26.09 Using where +1 SIMPLE fi ref|filter filt_aceid,filt_fh filt_aceid|filt_fh 8|8 test.a.id 24 (14%) 14.46 Using where; Using rowid filter Warnings: Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) set statement optimizer_switch='rowid_filter=on' for select t.id, fi.* @@ -3791,7 +3777,7 @@ fi.fh in (6311439873746261694,-397087483897438286, id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index 1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where; Using join buffer (flat, BKA join); Rowid-ordered scan -1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 1 26.09 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan +1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 24 14.46 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan Warnings: Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) set statement optimizer_switch='rowid_filter=off' for select t.id, fi.* @@ -3848,7 +3834,7 @@ fi.fh in (6311439873746261694,-397087483897438286, id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index 1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where; Using join buffer (flat, BKA join); Rowid-ordered scan -1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 1 26.09 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan +1 SIMPLE fi ref|filter filt_aceid,filt_fh filt_aceid|filt_fh 8|8 test.a.id 24 (14%) 14.46 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan; Using rowid filter Warnings: Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) set statement optimizer_switch='rowid_filter=on' for select t.id, fi.* @@ -4000,7 +3986,7 @@ ANALYZE "r_rows": 32, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 26.08628654, + "filtered": 14.46428585, "r_filtered": 100 }, "buffer_type": "incremental", @@ -4008,7 +3994,7 @@ ANALYZE "join_type": "BKA", "mrr_type": "Rowid-ordered scan", "attached_condition": "fi.fh in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)", - "r_filtered": 40, + "r_filtered": 100, "r_unpack_time_ms": "REPLACED" } } @@ -4048,6 +4034,16 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK test.t2 analyze status Engine-independent statistics collected test.t2 analyze status OK +EXPLAIN EXTENDED SELECT * FROM t1 +WHERE t1.c1 NOT IN (SELECT t2.c1 FROM t2, t1 AS a1 +WHERE t2.i1 = t1.pk AND t2.i1 BETWEEN 3 AND 5); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 60 100.00 Using where +2 DEPENDENT SUBQUERY t2 ref|filter c1,i1 c1|i1 3|5 func 38 (25%) 25.00 Using where; Full scan on NULL key; Using rowid filter +2 DEPENDENT SUBQUERY a1 ALL NULL NULL NULL NULL 60 100.00 Using join buffer (flat, BNL join) +Warnings: +Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where !<`test`.`t1`.`c1`,`test`.`t1`.`pk`>((`test`.`t1`.`c1`,(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t1` `a1` where `test`.`t2`.`i1` = `test`.`t1`.`pk` and `test`.`t2`.`i1` between 3 and 5 and trigcond((`test`.`t1`.`c1`) = `test`.`t2`.`c1`)))) SELECT * FROM t1 WHERE t1.c1 NOT IN (SELECT t2.c1 FROM t2, t1 AS a1 WHERE t2.i1 = t1.pk AND t2.i1 BETWEEN 3 AND 5); @@ -4112,16 +4108,6 @@ pk c1 128 y 129 NULL 133 NULL -EXPLAIN EXTENDED SELECT * FROM t1 -WHERE t1.c1 NOT IN (SELECT t2.c1 FROM t2, t1 AS a1 -WHERE t2.i1 = t1.pk AND t2.i1 BETWEEN 3 AND 5); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 15 100.00 Using where -2 DEPENDENT SUBQUERY t2 ref|filter c1,i1 c1|i1 3|5 func 6 (33%) 11.11 Using where; Full scan on NULL key; Using rowid filter -2 DEPENDENT SUBQUERY a1 ALL NULL NULL NULL NULL 15 100.00 Using join buffer (flat, BNL join) -Warnings: -Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where !<`test`.`t1`.`c1`,`test`.`t1`.`pk`>((`test`.`t1`.`c1`,(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t1` `a1` where `test`.`t2`.`i1` = `test`.`t1`.`pk` and `test`.`t2`.`i1` between 3 and 5 and trigcond((`test`.`t1`.`c1`) = `test`.`t2`.`c1`)))) DROP TABLE t1,t2; set global innodb_stats_persistent= @stats.save; # End of 10.4 tests diff --git a/mysql-test/main/rowid_filter_innodb.test b/mysql-test/main/rowid_filter_innodb.test index 339d4e37f67..604f32cd56e 100644 --- a/mysql-test/main/rowid_filter_innodb.test +++ b/mysql-test/main/rowid_filter_innodb.test @@ -70,7 +70,7 @@ let $q= select * from t1 join t2 on t1.id = t2.x where t2.y = 2 and t1.id = 1; eval $q; ---replace_column 10 # +--replace_column 9 # 10 # eval explain extended $q; drop table t1, t2; @@ -133,9 +133,9 @@ INSERT INTO t1 VALUES ANALYZE TABLE t1; EXPLAIN EXTENDED -SELECT a FROM t1 WHERE c < 'k' AND b > 't' ORDER BY a; +SELECT a FROM t1 WHERE c < 'e' AND b > 't' ORDER BY a; -SELECT a FROM t1 WHERE c < 'k' AND b > 't' ORDER BY a; +SELECT a FROM t1 WHERE c < 'e' AND b > 't' ORDER BY a; DROP TABLE t1; SET GLOBAL innodb_stats_persistent= @stats.save; @@ -644,8 +644,8 @@ SELECT * FROM t1 WHERE t1.c1 NOT IN (SELECT t2.c1 FROM t2, t1 AS a1 WHERE t2.i1 = t1.pk AND t2.i1 BETWEEN 3 AND 5); -eval $q; eval EXPLAIN EXTENDED $q; +eval $q; DROP TABLE t1,t2; diff --git a/mysql-test/main/rowid_filter_innodb_debug.result b/mysql-test/main/rowid_filter_innodb_debug.result index f82b29aa1e6..af800346f75 100644 --- a/mysql-test/main/rowid_filter_innodb_debug.result +++ b/mysql-test/main/rowid_filter_innodb_debug.result @@ -2,8 +2,10 @@ set default_storage_engine=innodb; # # MDEV-22761 KILL QUERY during rowid_filter, crashes # +create table t1(a int); +insert into t1 select seq from seq_1_to_1000; create table t2(a int); -insert into t2 select * from seq_0_to_99; +insert into t2 select seq from seq_1_to_100; CREATE TABLE t3 ( key1 int , key2 int, @@ -11,16 +13,11 @@ filler varchar(255), KEY (key1), KEY (key2) ); +insert into t3 select seq,seq, 'filler-data-filler-data' from seq_1_to_2000; select engine from information_schema.tables where table_schema=database() and table_name='t3'; engine InnoDB -insert into t3 -select -A.seq, -B.seq, -'filler-data-filler-data' -from seq_0_to_99 A, seq_0_to_99 B; analyze table t2,t3; Table Op Msg_type Msg_text test.t2 analyze status Engine-independent statistics collected @@ -30,14 +27,14 @@ test.t3 analyze status OK explain select * from t2, t3 where -t3.key1=t2.a and t3.key2 in (2,3); +t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 100 Using where -1 SIMPLE t3 ref|filter key1,key2 key1|key2 5|5 test.t2.a 100 (2%) Using where; Using rowid filter +1 SIMPLE t3 ref|filter key1,key2 key1|key2 5|5 test.t2.a 1 (0%) Using where; Using rowid filter set debug_sync='handler_rowid_filter_check SIGNAL at_rowid_filter_check WAIT_FOR go'; select * from t2, t3 where -t3.key1=t2.a and t3.key2 in (2,3); +t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); connect con1, localhost, root,,; set debug_sync='now WAIT_FOR at_rowid_filter_check'; kill query $target_id; @@ -46,5 +43,5 @@ connection default; disconnect con1; ERROR 70100: Query execution was interrupted set debug_sync='RESET'; -drop table t2,t3; +drop table t1,t2,t3; set default_storage_engine=default; diff --git a/mysql-test/main/rowid_filter_myisam_debug.result b/mysql-test/main/rowid_filter_myisam_debug.result index 75a8fad6947..d68714cc303 100644 --- a/mysql-test/main/rowid_filter_myisam_debug.result +++ b/mysql-test/main/rowid_filter_myisam_debug.result @@ -1,8 +1,10 @@ # # MDEV-22761 KILL QUERY during rowid_filter, crashes # +create table t1(a int); +insert into t1 select seq from seq_1_to_1000; create table t2(a int); -insert into t2 select * from seq_0_to_99; +insert into t2 select seq from seq_1_to_100; CREATE TABLE t3 ( key1 int , key2 int, @@ -10,16 +12,11 @@ filler varchar(255), KEY (key1), KEY (key2) ); +insert into t3 select seq,seq, 'filler-data-filler-data' from seq_1_to_2000; select engine from information_schema.tables where table_schema=database() and table_name='t3'; engine MyISAM -insert into t3 -select -A.seq, -B.seq, -'filler-data-filler-data' -from seq_0_to_99 A, seq_0_to_99 B; analyze table t2,t3; Table Op Msg_type Msg_text test.t2 analyze status Engine-independent statistics collected @@ -29,14 +26,14 @@ test.t3 analyze status Table is already up to date explain select * from t2, t3 where -t3.key1=t2.a and t3.key2 in (2,3); +t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 100 Using where -1 SIMPLE t3 ref|filter key1,key2 key1|key2 5|5 test.t2.a 100 (2%) Using where; Using rowid filter +1 SIMPLE t3 ref|filter key1,key2 key1|key2 5|5 test.t2.a 1 (0%) Using where; Using rowid filter set debug_sync='handler_rowid_filter_check SIGNAL at_rowid_filter_check WAIT_FOR go'; select * from t2, t3 where -t3.key1=t2.a and t3.key2 in (2,3); +t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); connect con1, localhost, root,,; set debug_sync='now WAIT_FOR at_rowid_filter_check'; kill query $target_id; @@ -45,4 +42,4 @@ connection default; disconnect con1; ERROR 70100: Query execution was interrupted set debug_sync='RESET'; -drop table t2,t3; +drop table t1,t2,t3; diff --git a/mysql-test/main/select.result b/mysql-test/main/select.result index 675601df08c..af65ca169d6 100644 --- a/mysql-test/main/select.result +++ b/mysql-test/main/select.result @@ -603,6 +603,31 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index +# +# Some test with ORDER BY and limit +# +explain select count(*) from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index period period 4 NULL 41810 Using index +1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using index +explain select sum(t1.price+t3.price) from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL period NULL NULL NULL 41810 +1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using where; Using join buffer (flat, BNL join) +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort +1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using where; Using join buffer (flat, BNL join) +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using temporary; Using filesort +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using where; Using join buffer (flat, BNL join) +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort +1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using where; Using join buffer (flat, BNL join) +set @save_join_cache_level=@@join_cache_level; +set @@join_cache_level=0; explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort @@ -615,6 +640,10 @@ explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period l id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 +set @@join_cache_level=@save_join_cache_level; +# +# Search with a constant table. +# select period from t1; period 9410 @@ -1378,18 +1407,28 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE delete from t2 where fld1=999999; +# +# Test left join optimization +# +set @save_join_cache_level=@@join_cache_level; +set @@join_cache_level=0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +set @@join_cache_level=@save_join_cache_level; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join) explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where @@ -1426,6 +1465,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +# +# Joins with forms. +# select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 @@ -2364,16 +2406,16 @@ insert into t1 values (1,2), (2,2), (3,2), (4,2); insert into t2 values (1,3), (2,3), (3,4), (4,4); explain select * from t1 left join t2 on a=c where d in (4); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c,d d 5 const 2 -1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c,d d 5 const 2 Using where +1 SIMPLE t1 ref a a 5 test.t2.c 2 select * from t1 left join t2 on a=c where d in (4); a b c d 3 2 3 4 4 2 4 4 explain select * from t1 left join t2 on a=c where d = 4; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c,d d 5 const 2 -1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c,d d 5 const 2 Using where +1 SIMPLE t1 ref a a 5 test.t2.c 2 select * from t1 left join t2 on a=c where d = 4; a b c d 3 2 3 4 @@ -3479,7 +3521,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using index condition; Using where +1 SIMPLE t1 range|filter PRIMARY,b b|PRIMARY 5|4 NULL 3 (90%) Using index condition; Using where; Using rowid filter 1 SIMPLE t2 ref c c 5 test.t1.a 2 DROP TABLE t1, t2; create table t1 ( @@ -3540,7 +3582,7 @@ WHERE t1.id=2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 const idx1 NULL NULL NULL 1 -1 SIMPLE t3 ALL idx1 NULL NULL NULL 9 Using where +1 SIMPLE t3 ref idx1 idx1 5 const 4 SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id WHERE t1.id=2; id a b c d e @@ -3640,7 +3682,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3648,7 +3690,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter DROP TABLE t1,t2,t3; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); @@ -3725,11 +3767,11 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|5 const 2 (27%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; id select_type table type possible_keys key key_len ref rows Extra @@ -3739,7 +3781,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -3773,7 +3815,7 @@ AND t1.ts BETWEEN t2.dt1 AND t2.dt2 AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 -1 SIMPLE t1 ALL ts NULL NULL NULL 2 Using where +1 SIMPLE t1 range ts ts 4 NULL 2 Using index condition; Using where SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 AND t1.ts BETWEEN t2.dt1 AND t2.dt2 AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; @@ -4039,7 +4081,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 ON ( f1.b=f2.b AND f1.a 0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +set @@join_cache_level=@save_join_cache_level; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; @@ -1582,9 +1596,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; -# -# Joins with forms. -# +--echo # +--echo # Joins with forms. +--echo # select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; diff --git a/mysql-test/main/select_jcl6.result b/mysql-test/main/select_jcl6.result index 19970c90c7f..74a0dbd8855 100644 --- a/mysql-test/main/select_jcl6.result +++ b/mysql-test/main/select_jcl6.result @@ -614,18 +614,47 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index +# +# Some test with ORDER BY and limit +# +explain select count(*) from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index period period 4 NULL 41810 Using index +1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using index +explain select sum(t1.price+t3.price) from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL period NULL NULL NULL 41810 +1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using where; Using join buffer (flat, BNL join) explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort -1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using where; Using join buffer (flat, BNL join) explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using temporary; Using filesort -1 SIMPLE t1 ref period period 4 test.t3.period 4181 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using where; Using join buffer (flat, BNL join) explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort -1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using where; Using join buffer (flat, BNL join) +set @save_join_cache_level=@@join_cache_level; +set @@join_cache_level=0; +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t3 ref period period 4 test.t1.period 4181 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index period period 4 NULL 1 +1 SIMPLE t1 ref period period 4 test.t3.period 4181 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index period period 4 NULL 1 +1 SIMPLE t3 ref period period 4 test.t1.period 4181 +set @@join_cache_level=@save_join_cache_level; +# +# Search with a constant table. +# select period from t1; period 9410 @@ -1389,17 +1418,27 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE delete from t2 where fld1=999999; +# +# Test left join optimization +# +set @save_join_cache_level=@@join_cache_level; +set @@join_cache_level=0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where -1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where -1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +set @@join_cache_level=@save_join_cache_level; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join) explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; id select_type table type possible_keys key key_len ref rows Extra @@ -1437,6 +1476,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join) +# +# Joins with forms. +# select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 @@ -2375,16 +2417,16 @@ insert into t1 values (1,2), (2,2), (3,2), (4,2); insert into t2 values (1,3), (2,3), (3,4), (4,4); explain select * from t1 left join t2 on a=c where d in (4); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c,d d 5 const 2 -1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c,d d 5 const 2 Using where +1 SIMPLE t1 ref a a 5 test.t2.c 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan select * from t1 left join t2 on a=c where d in (4); a b c d 3 2 3 4 4 2 4 4 explain select * from t1 left join t2 on a=c where d = 4; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c,d d 5 const 2 -1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c,d d 5 const 2 Using where +1 SIMPLE t1 ref a a 5 test.t2.c 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan select * from t1 left join t2 on a=c where d = 4; a b c d 3 2 3 4 @@ -3490,7 +3532,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using index condition; Using where; Rowid-ordered scan +1 SIMPLE t1 range|filter PRIMARY,b b|PRIMARY 5|4 NULL 3 (90%) Using index condition; Using where; Rowid-ordered scan; Using rowid filter 1 SIMPLE t2 ref c c 5 test.t1.a 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan DROP TABLE t1, t2; create table t1 ( @@ -3551,7 +3593,7 @@ WHERE t1.id=2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 const idx1 NULL NULL NULL 1 -1 SIMPLE t3 ALL idx1 NULL NULL NULL 9 Using where +1 SIMPLE t3 ref idx1 idx1 5 const 4 SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id WHERE t1.id=2; id a b c d e @@ -3651,7 +3693,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where; Rowid-ordered scan -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3659,7 +3701,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where; Rowid-ordered scan -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter DROP TABLE t1,t2,t3; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); @@ -3736,11 +3778,11 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|5 const 2 (27%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; id select_type table type possible_keys key key_len ref rows Extra @@ -3750,7 +3792,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -3784,7 +3826,7 @@ AND t1.ts BETWEEN t2.dt1 AND t2.dt2 AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 -1 SIMPLE t1 ALL ts NULL NULL NULL 2 Using where +1 SIMPLE t1 range ts ts 4 NULL 2 Using index condition; Using where; Rowid-ordered scan SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 AND t1.ts BETWEEN t2.dt1 AND t2.dt2 AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; @@ -4050,7 +4092,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 ON ( f1.b=f2.b AND f1.a 0; id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +set @@join_cache_level=@save_join_cache_level; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join) explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where @@ -1426,6 +1465,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +# +# Joins with forms. +# select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 @@ -2364,16 +2406,16 @@ insert into t1 values (1,2), (2,2), (3,2), (4,2); insert into t2 values (1,3), (2,3), (3,4), (4,4); explain select * from t1 left join t2 on a=c where d in (4); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c,d d 5 const 2 -1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c,d d 5 const 2 Using where +1 SIMPLE t1 ref a a 5 test.t2.c 2 select * from t1 left join t2 on a=c where d in (4); a b c d 3 2 3 4 4 2 4 4 explain select * from t1 left join t2 on a=c where d = 4; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c,d d 5 const 2 -1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref c,d d 5 const 2 Using where +1 SIMPLE t1 ref a a 5 test.t2.c 2 select * from t1 left join t2 on a=c where d = 4; a b c d 3 2 3 4 @@ -3479,7 +3521,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using index condition; Using where +1 SIMPLE t1 range|filter PRIMARY,b b|PRIMARY 5|4 NULL 3 (90%) Using index condition; Using where; Using rowid filter 1 SIMPLE t2 ref c c 5 test.t1.a 2 DROP TABLE t1, t2; create table t1 ( @@ -3540,7 +3582,7 @@ WHERE t1.id=2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 const idx1 NULL NULL NULL 1 -1 SIMPLE t3 ALL idx1 NULL NULL NULL 9 Using where +1 SIMPLE t3 ref idx1 idx1 5 const 4 SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id WHERE t1.id=2; id a b c d e @@ -3640,7 +3682,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3648,7 +3690,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where +1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter DROP TABLE t1,t2,t3; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); @@ -3725,11 +3767,11 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|5 const 2 (27%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; id select_type table type possible_keys key key_len ref rows Extra @@ -3739,7 +3781,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra @@ -3773,7 +3815,7 @@ AND t1.ts BETWEEN t2.dt1 AND t2.dt2 AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 -1 SIMPLE t1 ALL ts NULL NULL NULL 2 Using where +1 SIMPLE t1 range ts ts 4 NULL 2 Using index condition; Using where SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 AND t1.ts BETWEEN t2.dt1 AND t2.dt2 AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; @@ -4039,7 +4081,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 ON ( f1.b=f2.b AND f1.a<`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` +Note 1003 /* select#1 */ select `dbt3_s001`.`supplier`.`s_acctbal` AS `s_acctbal`,`dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`nation`.`n_name` AS `n_name`,`dbt3_s001`.`part`.`p_partkey` AS `p_partkey`,`dbt3_s001`.`part`.`p_mfgr` AS `p_mfgr`,`dbt3_s001`.`supplier`.`s_address` AS `s_address`,`dbt3_s001`.`supplier`.`s_phone` AS `s_phone`,`dbt3_s001`.`supplier`.`s_comment` AS `s_comment` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and (`dbt3_s001`.`part`.`p_size` = 9 or `dbt3_s001`.`part`.`p_size` = 19999) and `dbt3_s001`.`part`.`p_type` like '%TIN' and `dbt3_s001`.`partsupp`.`ps_supplycost` = <`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`region`.`r_regionkey` = `dbt3_s001`.`nation`.`n_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` set optimizer_use_condition_selectivity=4; explain extended select @@ -118,13 +118,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 2.08 Using where; Using join buffer (flat, BNL join) 1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 100.00 Using where -2 DEPENDENT SUBQUERY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where -2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 +2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 2 DEPENDENT SUBQUERY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where 2 DEPENDENT SUBQUERY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where +2 DEPENDENT SUBQUERY region eq_ref PRIMARY PRIMARY 4 dbt3_s001.nation.n_regionkey 1 20.00 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.part.p_partkey' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `dbt3_s001`.`supplier`.`s_acctbal` AS `s_acctbal`,`dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`nation`.`n_name` AS `n_name`,`dbt3_s001`.`part`.`p_partkey` AS `p_partkey`,`dbt3_s001`.`part`.`p_mfgr` AS `p_mfgr`,`dbt3_s001`.`supplier`.`s_address` AS `s_address`,`dbt3_s001`.`supplier`.`s_phone` AS `s_phone`,`dbt3_s001`.`supplier`.`s_comment` AS `s_comment` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`part`.`p_size` = 9 and `dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_type` like '%TIN' and `dbt3_s001`.`partsupp`.`ps_supplycost` = <`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` +Note 1003 /* select#1 */ select `dbt3_s001`.`supplier`.`s_acctbal` AS `s_acctbal`,`dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`nation`.`n_name` AS `n_name`,`dbt3_s001`.`part`.`p_partkey` AS `p_partkey`,`dbt3_s001`.`part`.`p_mfgr` AS `p_mfgr`,`dbt3_s001`.`supplier`.`s_address` AS `s_address`,`dbt3_s001`.`supplier`.`s_phone` AS `s_phone`,`dbt3_s001`.`supplier`.`s_comment` AS `s_comment` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`part`.`p_size` = 9 and `dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey` and `dbt3_s001`.`nation`.`n_regionkey` = `dbt3_s001`.`region`.`r_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_type` like '%TIN' and `dbt3_s001`.`partsupp`.`ps_supplycost` = <`dbt3_s001`.`part`.`p_partkey`>((/* select#2 */ select min(`dbt3_s001`.`partsupp`.`ps_supplycost`) from `dbt3_s001`.`partsupp` join `dbt3_s001`.`supplier` join `dbt3_s001`.`nation` join `dbt3_s001`.`region` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`region`.`r_regionkey` = `dbt3_s001`.`nation`.`n_regionkey` and `dbt3_s001`.`region`.`r_name` = 'ASIA' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`)) order by `dbt3_s001`.`supplier`.`s_acctbal` desc,`dbt3_s001`.`nation`.`n_name`,`dbt3_s001`.`supplier`.`s_name`,`dbt3_s001`.`part`.`p_partkey` === Q15 === create view revenue0 (supplier_no, total_revenue) as select l_suppkey, sum(l_extendedprice * (1 - l_discount)) @@ -490,7 +490,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 100.00 Using where 2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 Using where -4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where +4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 15.14 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 @@ -542,7 +542,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort 1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 4.17 Using where -1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 100.00 Using where; FirstMatch(supplier) +1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 11.99 Using where; FirstMatch(supplier) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 15.14 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 @@ -597,7 +597,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort 1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 7.03 Using where -1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 100.00 Using where; FirstMatch(supplier) +1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 7.11 Using where; FirstMatch(supplier) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 15.14 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 @@ -652,7 +652,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort 1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 7.81 Using where -1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 100.00 Using where; FirstMatch(supplier) +1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 6.40 Using where; FirstMatch(supplier) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 15.14 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 @@ -707,7 +707,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort 1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 7.81 Using where -1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 100.00 Using where; FirstMatch(supplier) +1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 6.40 Using where; FirstMatch(supplier) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 15.14 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 @@ -1641,27 +1641,51 @@ drop function f1; # create table t1 (a int, b int, key (b), key (a)); insert into t1 -select (rand(1)*1000)/10, (rand(1001)*1000)/20 from seq_1_to_1000; -analyze table t1 persistent for all; +select (rand(1)*1000)/30, (rand(1001)*1000)/40 from seq_1_to_1000; +analyze table t1 ; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status Table is already up to date +select count(*) from t1 where b=2; +count(*) +42 +select count(*) from t1 where a in (17,51,5); +count(*) +62 # Check what info the optimizer has about selectivities explain extended select * from t1 use index () where a in (17,51,5); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.90 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 6.20 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5) explain extended select * from t1 use index () where b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.40 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 4.20 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2 # Now, the equality is used for ref access, while the range condition # gives selectivity data explain extended select * from t1 where a in (17,51,5) and b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ref|filter b,a b|a 5|5 const 24 (3%) 2.90 Using where; Using rowid filter +1 SIMPLE t1 ref|filter b,a b|a 5|5 const 42 (6%) 6.30 Using where; Using rowid filter +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5) +truncate table t1; +insert into t1 +select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000; +analyze table t1 ; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +select count(*) from t1 where b=2; +count(*) +59 +select count(*) from t1 where a in (17,51,5); +count(*) +29 +explain extended select * from t1 where a in (17,51,5) and b=2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range|filter b,a a|b 5|5 NULL 29 (6%) 5.80 Using index condition; Using where; Using rowid filter Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5) drop table t1; @@ -1868,7 +1892,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 -2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where +2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (10%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 @@ -1880,7 +1904,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 -2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where +2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (10%) Using where; Using rowid filter set optimizer_switch= @save_optimizer_switch; set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; drop table t1,t2; diff --git a/mysql-test/main/selectivity.test b/mysql-test/main/selectivity.test index f2992ac1073..a4fa09f0116 100644 --- a/mysql-test/main/selectivity.test +++ b/mysql-test/main/selectivity.test @@ -1113,8 +1113,10 @@ drop function f1; --echo # create table t1 (a int, b int, key (b), key (a)); insert into t1 -select (rand(1)*1000)/10, (rand(1001)*1000)/20 from seq_1_to_1000; -analyze table t1 persistent for all; +select (rand(1)*1000)/30, (rand(1001)*1000)/40 from seq_1_to_1000; +analyze table t1 ; +select count(*) from t1 where b=2; +select count(*) from t1 where a in (17,51,5); --echo # Check what info the optimizer has about selectivities explain extended select * from t1 use index () where a in (17,51,5); @@ -1123,6 +1125,13 @@ explain extended select * from t1 use index () where b=2; --echo # Now, the equality is used for ref access, while the range condition --echo # gives selectivity data explain extended select * from t1 where a in (17,51,5) and b=2; +truncate table t1; +insert into t1 +select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000; +analyze table t1 ; +select count(*) from t1 where b=2; +select count(*) from t1 where a in (17,51,5); +explain extended select * from t1 where a in (17,51,5) and b=2; drop table t1; set use_stat_tables= @save_use_stat_tables; @@ -1240,13 +1249,10 @@ set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; drop table t1,t2,t3; - --echo # --echo # MDEV-20519: Query plan regression with optimizer_use_condition_selectivity=4 --echo # - - create table t1 (id int, a int, PRIMARY KEY(id), key(a)); insert into t1 select seq,seq from seq_1_to_100; diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index 3797de29935..617aa350206 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -495,7 +495,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 100.00 Using where 2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where -4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where +4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.40 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 @@ -544,15 +544,15 @@ and n_name = 'UNITED STATES' order by s_name limit 10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 100.00 Using where; Using filesort -1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 4.00 Using where -1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70 100.00 Using where -1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 4.17 Using where; FirstMatch(nation) +1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort +1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 +1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 4.17 Using where +1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 11.99 Using where; FirstMatch(supplier) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.40 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 -Note 1003 /* select#1 */ select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_name` = 'UNITED STATES' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`partsupp`.`ps_availqty` > <`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((/* select#4 */ select 0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`) from `dbt3_s001`.`lineitem` where `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`lineitem`.`l_shipDATE` >= (cast('1993-01-01' as date)) and `dbt3_s001`.`lineitem`.`l_shipDATE` < (cast('1993-01-01' as date) + interval '1' year))) and `dbt3_s001`.`part`.`p_name` like 'g%' order by `dbt3_s001`.`supplier`.`s_name` limit 10 +Note 1003 /* select#1 */ select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where `dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey` and `dbt3_s001`.`nation`.`n_name` = 'UNITED STATES' and `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`partsupp`.`ps_availqty` > <`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((/* select#4 */ select 0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`) from `dbt3_s001`.`lineitem` where `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`lineitem`.`l_shipDATE` >= (cast('1993-01-01' as date)) and `dbt3_s001`.`lineitem`.`l_shipDATE` < (cast('1993-01-01' as date) + interval '1' year))) and `dbt3_s001`.`part`.`p_name` like 'g%' order by `dbt3_s001`.`supplier`.`s_name` limit 10 select sql_calc_found_rows s_name, s_address from supplier, nation @@ -602,7 +602,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 100.00 Using where; Using filesort 1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 4.00 Using where 1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70 100.00 Using where -1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 7.03 Using where; FirstMatch(nation) +1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 35.71 Using where; FirstMatch(nation) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.40 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 @@ -657,7 +657,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 100.00 Using where; Using filesort 1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 4.00 Using where 1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70 100.00 Using where -1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 7.81 Using where; FirstMatch(nation) +1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 35.71 Using where; FirstMatch(nation) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.40 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 @@ -712,7 +712,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 100.00 Using where; Using filesort 1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 4.00 Using where 1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70 100.00 Using where -1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 7.81 Using where; FirstMatch(nation) +1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 35.71 Using where; FirstMatch(nation) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.40 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 @@ -1648,27 +1648,51 @@ drop function f1; # create table t1 (a int, b int, key (b), key (a)); insert into t1 -select (rand(1)*1000)/10, (rand(1001)*1000)/20 from seq_1_to_1000; -analyze table t1 persistent for all; +select (rand(1)*1000)/30, (rand(1001)*1000)/40 from seq_1_to_1000; +analyze table t1 ; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK +select count(*) from t1 where b=2; +count(*) +42 +select count(*) from t1 where a in (17,51,5); +count(*) +62 # Check what info the optimizer has about selectivities explain extended select * from t1 use index () where a in (17,51,5); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.90 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 6.20 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5) explain extended select * from t1 use index () where b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.40 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 4.20 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2 # Now, the equality is used for ref access, while the range condition # gives selectivity data explain extended select * from t1 where a in (17,51,5) and b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ref|filter b,a b|a 5|5 const 59 (3%) 2.90 Using where; Using rowid filter +1 SIMPLE t1 ref|filter b,a b|a 5|5 const 42 (6%) 6.30 Using where; Using rowid filter +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5) +truncate table t1; +insert into t1 +select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000; +analyze table t1 ; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select count(*) from t1 where b=2; +count(*) +59 +select count(*) from t1 where a in (17,51,5); +count(*) +29 +explain extended select * from t1 where a in (17,51,5) and b=2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range|filter b,a a|b 5|5 NULL 29 (6%) 5.90 Using index condition; Using where; Using rowid filter Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5) drop table t1; @@ -1776,7 +1800,7 @@ explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 10 NULL 11 100.00 Using index condition; Using where -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00 Warnings: Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`c` and `test`.`t3`.`a` = `test`.`t1`.`d` and `test`.`t1`.`a` = 50 and `test`.`t1`.`b` <= 100 @@ -1797,8 +1821,8 @@ set optimizer_use_condition_selectivity=2; explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range a a 10 NULL 11 11.00 Using index condition; Using where -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +1 SIMPLE t1 range a a 10 NULL 11 100.00 Using index condition; Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00 Warnings: Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`c` and `test`.`t3`.`a` = `test`.`t1`.`d` and `test`.`t1`.`a` = 50 and `test`.`t1`.`b` <= 100 @@ -1815,6 +1839,18 @@ b a a b 7 7 8 8 8 8 9 9 9 9 10 10 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 10 NULL 11 100.00 Using index condition; Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00 +Warnings: +Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`c` and `test`.`t3`.`a` = `test`.`t1`.`d` and `test`.`t1`.`a` = 50 and `test`.`t1`.`b` <= 100 set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; drop table t1,t2,t3; # @@ -1863,7 +1899,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index -2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where +2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (19%) Using where; Using rowid filter EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 @@ -1875,7 +1911,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index -2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where +2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (19%) Using where; Using rowid filter set optimizer_switch= @save_optimizer_switch; set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; drop table t1,t2; diff --git a/mysql-test/main/selectivity_no_engine.result b/mysql-test/main/selectivity_no_engine.result index 552a16d8334..3811b12a1be 100644 --- a/mysql-test/main/selectivity_no_engine.result +++ b/mysql-test/main/selectivity_no_engine.result @@ -236,8 +236,8 @@ set optimizer_use_condition_selectivity=2; explain select * from t1,t2 where t1.id = t2.t1_id and t2.f2='qux' and t2.f1='baz'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL f1 NULL NULL NULL 4 Using where -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref f1 f1 325 const,const 2 Using index condition; Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 122 test.t2.t1_id 1 select * from t1,t2 where t1.id = t2.t1_id and t2.f2='qux' and t2.f1='baz'; id dt t1_id f1 f2 foo 2011-04-12 05:18:08 foo baz qux diff --git a/mysql-test/main/show_explain.result b/mysql-test/main/show_explain.result index aa3be6f1f58..1888052647b 100644 --- a/mysql-test/main/show_explain.result +++ b/mysql-test/main/show_explain.result @@ -40,7 +40,7 @@ select count(*) from t1 where a < 100000; connection default; show explain for $thr2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index a a 5 NULL 1000 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 999 Using where; Using index Warnings: Note 1003 select count(*) from t1 where a < 100000 connection con1; diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 04f6a071112..37c22e45b45 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -2173,8 +2173,8 @@ create procedure bug3734 (param1 varchar(100)) select * from t3 where match (title,body) against (param1)| call bug3734('database')| id title body -1 MySQL Tutorial DBMS stands for DataBase ... 5 MySQL vs. YourSQL In the following database comparison ... +1 MySQL Tutorial DBMS stands for DataBase ... call bug3734('Security')| id title body 6 MySQL Security When configured properly, MySQL ... diff --git a/mysql-test/main/ssl.result b/mysql-test/main/ssl.result index 794830e5529..2694d177056 100644 --- a/mysql-test/main/ssl.result +++ b/mysql-test/main/ssl.result @@ -9,6 +9,7 @@ SHOW STATUS LIKE 'Ssl_server_not_after'; Variable_name Value Ssl_server_not_after Feb 27 03:03:03 2040 GMT drop table if exists t1,t2,t3,t4; +set @@default_storage_engine="aria"; CREATE TABLE t1 ( Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL @@ -609,6 +610,9 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index +# +# Some test with ORDER BY and limit +# explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort @@ -1298,7 +1302,7 @@ companynr tinyint(2) unsigned zerofill NOT NULL default '00', companyname char(30) NOT NULL default '', PRIMARY KEY (companynr), UNIQUE KEY companyname(companyname) -) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; companynr companyname 00 Unknown @@ -1388,6 +1392,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE delete from t2 where fld1=999999; +# +# Test left join optimization +# explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where @@ -1402,15 +1409,15 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; id select_type table type possible_keys key key_len ref rows Extra @@ -1426,11 +1433,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/ssl_compress.result b/mysql-test/main/ssl_compress.result index 69de425cdc1..beb21ce8b16 100644 --- a/mysql-test/main/ssl_compress.result +++ b/mysql-test/main/ssl_compress.result @@ -6,6 +6,7 @@ SHOW STATUS LIKE 'Compression'; Variable_name Value Compression ON drop table if exists t1,t2,t3,t4; +set @@default_storage_engine="aria"; CREATE TABLE t1 ( Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL @@ -606,6 +607,9 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index +# +# Some test with ORDER BY and limit +# explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort @@ -1295,7 +1299,7 @@ companynr tinyint(2) unsigned zerofill NOT NULL default '00', companyname char(30) NOT NULL default '', PRIMARY KEY (companynr), UNIQUE KEY companyname(companyname) -) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; companynr companyname 00 Unknown @@ -1385,6 +1389,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE delete from t2 where fld1=999999; +# +# Test left join optimization +# explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where @@ -1399,15 +1406,15 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; id select_type table type possible_keys key key_len ref rows Extra @@ -1423,11 +1430,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result index 35659bc0076..d9ee8cf14c4 100644 --- a/mysql-test/main/stat_tables.result +++ b/mysql-test/main/stat_tables.result @@ -214,10 +214,10 @@ order by o_year; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort 1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join) -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_partkey 5 dbt3_s001.part.p_partkey 30 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 5 dbt3_s001.part.p_partkey 30 Using index condition 1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where 1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 -1 SIMPLE orders eq_ref PRIMARY,i_o_orderdate,i_o_custkey PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_orderdate,i_o_custkey PRIMARY|i_o_orderdate 4|4 dbt3_s001.lineitem.l_orderkey 1 (27%) Using where; Using rowid filter 1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where 1 SIMPLE n1 eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1 Using where select o_year, @@ -251,12 +251,32 @@ and p_name like '%green%') as profit group by nation, o_year order by nation, o_year desc; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 Using where; Using temporary; Using filesort +1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 Using where; Using temporary; Using filesort +1 SIMPLE partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 +1 SIMPLE supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) 1 SIMPLE nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 -1 SIMPLE partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70 -1 SIMPLE part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 Using where -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.supplier.s_suppkey 8 +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 10 dbt3_s001.part.p_partkey,dbt3_s001.partsupp.ps_suppkey 8 1 SIMPLE orders eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 +EXPLAIN EXTENDED select nation, o_year, sum(amount) as sum_profit +from (select n_name as nation, +extract(year from o_orderdate) as o_year, +l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount +from part, supplier, lineitem, partsupp, orders, nation +where s_suppkey = l_suppkey and ps_suppkey = l_suppkey +and ps_partkey = l_partkey and p_partkey = l_partkey +and o_orderkey = l_orderkey and s_nationkey = n_nationkey +and p_name like '%green%') as profit +group by nation, o_year +order by nation, o_year desc; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 100.00 Using where; Using temporary; Using filesort +1 SIMPLE partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 +1 SIMPLE supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 10.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 10 dbt3_s001.part.p_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 +1 SIMPLE orders eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 100.00 +Warnings: +Note 1003 select `dbt3_s001`.`nation`.`n_name` AS `nation`,extract(year from `dbt3_s001`.`orders`.`o_orderDATE`) AS `o_year`,sum(`dbt3_s001`.`lineitem`.`l_extendedprice` * (1 - `dbt3_s001`.`lineitem`.`l_discount`) - `dbt3_s001`.`partsupp`.`ps_supplycost` * `dbt3_s001`.`lineitem`.`l_quantity`) AS `sum_profit` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`lineitem` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`orders` join `dbt3_s001`.`nation` where `dbt3_s001`.`supplier`.`s_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`orders`.`o_orderkey` = `dbt3_s001`.`lineitem`.`l_orderkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`part`.`p_name` like '%green%' group by `dbt3_s001`.`nation`.`n_name`,extract(year from `dbt3_s001`.`orders`.`o_orderDATE`) desc order by `dbt3_s001`.`nation`.`n_name`,extract(year from `dbt3_s001`.`orders`.`o_orderDATE`) desc select nation, o_year, sum(amount) as sum_profit from (select n_name as nation, extract(year from o_orderdate) as o_year, @@ -337,7 +357,7 @@ and o_orderkey=l_orderkey and p_partkey=l_partkey; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE part range PRIMARY,i_p_retailprice i_p_retailprice 9 NULL 1 Using index condition 1 SIMPLE orders ref PRIMARY,i_o_orderdate i_o_orderdate 4 const 1 -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where select o_orderkey, p_partkey from part, lineitem, orders where p_retailprice > 1100 and o_orderdate='1997-01-01' @@ -591,8 +611,8 @@ set @@use_stat_tables= PREFERABLY; explain SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL -1 SIMPLE global_priv ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) +1 SIMPLE global_priv ALL NULL NULL NULL NULL 5 +1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL Using join buffer (flat, BNL join) set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set use_stat_tables=@save_use_stat_tables; # @@ -852,7 +872,6 @@ set histogram_size=0; # create table t1 (a int, b int); insert into t1(a,b) values (1,2),(1,3),(1,4),(1,5),(2,6),(2,7),(3,8),(3,9),(3,9),(4,10); -insert into t1 select seq,seq from seq_10_to_100; set use_stat_tables= preferably_for_queries; # # with use_stat_tables= PREFERABLY_FOR_QUERIES @@ -866,7 +885,7 @@ db_name table_name column_name min_value max_value nulls_ratio avg_length avg_fr analyze select * from t1 where a = 1 and b=3; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 101 101.00 100.00 0.99 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 10.00 Using where # # with use_stat_tables= PREFERABLY_FOR_QUERIES # analyze table t1 will collect statistics if we use PERSISTENT @@ -878,12 +897,12 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status Table is already up to date 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 -test t1 a 1 100 0.0000 4.0000 1.0632 0 NULL NULL +test t1 a 1 4 0.0000 4.0000 2.5000 0 NULL NULL # filtered shows that we used the data from stat tables analyze select * from t1 where a = 1 and b=3; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 101 101.00 1.05 0.99 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 25.00 10.00 Using where # # with use_stat_tables= PREFERABLY # analyze table t1 will collect statistics @@ -895,13 +914,13 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status Table is already up to date 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 -test t1 a 1 100 0.0000 4.0000 1.0632 0 NULL NULL -test t1 b 2 100 0.0000 4.0000 1.0202 0 NULL NULL +test t1 a 1 4 0.0000 4.0000 2.5000 0 NULL NULL +test t1 b 2 10 0.0000 4.0000 1.1111 0 NULL NULL # filtered shows that we used the data from stat tables analyze select * from t1 where a=1 and b=3; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 101 101.00 0.99 0.99 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where drop table t1; set @@global.histogram_size=@save_histogram_size; # End of 10.4 tests diff --git a/mysql-test/main/stat_tables.test b/mysql-test/main/stat_tables.test index fccae8d88c4..8b9f8361d55 100644 --- a/mysql-test/main/stat_tables.test +++ b/mysql-test/main/stat_tables.test @@ -141,6 +141,7 @@ group by nation, o_year order by nation, o_year desc; eval EXPLAIN $Q9; +eval EXPLAIN EXTENDED $Q9; eval $Q9; @@ -603,7 +604,6 @@ set histogram_size=0; create table t1 (a int, b int); insert into t1(a,b) values (1,2),(1,3),(1,4),(1,5),(2,6),(2,7),(3,8),(3,9),(3,9),(4,10); -insert into t1 select seq,seq from seq_10_to_100; set use_stat_tables= preferably_for_queries; --echo # --echo # with use_stat_tables= PREFERABLY_FOR_QUERIES diff --git a/mysql-test/main/stat_tables_innodb.result b/mysql-test/main/stat_tables_innodb.result index f874f6a0ff6..c90e99a9bbf 100644 --- a/mysql-test/main/stat_tables_innodb.result +++ b/mysql-test/main/stat_tables_innodb.result @@ -77,12 +77,12 @@ and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01' group by n_name order by revenue desc; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort -1 SIMPLE nation ref PRIMARY,i_n_regionkey i_n_regionkey 5 dbt3_s001.region.r_regionkey 5 -1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 Using index -1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 Using index +1 SIMPLE supplier index PRIMARY,i_s_nationkey i_s_nationkey 5 NULL 10 Using where; Using index; Using temporary; Using filesort +1 SIMPLE nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 Using where +1 SIMPLE region eq_ref PRIMARY PRIMARY 4 dbt3_s001.nation.n_regionkey 1 Using where +1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.supplier.s_nationkey 6 Using index 1 SIMPLE orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (14%) Using where; Using rowid filter -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey 9 dbt3_s001.supplier.s_suppkey,dbt3_s001.orders.o_orderkey 1 +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey @@ -208,12 +208,12 @@ and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01' group by n_name order by revenue desc; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort -1 SIMPLE nation ref PRIMARY,i_n_regionkey i_n_regionkey 5 dbt3_s001.region.r_regionkey 5 -1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 Using index -1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 Using index +1 SIMPLE supplier index PRIMARY,i_s_nationkey i_s_nationkey 5 NULL 10 Using where; Using index; Using temporary; Using filesort +1 SIMPLE nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 Using where +1 SIMPLE region eq_ref PRIMARY PRIMARY 4 dbt3_s001.nation.n_regionkey 1 Using where +1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.supplier.s_nationkey 6 Using index 1 SIMPLE orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (14%) Using where; Using rowid filter -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey 9 dbt3_s001.supplier.s_suppkey,dbt3_s001.orders.o_orderkey 1 +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey @@ -246,7 +246,7 @@ order by o_year; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort 1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join) -1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_partkey 5 dbt3_s001.part.p_partkey 30 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 5 dbt3_s001.part.p_partkey 30 Using index condition 1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where 1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 1 SIMPLE orders eq_ref PRIMARY,i_o_orderdate,i_o_custkey PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where @@ -289,6 +289,26 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 Using where 1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.supplier.s_suppkey 8 1 SIMPLE orders eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 +EXPLAIN EXTENDED select nation, o_year, sum(amount) as sum_profit +from (select n_name as nation, +extract(year from o_orderdate) as o_year, +l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount +from part, supplier, lineitem, partsupp, orders, nation +where s_suppkey = l_suppkey and ps_suppkey = l_suppkey +and ps_partkey = l_partkey and p_partkey = l_partkey +and o_orderkey = l_orderkey and s_nationkey = n_nationkey +and p_name like '%green%') as profit +group by nation, o_year +order by nation, o_year desc; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE supplier index PRIMARY,i_s_nationkey i_s_nationkey 5 NULL 10 100.00 Using where; Using index; Using temporary; Using filesort +1 SIMPLE nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 +1 SIMPLE partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70 100.00 +1 SIMPLE part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 100.00 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.supplier.s_suppkey 8 100.00 +1 SIMPLE orders eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 100.00 +Warnings: +Note 1003 select `dbt3_s001`.`nation`.`n_name` AS `nation`,extract(year from `dbt3_s001`.`orders`.`o_orderDATE`) AS `o_year`,sum(`dbt3_s001`.`lineitem`.`l_extendedprice` * (1 - `dbt3_s001`.`lineitem`.`l_discount`) - `dbt3_s001`.`partsupp`.`ps_supplycost` * `dbt3_s001`.`lineitem`.`l_quantity`) AS `sum_profit` from `dbt3_s001`.`part` join `dbt3_s001`.`supplier` join `dbt3_s001`.`lineitem` join `dbt3_s001`.`partsupp` join `dbt3_s001`.`orders` join `dbt3_s001`.`nation` where `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`orders`.`o_orderkey` = `dbt3_s001`.`lineitem`.`l_orderkey` and `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`part`.`p_name` like '%green%' group by `dbt3_s001`.`nation`.`n_name`,extract(year from `dbt3_s001`.`orders`.`o_orderDATE`) desc order by `dbt3_s001`.`nation`.`n_name`,extract(year from `dbt3_s001`.`orders`.`o_orderDATE`) desc select nation, o_year, sum(amount) as sum_profit from (select n_name as nation, extract(year from o_orderdate) as o_year, @@ -623,8 +643,8 @@ set @@use_stat_tables= PREFERABLY; explain SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL -1 SIMPLE global_priv ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) +1 SIMPLE global_priv ALL NULL NULL NULL NULL 5 +1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL Using join buffer (flat, BNL join) set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set use_stat_tables=@save_use_stat_tables; # @@ -884,7 +904,6 @@ set histogram_size=0; # create table t1 (a int, b int); insert into t1(a,b) values (1,2),(1,3),(1,4),(1,5),(2,6),(2,7),(3,8),(3,9),(3,9),(4,10); -insert into t1 select seq,seq from seq_10_to_100; set use_stat_tables= preferably_for_queries; # # with use_stat_tables= PREFERABLY_FOR_QUERIES @@ -898,7 +917,7 @@ db_name table_name column_name min_value max_value nulls_ratio avg_length avg_fr analyze select * from t1 where a = 1 and b=3; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 101 101.00 100.00 0.99 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 10.00 Using where # # with use_stat_tables= PREFERABLY_FOR_QUERIES # analyze table t1 will collect statistics if we use PERSISTENT @@ -910,12 +929,12 @@ test.t1 analyze status Engine-independent statistics collected 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 -test t1 a 1 100 0.0000 4.0000 1.0632 0 NULL NULL +test t1 a 1 4 0.0000 4.0000 2.5000 0 NULL NULL # filtered shows that we used the data from stat tables analyze select * from t1 where a = 1 and b=3; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 101 101.00 1.05 0.99 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 25.00 10.00 Using where # # with use_stat_tables= PREFERABLY # analyze table t1 will collect statistics @@ -927,13 +946,13 @@ test.t1 analyze status Engine-independent statistics collected 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 -test t1 a 1 100 0.0000 4.0000 1.0632 0 NULL NULL -test t1 b 2 100 0.0000 4.0000 1.0202 0 NULL NULL +test t1 a 1 4 0.0000 4.0000 2.5000 0 NULL NULL +test t1 b 2 10 0.0000 4.0000 1.1111 0 NULL NULL # filtered shows that we used the data from stat tables analyze select * from t1 where a=1 and b=3; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 101 101.00 0.99 0.99 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where drop table t1; set @@global.histogram_size=@save_histogram_size; # End of 10.4 tests diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result index 375ed45afbc..748287152b1 100644 --- a/mysql-test/main/statistics_json.result +++ b/mysql-test/main/statistics_json.result @@ -4643,7 +4643,7 @@ Warnings: Note 1003 select `test`.`t1_json`.`a` AS `a` from `test`.`t1_json` where `test`.`t1_json`.`a` < 'b-1a' analyze select * from t1_json where a > 'zzzzzzzzz'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 10.00 0.00 Using where +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 0.00 0.00 Using where drop table ten; UPDATE mysql.column_stats SET histogram='["not-what-you-expect"]' WHERE table_name='t1_json'; diff --git a/mysql-test/main/status.result b/mysql-test/main/status.result index ae64f370e45..0669bdf3b34 100644 --- a/mysql-test/main/status.result +++ b/mysql-test/main/status.result @@ -71,10 +71,10 @@ a 6 show status like 'last_query_cost'; Variable_name Value -Last_query_cost 0.017820 +Last_query_cost 0.017856 show status like 'last_query_cost'; Variable_name Value -Last_query_cost 0.017820 +Last_query_cost 0.017856 select 1; 1 1 @@ -134,20 +134,20 @@ a 1 SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 0.010313 +Last_query_cost 0.010348 EXPLAIN SELECT a FROM t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 0.010313 +Last_query_cost 0.010348 SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a; a 1 2 SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 0.010313 +Last_query_cost 0.010348 EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 @@ -155,25 +155,25 @@ id select_type table type possible_keys key key_len ref rows Extra NULL UNION RESULT ALL NULL NULL NULL NULL NULL Using filesort SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 0.010313 +Last_query_cost 0.010348 SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1; a IN (SELECT a FROM t1) 1 SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 0.010313 +Last_query_cost 0.010348 SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1; x 1 SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 0.010313 +Last_query_cost 0.010348 SELECT * FROM t1 a, t1 b LIMIT 1; a a 1 1 SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value -Last_query_cost 0.021119 +Last_query_cost 0.021190 DROP TABLE t1; connect con1,localhost,root,,; show status like 'com_show_status'; diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index 478404fcefe..b3d69a547d1 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -345,7 +345,7 @@ patient_uq clinic_uq explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t7 index PRIMARY PRIMARY 4 NULL 2 100.00 Using index -1 PRIMARY t6 ALL i1 NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t6 ref i1 i1 5 test.t7.uq 2 100.00 Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t7` join `test`.`t6` where `test`.`t6`.`clinic_uq` = `test`.`t7`.`uq` @@ -1429,6 +1429,9 @@ drop table if exists t1; (SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0); a 1 +# +# IN subselect optimization test +# create table t1 (a int not null, b int, primary key (a)); create table t2 (a int not null, primary key (a)); create table t3 (a int not null, b int, primary key (a)); @@ -1475,42 +1478,48 @@ insert into t1 values (1,10), (2,20), (3,30), (4,40); create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t1 -select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +select rand()*100000+200,rand(1)*100000 from t0 A, t0 B, t0 C, t0 D; insert into t2 values (2), (3), (4), (5); insert into t3 values (10,3), (20,4), (30,5); +explain extended select * from t2 where t2.a in (select a from t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using index; FirstMatch(t2) +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select a from t1); a 2 3 4 -explain extended select * from t2 where t2.a in (select a from t1); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) +1 PRIMARY t3 range a a 5 NULL 3 100.00 Using where; Using index +1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 0.29 Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); a 2 3 -explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +insert into t1 values (3,31); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index -1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` -insert into t1 values (3,31); +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 @@ -1520,12 +1529,6 @@ select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31 a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) -Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 drop table t0, t1, t2, t3; create table t1 (a int, b int); create table t2 (a int, b int); @@ -1587,6 +1590,9 @@ Note 1003 (select 'tttt' AS `s1` from dual) s1 tttt drop table t1; +# +# IN optimisation test results +# create table t1 (s1 char(5), index s1(s1)); create table t2 (s1 char(5), index s1(s1)); insert into t1 values ('a1'),('a2'),('a3'); @@ -1614,21 +1620,21 @@ a3 1 explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index @@ -2420,22 +2426,23 @@ a 1 3 DROP TABLE t1; +# +# SELECT(EXISTS * ...)optimisation +# create table t1 (a int, b int); insert into t1 values (1,2),(3,4),(5,6),(7,8); -select * from t1 up where exists (select * from t1 where t1.a=up.a); -a b -1 2 -3 4 -5 6 -7 8 -explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a); +insert into t1 select seq,seq from seq_20_to_40; +select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); +sum(a+b) +1296 +explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY up ALL NULL NULL NULL NULL 4 100.00 +1 PRIMARY up ALL NULL NULL NULL NULL 25 100.00 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 4 100.00 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 25 100.00 Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` semi join (`test`.`t1`) where 1 +Note 1003 select sum(`test`.`up`.`a` + `test`.`up`.`b`) AS `sum(a+b)` from `test`.`t1` `up` semi join (`test`.`t1`) where 1 drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -3103,6 +3110,10 @@ retailerID statusID changed 0048 1 2006-01-06 12:37:50 0059 1 2006-01-06 12:37:50 drop table t1; +# +# Bug#21180 Subselect with index for both WHERE and ORDER BY +# produces empty result +# create table t1(a int, primary key (a)); insert into t1 values (10); create table t2 (a int primary key, b varchar(32), c int, unique key cb(c, b)); @@ -3118,7 +3129,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using where SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10; @@ -3130,7 +3141,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using index condition; Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using index condition SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10; @@ -4230,8 +4241,8 @@ INSERT INTO t2 VALUES (7), (5), (1), (3); SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); id st -3 FL 1 GA +3 FL 7 FL SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) @@ -4332,6 +4343,9 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; 0 0 DROP TABLE t1, t2; +# +# Bug#28076 inconsistent binary/varbinary comparison +# CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5)); INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43); SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); @@ -4393,8 +4407,8 @@ CREATE INDEX I1 ON t1 (a); CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1) +1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4403,15 +4417,15 @@ CREATE INDEX I1 ON t2 (a); CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t2 ref I1 I1 4 test.t2.b 2 Using where; Using index; FirstMatch(t2) +1 PRIMARY t2 index I1 I1 4 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t2 ref I2 I2 13 test.t2.a 2 Using index condition SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1) +1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -4456,11 +4470,10 @@ EXPLAIN EXTENDED SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` semi join (`test`.`t2`) where 1 +Note 1003 select 2 AS `2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = `test`.`t1`.`a` EXPLAIN EXTENDED SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION (SELECT 1 FROM t2 WHERE t1.a = t2.a)); @@ -5707,6 +5720,7 @@ CREATE TABLE t1 (a int) ; INSERT INTO t1 VALUES (NULL), (1), (NULL), (2); CREATE TABLE t2 (a int, INDEX idx(a)) ; INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000); +insert into t2 select seq from seq_3_to_500; SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a); a @@ -5717,7 +5731,7 @@ WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 502 SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); a @@ -5727,7 +5741,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY t2 ref idx idx 5 test.t1.a 2 Using index; FirstMatch(t1) +1 PRIMARY t2 ref idx idx 5 test.t1.a 11 Using index; FirstMatch(t1) DROP TABLE t1,t2; # # BUG#752992: Wrong results for a subquery with 'semijoin=on' @@ -5744,9 +5758,9 @@ SET @save_join_cache_level=@@join_cache_level; SET join_cache_level=0; EXPLAIN SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 3 -1 PRIMARY it eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 Using index -1 PRIMARY t2 index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(it) +1 PRIMARY it index PRIMARY PRIMARY 4 NULL 3 Using index +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.it.pk 1 +1 PRIMARY t2 index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1); pk i 11 0 diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test index 461d518d99f..48ad7402755 100644 --- a/mysql-test/main/subselect.test +++ b/mysql-test/main/subselect.test @@ -907,9 +907,9 @@ drop table if exists t1; (SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0); -# -# IN subselect optimization test -# +--echo # +--echo # IN subselect optimization test +--echo # create table t1 (a int not null, b int, primary key (a)); create table t2 (a int not null, primary key (a)); create table t3 (a int not null, b int, primary key (a)); @@ -931,20 +931,20 @@ insert into t1 values (1,10), (2,20), (3,30), (4,40); create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t1 -select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +select rand()*100000+200,rand(1)*100000 from t0 A, t0 B, t0 C, t0 D; insert into t2 values (2), (3), (4), (5); insert into t3 values (10,3), (20,4), (30,5); -select * from t2 where t2.a in (select a from t1); explain extended select * from t2 where t2.a in (select a from t1); -select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +select * from t2 where t2.a in (select a from t1); explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); -select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); insert into t1 values (3,31); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); select * from t2 where t2.a in (select a from t1 where t1.b <> 30); select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); drop table t0, t1, t2, t3; # @@ -1018,9 +1018,9 @@ explain extended (select * from t1); (select * from t1); drop table t1; -# -# IN optimisation test results -# +--echo # +--echo # IN optimisation test results +--echo # create table t1 (s1 char(5), index s1(s1)); create table t2 (s1 char(5), index s1(s1)); insert into t1 values ('a1'),('a2'),('a3'); @@ -1452,15 +1452,16 @@ SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = '2'); DROP TABLE t1; -# -# SELECT(EXISTS * ...)optimisation -# +--echo # +--echo # SELECT(EXISTS * ...)optimisation +--echo # #--view-protocol is disabled because view gives another query plan --disable_view_protocol create table t1 (a int, b int); insert into t1 values (1,2),(3,4),(5,6),(7,8); -select * from t1 up where exists (select * from t1 where t1.a=up.a); -explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a); +insert into t1 select seq,seq from seq_20_to_40; +select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); +explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); drop table t1; --enable_view_protocol @@ -2061,10 +2062,10 @@ select * from t1 r1 drop table t1; -# -# Bug#21180 Subselect with index for both WHERE and ORDER BY -# produces empty result -# +--echo # +--echo # Bug#21180 Subselect with index for both WHERE and ORDER BY +--echo # produces empty result +--echo # create table t1(a int, primary key (a)); insert into t1 values (10); @@ -3100,6 +3101,7 @@ INSERT INTO t1 VALUES CREATE TABLE t2 (id int NOT NULL, INDEX idx(id)); INSERT INTO t2 VALUES (7), (5), (1), (3); +--sorted_result SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); SELECT id, st FROM t1 @@ -3274,9 +3276,9 @@ DROP TABLE t1, t2; #--enable_query_log #drop table t1; -# -# Bug#28076 inconsistent binary/varbinary comparison -# +--echo # +--echo # Bug#28076 inconsistent binary/varbinary comparison +--echo # CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5)); INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43); @@ -4856,6 +4858,7 @@ INSERT INTO t1 VALUES (NULL), (1), (NULL), (2); CREATE TABLE t2 (a int, INDEX idx(a)) ; INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000); +insert into t2 select seq from seq_3_to_500; SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a); diff --git a/mysql-test/main/subselect2.result b/mysql-test/main/subselect2.result index dea2a963caf..1af4328aecc 100644 --- a/mysql-test/main/subselect2.result +++ b/mysql-test/main/subselect2.result @@ -277,7 +277,7 @@ KEY `date` (`date`) INSERT INTO `t1` VALUES (2085,'2012-01-01 00:00:00','2013-01-01 00:00:00'); INSERT INTO `t1` VALUES (2084,'2012-02-01 00:00:00','2013-01-01 00:00:00'); INSERT INTO `t1` VALUES (2088,'2012-03-01 00:00:00','2013-01-01 00:00:00'); -explain +set statement optimizer_scan_setup_cost=0 for explain SELECT * FROM ( SELECT node_uid, date, mirror_date, @result := 0 AS result FROM t1 @@ -286,9 +286,9 @@ WHERE date < '2012-12-12 12:12:12' ORDER BY mirror_date ASC ) AS calculated_result; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 3 -2 DERIVED t1 ALL date NULL NULL NULL 3 Using where; Using filesort -SELECT * FROM ( +1 PRIMARY ALL NULL NULL NULL NULL 3 +3 DERIVED t1 ALL date NULL NULL NULL 3 Using where; Using filesort +set statement optimizer_scan_setup_cost=0 FOR SELECT * FROM ( SELECT node_uid, date, mirror_date, @result := 0 AS result FROM t1 WHERE date < '2012-12-12 12:12:12' @@ -310,7 +310,7 @@ ORDER BY mirror_date ASC ) AS calculated_result; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 3 -2 DERIVED t1 ALL date NULL NULL NULL 3 Using where; Using filesort +2 DERIVED t1 range date date 6 NULL 3 Using index condition; Using where; Using filesort SELECT * FROM ( SELECT node_uid, date, mirror_date, @result := 0 AS result FROM t1 diff --git a/mysql-test/main/subselect2.test b/mysql-test/main/subselect2.test index b341e516941..0780a5b9319 100644 --- a/mysql-test/main/subselect2.test +++ b/mysql-test/main/subselect2.test @@ -303,7 +303,7 @@ INSERT INTO `t1` VALUES (2085,'2012-01-01 00:00:00','2013-01-01 00:00:00'); INSERT INTO `t1` VALUES (2084,'2012-02-01 00:00:00','2013-01-01 00:00:00'); INSERT INTO `t1` VALUES (2088,'2012-03-01 00:00:00','2013-01-01 00:00:00'); -explain +set statement optimizer_scan_setup_cost=0 for explain SELECT * FROM ( SELECT node_uid, date, mirror_date, @result := 0 AS result FROM t1 @@ -312,7 +312,7 @@ SELECT * FROM ( ORDER BY mirror_date ASC ) AS calculated_result; -SELECT * FROM ( +set statement optimizer_scan_setup_cost=0 FOR SELECT * FROM ( SELECT node_uid, date, mirror_date, @result := 0 AS result FROM t1 WHERE date < '2012-12-12 12:12:12' diff --git a/mysql-test/main/subselect3.result b/mysql-test/main/subselect3.result index 36063f3e594..c41b3e3c48f 100644 --- a/mysql-test/main/subselect3.result +++ b/mysql-test/main/subselect3.result @@ -1157,9 +1157,9 @@ set @@optimizer_switch='firstmatch=off,materialization=off'; set @@max_heap_table_size= 16384; explain select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E where a+1 < 10000 + A.a + B.a +C.a+D.a); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY A ALL NULL NULL NULL NULL 10 +1 PRIMARY E ALL NULL NULL NULL NULL 5 Start temporary +1 PRIMARY A ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join) 1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join) -1 PRIMARY E ALL NULL NULL NULL NULL 5 Start temporary; Using join buffer (flat, BNL join) 1 PRIMARY C ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) 1 PRIMARY D ALL NULL NULL NULL NULL 10 Using where; End temporary; Using join buffer (flat, BNL join) flush status; @@ -1341,9 +1341,9 @@ count(*) explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 -1 PRIMARY X ALL NULL NULL NULL NULL 6 Using where -1 PRIMARY Y ALL NULL NULL NULL NULL 6 Using where -1 PRIMARY Z ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t1) +1 PRIMARY X ALL NULL NULL NULL NULL 6 Using where; Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY Y ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +1 PRIMARY Z ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join) drop table t0,t1,t2; set @@optimizer_switch=@save_optimizer_switch; @@ -1418,7 +1418,7 @@ WHERE cona.postalStripped='T2H3B2' id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY cona ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary 1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where -1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 50.00 Using index; End temporary Warnings: Note 1003 select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where `test`.`cona`.`postalStripped` = 'T2H3B2' and `test`.`a`.`idIndividual` = `test`.`c`.`idObj` and `test`.`c`.`idContact` = `test`.`cona`.`idContact` SELECT a.idIndividual FROM t1 a diff --git a/mysql-test/main/subselect3_jcl6.result b/mysql-test/main/subselect3_jcl6.result index 41f280b5bd0..13f61b7d101 100644 --- a/mysql-test/main/subselect3_jcl6.result +++ b/mysql-test/main/subselect3_jcl6.result @@ -622,8 +622,8 @@ aa 1 1 bb NULL NULL select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); oref a -cc 5 aa 1 +cc 5 select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); oref a ee NULL @@ -1160,9 +1160,9 @@ set @@optimizer_switch='firstmatch=off,materialization=off'; set @@max_heap_table_size= 16384; explain select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E where a+1 < 10000 + A.a + B.a +C.a+D.a); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY A ALL NULL NULL NULL NULL 10 -1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join) -1 PRIMARY E ALL NULL NULL NULL NULL 5 Using where; Start temporary; Using join buffer (incremental, BNL join) +1 PRIMARY E ALL NULL NULL NULL NULL 5 Using where; Start temporary +1 PRIMARY A ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join) +1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (incremental, BNL join) 1 PRIMARY C ALL NULL NULL NULL NULL 10 Using where; Using join buffer (incremental, BNL join) 1 PRIMARY D hash_ALL NULL #hash#$hj 5 test.E.a 10 Using where; End temporary; Using join buffer (incremental, BNLH join) flush status; @@ -1421,7 +1421,7 @@ WHERE cona.postalStripped='T2H3B2' id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY cona ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary 1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 50.00 Using index; End temporary Warnings: Note 1003 select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where `test`.`cona`.`postalStripped` = 'T2H3B2' and `test`.`a`.`idIndividual` = `test`.`c`.`idObj` and `test`.`c`.`idContact` = `test`.`cona`.`idContact` SELECT a.idIndividual FROM t1 a diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index 48fe29344a5..c96379ee856 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -1367,8 +1367,8 @@ GROUP BY SQ1_t1.f4)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where -3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary -3 SUBQUERY SQ1_t3 index f4 f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +3 SUBQUERY SQ1_t3 range f4 f4 5 NULL 2 Using where; Using index; Using temporary +3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using join buffer (flat, BNL join) SELECT * FROM t1 WHERE (SELECT f2 FROM t2 WHERE f4 <= ALL @@ -1388,8 +1388,8 @@ INSERT INTO t2 VALUES (1), (2); EXPLAIN SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 SUBQUERY t2 index k k 5 NULL 2 Using where; Using index +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 index_subquery k k 5 const 2 Using index DROP TABLE t2; DROP TABLE t1; # @@ -1785,7 +1785,7 @@ SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t3 system NULL NULL NULL NULL 1 -2 SUBQUERY t2 index f10 f10 10 NULL 2 Using where; Using index +2 SUBQUERY t2 ref_or_null f10 f10 10 const,const 2 Using where; Using index SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10); f4 drop table t1,t2,t3; @@ -2758,15 +2758,15 @@ from t2 join t1 on id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 index NULL v1 9 NULL 5 Using index -2 SUBQUERY t1 ref_or_null v1 v1 4 const 3 Using where; Using index -2 SUBQUERY t3 ALL NULL NULL NULL NULL 4 Using where -2 SUBQUERY t4 ALL NULL NULL NULL NULL 50 Using where +2 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 Using where +2 MATERIALIZED t1 ref v1 v1 4 test.t3.v2 1 Using index +2 MATERIALIZED t4 ALL NULL NULL NULL NULL 50 select 1 from t2 join t1 on ('i','w') not in (select t1.v1,t4.v2 from t4,t1,t3 where t3.v2 = t1.v1) LIMIT ROWS EXAMINED 10; 1 Warnings: -Warning 1931 Query execution was interrupted. The query examined at least 11 rows, which exceeds LIMIT ROWS EXAMINED (10). The query result may be incomplete +Warning 1931 Query execution was interrupted. The query examined at least 14 rows, which exceeds LIMIT ROWS EXAMINED (10). The query result may be incomplete SET join_cache_level= @save_join_cache_level; DROP TABLE t1,t2,t3,t4; # diff --git a/mysql-test/main/subselect_exists2in.result b/mysql-test/main/subselect_exists2in.result index 7b3966c3f93..45655afe662 100644 --- a/mysql-test/main/subselect_exists2in.result +++ b/mysql-test/main/subselect_exists2in.result @@ -51,8 +51,8 @@ c explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t3 WHERE t3.b = t1.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index aa aa 4 NULL 2 100.00 Using index -1 PRIMARY t3 ALL bb NULL NULL NULL 2 75.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) +1 PRIMARY t1 index aa aa 4 NULL 2 100.00 Using where; Using index +1 PRIMARY t3 ref bb bb 4 test.t1.a 2 50.00 FirstMatch(t1) Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where `test`.`t3`.`b` = `test`.`t1`.`a` @@ -65,10 +65,10 @@ explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t3 WHERE t3.b = t1.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL aa 4 NULL 2 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t3 ALL bb NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t3 index_subquery bb bb 4 func 2 100.00 Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`b` from `test`.`t3` where (`test`.`t1`.`a`) = `test`.`t3`.`b`)) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in t3 on bb))) -- EXIST2IN then MATERIALIZATION set optimizer_switch='exists_to_in=on,in_to_exists=off,semijoin=off,materialization=on,subquery_cache=off'; SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t3 WHERE t3.b = t1.a); @@ -91,7 +91,7 @@ explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t3 WHERE t3.b = t1.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL aa 4 NULL 2 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t3 ALL bb NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t3 ref bb bb 4 test.t1.a 2 100.00 Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(/* select#2 */ select `test`.`t3`.`a` from `test`.`t3` where `test`.`t3`.`b` = `test`.`t1`.`a` limit 1) @@ -304,6 +304,7 @@ CREATE TABLE t1 ( a INT ); INSERT INTO t1 VALUES (7),(0),(100); CREATE TABLE t2 ( b INT ); INSERT INTO t2 VALUES (0),(8),(1000),(2000),(3000),(4000),(5000); +insert into t2 select seq from seq_6000_to_6100; SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t2 WHERE b = a ) OR a > 0; @@ -317,7 +318,7 @@ EXISTS ( SELECT * FROM t2 WHERE b = a ) OR a > 0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 108 100.00 Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where 1 ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`b`)))) or `test`.`t1`.`a` > 0 @@ -390,7 +391,7 @@ explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t3 WHERE t3.b = t1.a and t3.b1 = t1.a1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 index bb bb 8 NULL 2 100.00 Using where; Using index; LooseScan -1 PRIMARY t1 ref aa aa 8 test.t3.b,test.t3.b1 2 100.00 Using index +1 PRIMARY t1 ref aa aa 8 test.t3.b,test.t3.b1 2 50.00 Using index Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a1' of SELECT #2 was resolved in SELECT #1 @@ -626,7 +627,7 @@ SELECT * FROM t1 AS alias WHERE EXISTS ( SELECT * FROM t1 WHERE a > alias.a AND a = alias.b ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY alias ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary; End temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary Warnings: Note 1276 Field or reference 'test.alias.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.alias.b' of SELECT #2 was resolved in SELECT #1 @@ -719,12 +720,13 @@ set optimizer_switch='exists_to_in=on'; create table t1 (col1 int, col2 int, col3 int); insert into t1 values (1,2,3),(2,3,4),(4,5,6),(7,8,9); create table t2 as select * from t1; +insert into t2 select seq,seq,seq from seq_1000_to_1200; explain extended select * from t1 where exists (select col2 from t2 where t2.col1=t1.col1 and t2.col2=t1.col2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00 1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 100.00 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 205 100.00 Warnings: Note 1276 Field or reference 'test.t1.col1' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.col2' of SELECT #2 was resolved in SELECT #1 @@ -907,7 +909,7 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where -3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch 3 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'sq1.pk' of SELECT #3 was resolved in SELECT #1 @@ -926,7 +928,7 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where -3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch 3 DEPENDENT SUBQUERY sq2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'sq1.pk' of SELECT #3 was resolved in SELECT #1 diff --git a/mysql-test/main/subselect_exists2in.test b/mysql-test/main/subselect_exists2in.test index cf06e7cbd2c..625c007e006 100644 --- a/mysql-test/main/subselect_exists2in.test +++ b/mysql-test/main/subselect_exists2in.test @@ -1,4 +1,5 @@ --source include/default_optimizer_switch.inc +--source include/have_sequence.inc --disable_warnings drop table if exists t1,t2,t3; @@ -245,6 +246,7 @@ CREATE TABLE t1 ( a INT ); INSERT INTO t1 VALUES (7),(0),(100); CREATE TABLE t2 ( b INT ); INSERT INTO t2 VALUES (0),(8),(1000),(2000),(3000),(4000),(5000); +insert into t2 select seq from seq_6000_to_6100; SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t2 WHERE b = a ) @@ -573,6 +575,8 @@ set optimizer_switch='exists_to_in=on'; create table t1 (col1 int, col2 int, col3 int); insert into t1 values (1,2,3),(2,3,4),(4,5,6),(7,8,9); create table t2 as select * from t1; +insert into t2 select seq,seq,seq from seq_1000_to_1200; + explain extended select * from t1 where exists (select col2 from t2 where t2.col1=t1.col1 and t2.col2=t1.col2); select * from t1 where exists (select col2 from t2 where t2.col1=t1.col1 and t2.col2=t1.col2); diff --git a/mysql-test/main/subselect_exists2in_costmat.result b/mysql-test/main/subselect_exists2in_costmat.result index 5630f8f275a..1c9574aafd3 100644 --- a/mysql-test/main/subselect_exists2in_costmat.result +++ b/mysql-test/main/subselect_exists2in_costmat.result @@ -64,8 +64,8 @@ Code = Country) OR Name LIKE 'L%') AND surfacearea > 1000000; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY Country range Name,SurfaceArea SurfaceArea 4 NULL 71 Using index condition; Using where; Rowid-ordered scan -2 DEPENDENT SUBQUERY City index_subquery Population,Country Country 3 func 17 Using where +1 PRIMARY Country ALL Name,SurfaceArea NULL NULL NULL 239 Using where +2 MATERIALIZED City ALL Population,Country NULL NULL NULL 4079 Using where SELECT Name FROM Country WHERE (EXISTS (select 1 from City where City.Population > 100000 and Code = Country) OR diff --git a/mysql-test/main/subselect_innodb.result b/mysql-test/main/subselect_innodb.result index c95cf3abb37..b74ad66366f 100644 --- a/mysql-test/main/subselect_innodb.result +++ b/mysql-test/main/subselect_innodb.result @@ -462,7 +462,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT b FROM t2, t3 GROUP BY b HAVING b != 3 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 SUBQUERY t2 index NULL PRIMARY 4 NULL 1 Using index; Using temporary +2 SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using temporary 2 SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) SELECT * FROM t1 WHERE EXISTS ( SELECT b FROM t2, t3 GROUP BY b HAVING b != 3 ); a @@ -612,7 +612,7 @@ INNER JOIN ON ( 1 IN ( SELECT f4 FROM t4 ) ) ) ON ( f1 >= f2 ); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 PRIMARY t4 ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (incremental, BNL join) diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result index eef237ef8de..d939078c897 100644 --- a/mysql-test/main/subselect_mat.result +++ b/mysql-test/main/subselect_mat.result @@ -105,7 +105,7 @@ explain extended select * from t1i where a1 in (select b1 from t2i where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where; -2 MATERIALIZED t2i index it2i1,it2i3 it2i1 # NULL 5 100.00 Using where; +2 MATERIALIZED t2i range it2i1,it2i3 it2i1 # NULL 5 100.00 Using where; Warnings: Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <`test`.`t1i`.`a1`>((`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( (/* select#2 */ select `test`.`t2i`.`b1` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), (`test`.`t1i`.`a1` in on distinct_key where `test`.`t1i`.`a1` = ``.`b1`)))) select * from t1i where a1 in (select b1 from t2i where b1 > '0'); @@ -127,7 +127,7 @@ explain extended select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where; -2 MATERIALIZED t2i index it2i1,it2i3 it2i3 # NULL 5 100.00 Using where; +2 MATERIALIZED t2i range it2i1,it2i3 it2i3 # NULL 5 100.00 Using where; Warnings: Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( (/* select#2 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), (`test`.`t1i`.`a1` in on distinct_key where `test`.`t1i`.`a1` = ``.`b1` and `test`.`t1i`.`a2` = ``.`b2`)))) select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0'); @@ -340,7 +340,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL # # # 3 100.00 # 3 MATERIALIZED t3i index NULL # # # 4 100.00 # 4 MATERIALIZED t2i index it2i2 # # # 5 100.00 # -2 MATERIALIZED t2i index it2i1,it2i3 # # # 5 100.00 # +2 MATERIALIZED t2i range it2i1,it2i3 # # # 5 100.00 # Warnings: Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( (/* select#2 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), (`test`.`t1i`.`a1` in on distinct_key where `test`.`t1i`.`a1` = ``.`b1` and `test`.`t1i`.`a2` = ``.`b2`)))) and <`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( (/* select#3 */ select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <`test`.`t3i`.`c1`,`test`.`t3i`.`c2`>(((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( (/* select#4 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), (`test`.`t3i`.`c1` in on distinct_key where `test`.`t3i`.`c1` = ``.`b1` and `test`.`t3i`.`c2` = ``.`b2`)))) ), (`test`.`t1i`.`a1` in on distinct_key where `test`.`t1i`.`a1` = ``.`c1` and `test`.`t1i`.`a2` = ``.`c2`)))) select * from t1i @@ -423,7 +423,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 7 UNION t1i index NULL # # # 3 100.00 # 9 MATERIALIZED t3i index NULL # # # 4 100.00 # 10 MATERIALIZED t2i index it2i2 # # # 5 100.00 # -8 MATERIALIZED t2i index it2i1,it2i3 # # # 5 100.00 # +8 MATERIALIZED t2i range it2i1,it2i3 # # # 5 100.00 # NULL UNION RESULT ALL NULL # # # NULL NULL # Warnings: Note 1003 (/* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( (/* select#2 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where <`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`)))) or <`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`)))) ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`b1` and `test`.`t1`.`a2` = ``.`b2`)))) and <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( (/* select#5 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <`test`.`t3`.`c1`,`test`.`t3`.`c2`>(((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( (/* select#6 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), (`test`.`t3`.`c1` in on distinct_key where `test`.`t3`.`c1` = ``.`b1` and `test`.`t3`.`c2` = ``.`b2`)))) ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`c1` and `test`.`t1`.`a2` = ``.`c2`))))) union (/* select#7 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( (/* select#8 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), (`test`.`t1i`.`a1` in on distinct_key where `test`.`t1i`.`a1` = ``.`b1` and `test`.`t1i`.`a2` = ``.`b2`)))) and <`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( (/* select#9 */ select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <`test`.`t3i`.`c1`,`test`.`t3i`.`c2`>(((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( (/* select#10 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), (`test`.`t3i`.`c1` in on distinct_key where `test`.`t3i`.`c1` = ``.`b1` and `test`.`t3i`.`c2` = ``.`b2`)))) ), (`test`.`t1i`.`a1` in on distinct_key where `test`.`t1i`.`a1` = ``.`c1` and `test`.`t1i`.`a2` = ``.`c2`))))) @@ -1142,7 +1142,7 @@ a explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL it1a 4 NULL 7 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`c`)))) @@ -1154,7 +1154,7 @@ create index iab on t1(a, b); explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL it1a 4 NULL 7 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`c`)))) @@ -1166,7 +1166,7 @@ explain extended select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL iab 8 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL iab 4 NULL 7 100.00 Using index for group-by 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: @@ -1516,6 +1516,9 @@ COUNT(*) 2 set @@optimizer_switch= @local_optimizer_switch; DROP TABLE t1, t2; +# +# BUG#46548 IN-subqueries return 0 rows with materialization=on +# CREATE TABLE t1 ( pk int, a varchar(1), @@ -1525,15 +1528,19 @@ d varchar(4), PRIMARY KEY (pk) ); INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +insert into t1 select seq,'x','xxxx','xxxx','xxxx' from seq_10_to_40; CREATE TABLE t2 LIKE t1; INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +insert into t2 select -seq,'a','aaaa','aaaa','aaaa' from seq_1_to_20; +insert into t2 select seq,'b','bbbb','bbbb','bbbb' from seq_100_to_200; set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; SET @@optimizer_switch='semijoin=on,materialization=on'; EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 -1 PRIMARY t2 ALL PRIMARY NULL NULL NULL 2 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 33 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 123 Using where SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); pk 2 @@ -1887,20 +1894,21 @@ WHERE alias4.c = alias3.b ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2 -3 MATERIALIZED alias4 index c c 11 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2 Using where +3 MATERIALIZED alias4 ref c c 11 test.alias3.b 2 Using where; Using index DROP TABLE t1,t2; # # BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result # create table t1 (a int, b int); insert into t1 values (7,5), (3,3), (5,4), (9,3); +insert into t1 select seq,seq from seq_100_to_200; create table t2 (a int, b int, index i_a(a)); insert into t2 values (4,2), (7,9), (7,4), (3,1), (5,3), (3,1), (9,4), (8,1); explain select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 105 Using where 2 MATERIALIZED t2 ALL i_a NULL NULL NULL 8 Using where select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1); a b @@ -2192,8 +2200,8 @@ mysqltest1 EXPLAIN EXTENDED SELECT db FROM t1 WHERE db IN (SELECT SCHEMA_NAME FROM information_schema.schemata) ORDER BY db DESC; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY schemata ALL NULL NULL NULL NULL NULL NULL Start temporary; Using temporary; Using filesort -1 PRIMARY t1 eq_ref db db 764 information_schema.schemata.SCHEMA_NAME 1 100.00 Using where; Using index; End temporary +1 PRIMARY t1 index db db 764 NULL 4 100.00 Using index; Using temporary; Using filesort +1 PRIMARY schemata ALL NULL NULL NULL NULL NULL NULL Using where; FirstMatch(t1); Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`db` AS `db` from `test`.`t1` semi join (`information_schema`.`schemata`) where `test`.`t1`.`db` = `information_schema`.`schemata`.`SCHEMA_NAME` order by `test`.`t1`.`db` desc drop table t1; @@ -2225,8 +2233,10 @@ drop table t1; CREATE TABLE t1 ( pk INT, f1 INT NOT NULL, f2 VARCHAR(3), f3 INT NULL, PRIMARY KEY(pk)) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,1,'foo',8), (2,5,'bar',7); +create table t2 like t1; +insert into t2 select * from t1; SELECT sq1.f2 FROM t1 AS sq1 -WHERE EXISTS ( SELECT * FROM t1 AS sq2 +WHERE EXISTS ( SELECT * FROM t2 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); f2 foo @@ -2243,12 +2253,12 @@ id select_type table type possible_keys key key_len ref rows Extra # this checks the result set above set optimizer_switch= 'materialization=off,semijoin=off'; SELECT sq1.f2 FROM t1 AS sq1 -WHERE EXISTS ( SELECT * FROM t1 AS sq2 +WHERE EXISTS ( SELECT * FROM t2 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); f2 foo set optimizer_switch= @local_optimizer_switch; -DROP TABLE t1; +DROP TABLE t1,t2; # # MDEV-12145: IN subquery used in WHERE of EXISTS subquery # @@ -2271,8 +2281,8 @@ WHERE EXISTS ( SELECT * FROM t2, t3 WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where -2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch -2 DEPENDENT SUBQUERY t2 index i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch +2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index Warnings: Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 @@ -2309,7 +2319,7 @@ SELECT pk, f1, ( SELECT COUNT(*) FROM t2 WHERE t1.pk IN ( SELECT f2 FROM t2 ) ) AS sq FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; FirstMatch +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 @@ -2393,11 +2403,10 @@ WHERE t2.ugroup = t3_i.sys_id AND t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND t2.user = '86826bf03710200044e0bfc8bcbe5d79'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where +1 PRIMARY t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where; Start temporary +1 PRIMARY t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where +1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t3_i.sys_id 2 Using index condition; Using where; End temporary 1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index -2 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where -2 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where set statement optimizer_prune_level=1 for explain SELECT t1.assignment_group FROM t1, t3 WHERE t1.assignment_group = t3.sys_id AND @@ -2408,11 +2417,10 @@ WHERE t2.ugroup = t3_i.sys_id AND t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND t2.user = '86826bf03710200044e0bfc8bcbe5d79'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where +1 PRIMARY t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where; Start temporary +1 PRIMARY t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where +1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t3_i.sys_id 2 Using index condition; Using where; End temporary 1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index -3 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where -3 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where SELECT t1.assignment_group FROM t1, t3 WHERE t1.assignment_group = t3.sys_id AND @@ -2455,9 +2463,8 @@ alter table t1 add key(id); explain SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 -1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t1 index id id 4 NULL 9 Using index +1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); 1 1 @@ -2506,20 +2513,17 @@ drop procedure prepare_data; set @@optimizer_switch= @local_optimizer_switch; drop table t1,t2,t3; CREATE TABLE t1 ( id int NOT NULL, key(id)); -INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO t1 select seq from seq_11_to_39; CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL); -INSERT INTO t2 VALUES (11,11),(12,12),(13,13); +INSERT INTO t2 select seq,seq+1 from seq_11_to_50; CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2; explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 -1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t1 index id id 4 NULL 29 Using index +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 40 Using where SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); 1 -1 -1 -1 drop table t1,t2; drop view v1; # @@ -2815,8 +2819,7 @@ SET @@optimizer_switch='default,semijoin=on,materialization=on'; EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where +1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; FirstMatch(t1); Using join buffer (flat, BNL join) SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); pk 2 diff --git a/mysql-test/main/subselect_mat_cost.result b/mysql-test/main/subselect_mat_cost.result index 9de70573189..d7ae095e1db 100644 --- a/mysql-test/main/subselect_mat_cost.result +++ b/mysql-test/main/subselect_mat_cost.result @@ -59,15 +59,15 @@ set @@optimizer_switch = 'in_to_exists=on,semijoin=on,materialization=on,partial Q1.1m: MATERIALIZATION: there are too many rows in the outer query to be looked up in the inner table. -set statement optimizer_cache_hit_ratio=20 for EXPLAIN +EXPLAIN SELECT count(*) FROM Country WHERE (Code IN (select Country from City where City.Population > 100000) OR Name LIKE 'L%') AND surfacearea > 100000; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY Country ALL Name,SurfaceArea NULL NULL NULL 239 Using where -3 MATERIALIZED City ALL Population,Country NULL NULL NULL 4079 Using where -set statement optimizer_cache_hit_ratio=20 for SELECT count(*) FROM Country +2 MATERIALIZED City ALL Population,Country NULL NULL NULL 4079 Using where +SELECT count(*) FROM Country WHERE (Code IN (select Country from City where City.Population > 100000) OR Name LIKE 'L%') AND surfacearea > 100000; @@ -105,13 +105,25 @@ Country.SurfaceArea < 3000 AND Country.SurfaceArea > 10 AND (select Language from CountryLanguage where Percentage > 50) OR City.name LIKE '%Island%'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY Country range PRIMARY,SurfaceArea SurfaceArea 4 NULL 47 Using index condition; Rowid-ordered scan +1 PRIMARY Country ALL PRIMARY,SurfaceArea NULL NULL NULL 239 Using where 1 PRIMARY City ref Country Country 3 world.Country.Code 17 Using where -2 MATERIALIZED CountryLanguage range Percentage,Language Percentage 4 NULL 197 Using index condition; Rowid-ordered scan +2 MATERIALIZED CountryLanguage ALL Percentage,Language NULL NULL NULL 984 Using where +EXPLAIN SELECT * FROM Country, City WHERE City.Country = Country.Code AND -Country.SurfaceArea < 3000 AND Country.SurfaceArea > 10 AND +Country.SurfaceArea < 500 AND Country.SurfaceArea > 10 AND +(City.Name IN +(select Language from CountryLanguage where Percentage > 50) OR +City.name LIKE '%Island%'); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY Country range PRIMARY,SurfaceArea SurfaceArea 4 NULL 32 Using index condition; Rowid-ordered scan +1 PRIMARY City ref Country Country 3 world.Country.Code 17 Using where +2 MATERIALIZED CountryLanguage ALL Percentage,Language NULL NULL NULL 984 Using where +SELECT * +FROM Country, City +WHERE City.Country = Country.Code AND +Country.SurfaceArea < 500 AND Country.SurfaceArea > 10 AND (City.Name IN (select Language from CountryLanguage where Percentage > 50) OR City.name LIKE '%Island%'); @@ -130,7 +142,7 @@ Country.SurfaceArea < 3000 AND Country.SurfaceArea > 10 AND (select Language from CountryLanguage where Percentage > 50) OR Country.name LIKE '%Island%'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY Country range PRIMARY,SurfaceArea SurfaceArea 4 NULL 47 Using index condition; Using where; Rowid-ordered scan +1 PRIMARY Country ALL PRIMARY,SurfaceArea NULL NULL NULL 239 Using where 1 PRIMARY City ref Country Country 3 world.Country.Code 17 2 DEPENDENT SUBQUERY CountryLanguage index_subquery Percentage,Language Language 30 func 2 Using where SELECT * @@ -175,7 +187,7 @@ OR (Country.Code, City.Name) IN (select Country, Language from CountryLanguage)); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY Country range PRIMARY,SurfaceArea SurfaceArea 4 NULL 73 Using index condition; Rowid-ordered scan +1 PRIMARY Country ALL PRIMARY,SurfaceArea NULL NULL NULL 239 Using where 1 PRIMARY City ref Country Country 3 world.Country.Code 17 Using where 3 MATERIALIZED CountryLanguage index PRIMARY,Language PRIMARY 33 NULL 984 Using index 2 DEPENDENT SUBQUERY CountryLanguage unique_subquery PRIMARY,Percentage,Language PRIMARY 33 func,func 1 Using where @@ -487,9 +499,30 @@ FROM City JOIN Country ON City.Country = Country.Code GROUP BY City.Name HAVING City.Name IN (select Name from Country where population < 1000000); id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY City ALL Country NULL NULL NULL 4079 Using temporary; Using filesort +1 PRIMARY Country eq_ref PRIMARY PRIMARY 3 world.City.Country 1 Using index +2 MATERIALIZED Country ALL Name NULL NULL NULL 239 Using where +Last_query_cost 5.934845 +EXPLAIN +SELECT straight_join City.Name, City.Population +FROM Country JOIN City ON City.Country = Country.Code +GROUP BY City.Name +HAVING City.Name IN (select Name from Country where population < 1000000); +id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY Country index PRIMARY PRIMARY 3 NULL 239 Using index; Using temporary; Using filesort 1 PRIMARY City ref Country Country 3 world.Country.Code 17 2 MATERIALIZED Country ALL Name NULL NULL NULL 239 Using where +Last_query_cost 7.951232 +EXPLAIN +SELECT City.Name, City.Population +FROM Country LEFT JOIN City ON City.Country = Country.Code +GROUP BY City.Name +HAVING City.Name IN (select Name from Country where population < 1000000); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY Country index NULL PRIMARY 3 NULL 239 Using index; Using temporary; Using filesort +1 PRIMARY City ref Country Country 3 world.Country.Code 17 +2 MATERIALIZED Country ALL Name NULL NULL NULL 239 Using where +Last_query_cost 7.951232 SELECT City.Name, City.Population FROM City JOIN Country ON City.Country = Country.Code GROUP BY City.Name diff --git a/mysql-test/main/subselect_mat_cost.test b/mysql-test/main/subselect_mat_cost.test index 6b7fa4fee64..60763076c45 100644 --- a/mysql-test/main/subselect_mat_cost.test +++ b/mysql-test/main/subselect_mat_cost.test @@ -73,13 +73,13 @@ set @@optimizer_switch = 'in_to_exists=on,semijoin=on,materialization=on,partial -- echo Q1.1m: -- echo MATERIALIZATION: there are too many rows in the outer query -- echo to be looked up in the inner table. -set statement optimizer_cache_hit_ratio=20 for EXPLAIN +EXPLAIN SELECT count(*) FROM Country WHERE (Code IN (select Country from City where City.Population > 100000) OR Name LIKE 'L%') AND surfacearea > 100000; -set statement optimizer_cache_hit_ratio=20 for SELECT count(*) FROM Country +SELECT count(*) FROM Country WHERE (Code IN (select Country from City where City.Population > 100000) OR Name LIKE 'L%') AND surfacearea > 100000; @@ -113,10 +113,19 @@ SELECT * (select Language from CountryLanguage where Percentage > 50) OR City.name LIKE '%Island%'); +EXPLAIN SELECT * FROM Country, City WHERE City.Country = Country.Code AND - Country.SurfaceArea < 3000 AND Country.SurfaceArea > 10 AND + Country.SurfaceArea < 500 AND Country.SurfaceArea > 10 AND + (City.Name IN + (select Language from CountryLanguage where Percentage > 50) OR + City.name LIKE '%Island%'); + +SELECT * + FROM Country, City + WHERE City.Country = Country.Code AND + Country.SurfaceArea < 500 AND Country.SurfaceArea > 10 AND (City.Name IN (select Language from CountryLanguage where Percentage > 50) OR City.name LIKE '%Island%'); @@ -374,13 +383,27 @@ SELECT City.Name, City.Population FROM City JOIN Country ON City.Country = Country.Code GROUP BY City.Name HAVING City.Name IN (select Name from Country where population < 1000000); +--source include/last_query_cost.inc + +EXPLAIN +SELECT straight_join City.Name, City.Population +FROM Country JOIN City ON City.Country = Country.Code +GROUP BY City.Name +HAVING City.Name IN (select Name from Country where population < 1000000); +--source include/last_query_cost.inc + +EXPLAIN +SELECT City.Name, City.Population +FROM Country LEFT JOIN City ON City.Country = Country.Code +GROUP BY City.Name +HAVING City.Name IN (select Name from Country where population < 1000000); +--source include/last_query_cost.inc SELECT City.Name, City.Population FROM City JOIN Country ON City.Country = Country.Code GROUP BY City.Name HAVING City.Name IN (select Name from Country where population < 1000000); - -- echo -- echo 5. Subqueries with UNION -- echo diff --git a/mysql-test/main/subselect_mat_cost_bugs.result b/mysql-test/main/subselect_mat_cost_bugs.result index 14522a24950..77b3430ba1f 100644 --- a/mysql-test/main/subselect_mat_cost_bugs.result +++ b/mysql-test/main/subselect_mat_cost_bugs.result @@ -95,9 +95,9 @@ t1a ON (t1a.c2 = t1b.pk AND 2) WHERE t1.pk) ; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 9 100.00 Using where -2 DEPENDENT SUBQUERY t1b ALL NULL NULL NULL NULL 9 100.00 +2 DEPENDENT SUBQUERY t1b ALL NULL NULL NULL NULL 9 100.00 Using where 2 DEPENDENT SUBQUERY t1a ref c2 c2 5 test.t1b.pk 1 100.00 Using where -2 DEPENDENT SUBQUERY t2 index c3 c3 9 NULL 2 75.00 Using where; Using index; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t2 ref c3 c3 4 test.t1b.c4 1 100.00 Using index Warnings: Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <`test`.`t1`.`c1`,`test`.`t1`.`pk`>((`test`.`t1`.`c1`,(/* select#2 */ select `test`.`t1a`.`c1` from `test`.`t1b` join `test`.`t2` left join `test`.`t1a` on(`test`.`t1a`.`c2` = `test`.`t1b`.`pk` and 2) where `test`.`t2`.`c3` = `test`.`t1b`.`c4` and `test`.`t1`.`pk` <> 0 and (`test`.`t1`.`c1`) = `test`.`t1a`.`c1`))) @@ -196,8 +196,8 @@ ORDER BY field1 ; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 2 Using where; Using filesort 1 PRIMARY alias1 eq_ref PRIMARY PRIMARY 4 alias2.f3 1 Using index -3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 -3 DEPENDENT SUBQUERY t1 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +3 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) 2 DERIVED t2 ALL NULL NULL NULL NULL 2 SELECT alias2.f2 AS field1 FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1 @@ -263,8 +263,8 @@ WHERE alias1.f11 OR alias1.f3 = 50 AND alias1.f10 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where -2 MATERIALIZED alias1 ALL NULL NULL NULL NULL 2 Using where -2 MATERIALIZED alias2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY alias1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY alias2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) SELECT * FROM t2 WHERE ( f12 ) IN ( SELECT alias2.f3 @@ -275,6 +275,8 @@ f12 f13 Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'f' Warning 1292 Truncated incorrect DECIMAL value: 'd' +Warning 1292 Truncated incorrect DECIMAL value: 'f' +Warning 1292 Truncated incorrect DECIMAL value: 'd' EXPLAIN SELECT * FROM t2 WHERE ( f12 ) IN ( @@ -283,8 +285,8 @@ FROM t1 AS alias1, t1 AS alias2 WHERE (alias2.f10 = alias1.f11) AND (alias1.f11 OR alias1.f3 = 50 AND alias1.f10)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where -2 MATERIALIZED alias1 ALL NULL NULL NULL NULL 2 Using where -2 MATERIALIZED alias2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY alias1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY alias2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) SELECT * FROM t2 WHERE ( f12 ) IN ( SELECT alias2.f3 @@ -294,6 +296,8 @@ f12 f13 Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'f' Warning 1292 Truncated incorrect DECIMAL value: 'd' +Warning 1292 Truncated incorrect DECIMAL value: 'f' +Warning 1292 Truncated incorrect DECIMAL value: 'd' set @@optimizer_switch=@save_optimizer_switch; drop table t1, t2; # @@ -316,7 +320,7 @@ explain select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -2 DEPENDENT SUBQUERY t2 ref key1,key2,key3 key3 5 const 1 Using where +2 DEPENDENT SUBQUERY t2 index_subquery key1,key2,key3 key1 10 func,const 1 Using where select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7; c1 set @@optimizer_switch='default'; @@ -363,8 +367,8 @@ WHERE t4.a >= t3.b AND a = SOME (SELECT b FROM t5)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t4 ALL PRIMARY NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t5 index c c 10 NULL 2 Using where; Using index; Start temporary; End temporary; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t5 index c c 10 NULL 2 Using where; Using index; Start temporary +2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t5.b 1 Using where; End temporary SELECT * FROM t3 WHERE t3.b > ALL ( diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index 87283487ef1..9076f05fc08 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -1433,6 +1433,9 @@ drop table if exists t1; (SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0); a 1 +# +# IN subselect optimization test +# create table t1 (a int not null, b int, primary key (a)); create table t2 (a int not null, primary key (a)); create table t3 (a int not null, b int, primary key (a)); @@ -1479,42 +1482,48 @@ insert into t1 values (1,10), (2,20), (3,30), (4,40); create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t1 -select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +select rand()*100000+200,rand(1)*100000 from t0 A, t0 B, t0 C, t0 D; insert into t2 values (2), (3), (4), (5); insert into t3 values (10,3), (20,4), (30,5); +explain extended select * from t2 where t2.a in (select a from t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using index; FirstMatch(t2) +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select a from t1); a 2 3 4 -explain extended select * from t2 where t2.a in (select a from t1); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) +1 PRIMARY t3 range a a 5 NULL 3 100.00 Using where; Using index +1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 0.29 Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); a 2 3 -explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +insert into t1 values (3,31); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index -1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` -insert into t1 values (3,31); +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 @@ -1524,12 +1533,6 @@ select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31 a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) -Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 drop table t0, t1, t2, t3; create table t1 (a int, b int); create table t2 (a int, b int); @@ -1591,6 +1594,9 @@ Note 1003 (select 'tttt' AS `s1` from dual) s1 tttt drop table t1; +# +# IN optimisation test results +# create table t1 (s1 char(5), index s1(s1)); create table t2 (s1 char(5), index s1(s1)); insert into t1 values ('a1'),('a2'),('a3'); @@ -1618,21 +1624,21 @@ a3 1 explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index @@ -2424,21 +2430,22 @@ a 1 3 DROP TABLE t1; +# +# SELECT(EXISTS * ...)optimisation +# create table t1 (a int, b int); insert into t1 values (1,2),(3,4),(5,6),(7,8); -select * from t1 up where exists (select * from t1 where t1.a=up.a); -a b -1 2 -3 4 -5 6 -7 8 -explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a); +insert into t1 select seq,seq from seq_20_to_40; +select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); +sum(a+b) +1296 +explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY up ALL NULL NULL NULL NULL 4 100.00 Using where -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 4 100.00 Using where +1 PRIMARY up ALL NULL NULL NULL NULL 25 100.00 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 25 100.00 Using where Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <`test`.`up`.`a`>(exists(/* select#2 */ select 1 from `test`.`t1` where `test`.`t1`.`a` = `test`.`up`.`a` limit 1)) +Note 1003 /* select#1 */ select sum(`test`.`up`.`a` + `test`.`up`.`b`) AS `sum(a+b)` from `test`.`t1` `up` where <`test`.`up`.`a`>(exists(/* select#2 */ select 1 from `test`.`t1` where `test`.`t1`.`a` = `test`.`up`.`a` limit 1)) drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -3106,6 +3113,10 @@ retailerID statusID changed 0048 1 2006-01-06 12:37:50 0059 1 2006-01-06 12:37:50 drop table t1; +# +# Bug#21180 Subselect with index for both WHERE and ORDER BY +# produces empty result +# create table t1(a int, primary key (a)); insert into t1 values (10); create table t2 (a int primary key, b varchar(32), c int, unique key cb(c, b)); @@ -3121,7 +3132,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using where SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10; @@ -3133,7 +3144,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using index condition; Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using index condition SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10; @@ -4233,8 +4244,8 @@ INSERT INTO t2 VALUES (7), (5), (1), (3); SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); id st -3 FL 1 GA +3 FL 7 FL SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) @@ -4335,6 +4346,9 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; 0 0 DROP TABLE t1, t2; +# +# Bug#28076 inconsistent binary/varbinary comparison +# CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5)); INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43); SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); @@ -4396,8 +4410,8 @@ CREATE INDEX I1 ON t1 (a); CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1) +1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4406,15 +4420,15 @@ CREATE INDEX I1 ON t2 (a); CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t2 ref I1 I1 4 test.t2.b 2 Using where; Using index; FirstMatch(t2) +1 PRIMARY t2 index I1 I1 4 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t2 ref I2 I2 13 test.t2.a 2 Using index condition SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1) +1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -5709,6 +5723,7 @@ CREATE TABLE t1 (a int) ; INSERT INTO t1 VALUES (NULL), (1), (NULL), (2); CREATE TABLE t2 (a int, INDEX idx(a)) ; INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000); +insert into t2 select seq from seq_3_to_500; SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a); a @@ -5718,7 +5733,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 502 Using where SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); a @@ -5728,7 +5743,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t2 ref idx idx 5 test.t1.a 2 Using index +2 DEPENDENT SUBQUERY t2 ref idx idx 5 test.t1.a 58 Using index DROP TABLE t1,t2; # # BUG#752992: Wrong results for a subquery with 'semijoin=on' @@ -5745,9 +5760,9 @@ SET @save_join_cache_level=@@join_cache_level; SET join_cache_level=0; EXPLAIN SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 3 -1 PRIMARY it eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 Using index -1 PRIMARY t2 index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(it) +1 PRIMARY it index PRIMARY PRIMARY 4 NULL 3 Using index +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.it.pk 1 +1 PRIMARY t2 index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1); pk i 11 0 diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index d7664b576b6..ad5ead75ccb 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -352,7 +352,7 @@ patient_uq clinic_uq explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t7 index PRIMARY PRIMARY 4 NULL 2 100.00 Using index -1 PRIMARY t6 ALL i1 NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t6 ref i1 i1 5 test.t7.uq 2 100.00 Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t7` join `test`.`t6` where `test`.`t6`.`clinic_uq` = `test`.`t7`.`uq` @@ -1436,6 +1436,9 @@ drop table if exists t1; (SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0); a 1 +# +# IN subselect optimization test +# create table t1 (a int not null, b int, primary key (a)); create table t2 (a int not null, primary key (a)); create table t3 (a int not null, b int, primary key (a)); @@ -1482,42 +1485,48 @@ insert into t1 values (1,10), (2,20), (3,30), (4,40); create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t1 -select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +select rand()*100000+200,rand(1)*100000 from t0 A, t0 B, t0 C, t0 D; insert into t2 values (2), (3), (4), (5); insert into t3 values (10,3), (20,4), (30,5); +explain extended select * from t2 where t2.a in (select a from t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using index; FirstMatch(t2) +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select a from t1); a 2 3 4 -explain extended select * from t2 where t2.a in (select a from t1); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) +1 PRIMARY t3 range a a 5 NULL 3 100.00 Using where; Using index +1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 0.29 Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); a 2 3 -explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +insert into t1 values (3,31); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index -1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` -insert into t1 values (3,31); +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 @@ -1527,12 +1536,6 @@ select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31 a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) -Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 drop table t0, t1, t2, t3; create table t1 (a int, b int); create table t2 (a int, b int); @@ -1594,6 +1597,9 @@ Note 1003 (select 'tttt' AS `s1` from dual) s1 tttt drop table t1; +# +# IN optimisation test results +# create table t1 (s1 char(5), index s1(s1)); create table t2 (s1 char(5), index s1(s1)); insert into t1 values ('a1'),('a2'),('a3'); @@ -1621,21 +1627,21 @@ a3 1 explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index @@ -2427,21 +2433,22 @@ a 1 3 DROP TABLE t1; +# +# SELECT(EXISTS * ...)optimisation +# create table t1 (a int, b int); insert into t1 values (1,2),(3,4),(5,6),(7,8); -select * from t1 up where exists (select * from t1 where t1.a=up.a); -a b -1 2 -3 4 -5 6 -7 8 -explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a); +insert into t1 select seq,seq from seq_20_to_40; +select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); +sum(a+b) +1296 +explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY up ALL NULL NULL NULL NULL 4 100.00 -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(up); Using join buffer (flat, BNL join) +1 PRIMARY up ALL NULL NULL NULL NULL 25 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 25 100.00 Using where; FirstMatch(up); Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`up`.`a` +Note 1003 select sum(`test`.`up`.`a` + `test`.`up`.`b`) AS `sum(a+b)` from `test`.`t1` `up` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`up`.`a` drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -2992,7 +2999,7 @@ Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 -1 PRIMARY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; FirstMatch(t1) +1 PRIMARY t2 ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary; End temporary Warnings: Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`flag` = 'N' and `test`.`t2`.`one` = `test`.`t1`.`one` and `test`.`t2`.`two` = `test`.`t1`.`two` explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; @@ -3108,6 +3115,10 @@ retailerID statusID changed 0048 1 2006-01-06 12:37:50 0059 1 2006-01-06 12:37:50 drop table t1; +# +# Bug#21180 Subselect with index for both WHERE and ORDER BY +# produces empty result +# create table t1(a int, primary key (a)); insert into t1 values (10); create table t2 (a int primary key, b varchar(32), c int, unique key cb(c, b)); @@ -3123,7 +3134,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using where SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10; @@ -3135,7 +3146,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using index condition; Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using index condition SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10; @@ -4335,6 +4346,9 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; 0 0 DROP TABLE t1, t2; +# +# Bug#28076 inconsistent binary/varbinary comparison +# CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5)); INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43); SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); @@ -4396,8 +4410,8 @@ CREATE INDEX I1 ON t1 (a); CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1) +1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4406,15 +4420,15 @@ CREATE INDEX I1 ON t2 (a); CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t2 ref I1 I1 4 test.t2.b 2 Using where; Using index; FirstMatch(t2) +1 PRIMARY t2 index I1 I1 4 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t2 ref I2 I2 13 test.t2.a 2 Using index condition SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1) +1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -5695,9 +5709,9 @@ WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a FROM it2,it3); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ot1 ALL NULL NULL NULL NULL 2 -1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using join buffer (flat, BNL join) -1 PRIMARY it2 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY it3 ALL NULL NULL NULL NULL 6 Using where; FirstMatch(ot4) +1 PRIMARY it2 ALL NULL NULL NULL NULL 4 Using where; Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY it3 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join) +1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using where; End temporary; Using join buffer (flat, BNL join) DROP TABLE IF EXISTS ot1, ot4, it2, it3; # # Bug#729039: NULL keys used to evaluate subquery @@ -5706,6 +5720,7 @@ CREATE TABLE t1 (a int) ; INSERT INTO t1 VALUES (NULL), (1), (NULL), (2); CREATE TABLE t2 (a int, INDEX idx(a)) ; INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000); +insert into t2 select seq from seq_3_to_500; SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a); a @@ -5715,7 +5730,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 502 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); a @@ -5725,7 +5740,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY t2 ref idx idx 5 test.t1.a 2 Using index; FirstMatch(t1) +1 PRIMARY t2 ref idx idx 5 test.t1.a 11 Using index; FirstMatch(t1) DROP TABLE t1,t2; # # BUG#752992: Wrong results for a subquery with 'semijoin=on' @@ -5742,9 +5757,9 @@ SET @save_join_cache_level=@@join_cache_level; SET join_cache_level=0; EXPLAIN SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 3 -1 PRIMARY it eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 Using index -1 PRIMARY t2 index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(it) +1 PRIMARY it index PRIMARY PRIMARY 4 NULL 3 Using index +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.it.pk 1 +1 PRIMARY t2 index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1); pk i 11 0 diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index 4e36ab903b3..1d51bd6b976 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -1432,6 +1432,9 @@ drop table if exists t1; (SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0); a 1 +# +# IN subselect optimization test +# create table t1 (a int not null, b int, primary key (a)); create table t2 (a int not null, primary key (a)); create table t3 (a int not null, b int, primary key (a)); @@ -1478,23 +1481,19 @@ insert into t1 values (1,10), (2,20), (3,30), (4,40); create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t1 -select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +select rand()*100000+200,rand(1)*100000 from t0 A, t0 B, t0 C, t0 D; insert into t2 values (2), (3), (4), (5); insert into t3 values (10,3), (20,4), (30,5); -select * from t2 where t2.a in (select a from t1); -a -2 -3 -4 explain extended select * from t2 where t2.a in (select a from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on a))) -select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +select * from t2 where t2.a in (select a from t1); a 2 +3 4 explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra @@ -1502,18 +1501,28 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on a where `test`.`t1`.`b` <> 30 and (`test`.`t2`.`a`) = `test`.`t1`.`a`))) -select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 -3 +4 explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index -2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 66.67 Using where; Using index; Using join buffer (flat, BNL join) Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`b` and (`test`.`t2`.`a`) = `test`.`t1`.`a`)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 insert into t1 values (3,31); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on a where `test`.`t1`.`b` <> 30 and (`test`.`t2`.`a`) = `test`.`t1`.`a`))) select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 @@ -1523,12 +1532,6 @@ select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31 a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where -Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on a where `test`.`t1`.`b` <> 30 and (`test`.`t2`.`a`) = `test`.`t1`.`a`))) drop table t0, t1, t2, t3; create table t1 (a int, b int); create table t2 (a int, b int); @@ -1590,6 +1593,9 @@ Note 1003 (select 'tttt' AS `s1` from dual) s1 tttt drop table t1; +# +# IN optimisation test results +# create table t1 (s1 char(5), index s1(s1)); create table t2 (s1 char(5), index s1(s1)); insert into t1 values ('a1'),('a2'),('a3'); @@ -1617,21 +1623,21 @@ a3 1 explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,(`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,(`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index @@ -2423,21 +2429,22 @@ a 1 3 DROP TABLE t1; +# +# SELECT(EXISTS * ...)optimisation +# create table t1 (a int, b int); insert into t1 values (1,2),(3,4),(5,6),(7,8); -select * from t1 up where exists (select * from t1 where t1.a=up.a); -a b -1 2 -3 4 -5 6 -7 8 -explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a); +insert into t1 select seq,seq from seq_20_to_40; +select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); +sum(a+b) +1296 +explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY up ALL NULL NULL NULL NULL 4 100.00 Using where -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 4 100.00 Using where +1 PRIMARY up ALL NULL NULL NULL NULL 25 100.00 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 25 100.00 Using where Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where (`test`.`up`.`a`,(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`up`.`a`) = `test`.`t1`.`a`)) +Note 1003 /* select#1 */ select sum(`test`.`up`.`a` + `test`.`up`.`b`) AS `sum(a+b)` from `test`.`t1` `up` where (`test`.`up`.`a`,(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`up`.`a`) = `test`.`t1`.`a`)) drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -3104,6 +3111,10 @@ retailerID statusID changed 0048 1 2006-01-06 12:37:50 0059 1 2006-01-06 12:37:50 drop table t1; +# +# Bug#21180 Subselect with index for both WHERE and ORDER BY +# produces empty result +# create table t1(a int, primary key (a)); insert into t1 values (10); create table t2 (a int primary key, b varchar(32), c int, unique key cb(c, b)); @@ -3119,7 +3130,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using where SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10; @@ -3131,7 +3142,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using index condition; Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using index condition SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10; @@ -4229,8 +4240,8 @@ INSERT INTO t2 VALUES (7), (5), (1), (3); SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); id st -3 FL 1 GA +3 FL 7 FL SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) @@ -4331,6 +4342,9 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; 0 0 DROP TABLE t1, t2; +# +# Bug#28076 inconsistent binary/varbinary comparison +# CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5)); INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43); SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); @@ -5702,6 +5716,7 @@ CREATE TABLE t1 (a int) ; INSERT INTO t1 VALUES (NULL), (1), (NULL), (2); CREATE TABLE t2 (a int, INDEX idx(a)) ; INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000); +insert into t2 select seq from seq_3_to_500; SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a); a @@ -5711,7 +5726,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 502 Using where SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); a @@ -5721,7 +5736,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t2 index_subquery idx idx 5 func 2 Using index +2 DEPENDENT SUBQUERY t2 index_subquery idx idx 5 func 58 Using index DROP TABLE t1,t2; # # BUG#752992: Wrong results for a subquery with 'semijoin=on' diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 8635f5352f1..18be05fe527 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -351,7 +351,7 @@ patient_uq clinic_uq explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t7 index PRIMARY PRIMARY 4 NULL 2 100.00 Using index -1 PRIMARY t6 ALL i1 NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t6 ref i1 i1 5 test.t7.uq 2 100.00 Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t7` join `test`.`t6` where `test`.`t6`.`clinic_uq` = `test`.`t7`.`uq` @@ -1435,6 +1435,9 @@ drop table if exists t1; (SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0); a 1 +# +# IN subselect optimization test +# create table t1 (a int not null, b int, primary key (a)); create table t2 (a int not null, primary key (a)); create table t3 (a int not null, b int, primary key (a)); @@ -1481,42 +1484,48 @@ insert into t1 values (1,10), (2,20), (3,30), (4,40); create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t1 -select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +select rand()*100000+200,rand(1)*100000 from t0 A, t0 B, t0 C, t0 D; insert into t2 values (2), (3), (4), (5); insert into t3 values (10,3), (20,4), (30,5); +explain extended select * from t2 where t2.a in (select a from t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using index; FirstMatch(t2) +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select a from t1); a 2 3 4 -explain extended select * from t2 where t2.a in (select a from t1); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) +1 PRIMARY t3 range a a 5 NULL 3 100.00 Using where; Using index +1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 0.29 Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); a 2 3 -explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +insert into t1 values (3,31); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index -1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a` -insert into t1 values (3,31); +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 @@ -1526,12 +1535,6 @@ select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31 a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index -1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) -Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30 drop table t0, t1, t2, t3; create table t1 (a int, b int); create table t2 (a int, b int); @@ -1593,6 +1596,9 @@ Note 1003 (select 'tttt' AS `s1` from dual) s1 tttt drop table t1; +# +# IN optimisation test results +# create table t1 (s1 char(5), index s1(s1)); create table t2 (s1 char(5), index s1(s1)); insert into t1 values ('a1'),('a2'),('a3'); @@ -1620,21 +1626,21 @@ a3 1 explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,(`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,(`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index @@ -2426,22 +2432,23 @@ a 1 3 DROP TABLE t1; +# +# SELECT(EXISTS * ...)optimisation +# create table t1 (a int, b int); insert into t1 values (1,2),(3,4),(5,6),(7,8); -select * from t1 up where exists (select * from t1 where t1.a=up.a); -a b -1 2 -3 4 -5 6 -7 8 -explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a); +insert into t1 select seq,seq from seq_20_to_40; +select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); +sum(a+b) +1296 +explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY up ALL NULL NULL NULL NULL 4 100.00 +1 PRIMARY up ALL NULL NULL NULL NULL 25 100.00 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 4 100.00 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 25 100.00 Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` semi join (`test`.`t1`) where 1 +Note 1003 select sum(`test`.`up`.`a` + `test`.`up`.`b`) AS `sum(a+b)` from `test`.`t1` `up` semi join (`test`.`t1`) where 1 drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -3109,6 +3116,10 @@ retailerID statusID changed 0048 1 2006-01-06 12:37:50 0059 1 2006-01-06 12:37:50 drop table t1; +# +# Bug#21180 Subselect with index for both WHERE and ORDER BY +# produces empty result +# create table t1(a int, primary key (a)); insert into t1 values (10); create table t2 (a int primary key, b varchar(32), c int, unique key cb(c, b)); @@ -3124,7 +3135,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using where SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10; @@ -3136,7 +3147,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using index condition; Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using index condition SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10; @@ -4236,8 +4247,8 @@ INSERT INTO t2 VALUES (7), (5), (1), (3); SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); id st -3 FL 1 GA +3 FL 7 FL SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) @@ -4338,6 +4349,9 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; 0 0 DROP TABLE t1, t2; +# +# Bug#28076 inconsistent binary/varbinary comparison +# CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5)); INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43); SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); @@ -4399,8 +4413,8 @@ CREATE INDEX I1 ON t1 (a); CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1) +1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4409,15 +4423,15 @@ CREATE INDEX I1 ON t2 (a); CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t2 ref I1 I1 4 test.t2.b 2 Using where; Using index; FirstMatch(t2) +1 PRIMARY t2 index I1 I1 4 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t2 ref I2 I2 13 test.t2.a 2 Using index condition SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where -1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1) +1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -4462,11 +4476,10 @@ EXPLAIN EXTENDED SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` semi join (`test`.`t2`) where 1 +Note 1003 select 2 AS `2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = `test`.`t1`.`a` EXPLAIN EXTENDED SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION (SELECT 1 FROM t2 WHERE t1.a = t2.a)); @@ -5713,6 +5726,7 @@ CREATE TABLE t1 (a int) ; INSERT INTO t1 VALUES (NULL), (1), (NULL), (2); CREATE TABLE t2 (a int, INDEX idx(a)) ; INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000); +insert into t2 select seq from seq_3_to_500; SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a); a @@ -5723,7 +5737,7 @@ WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 502 SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); a @@ -5733,7 +5747,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY t2 ref idx idx 5 test.t1.a 2 Using index; FirstMatch(t1) +1 PRIMARY t2 ref idx idx 5 test.t1.a 11 Using index; FirstMatch(t1) DROP TABLE t1,t2; # # BUG#752992: Wrong results for a subquery with 'semijoin=on' @@ -5750,9 +5764,9 @@ SET @save_join_cache_level=@@join_cache_level; SET join_cache_level=0; EXPLAIN SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 3 -1 PRIMARY it eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 Using index -1 PRIMARY t2 index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(it) +1 PRIMARY it index PRIMARY PRIMARY 4 NULL 3 Using index +1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.it.pk 1 +1 PRIMARY t2 index NULL PRIMARY 4 NULL 3 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1); pk i 11 0 diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index cca7f431d0e..07eb361b91c 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -914,9 +914,9 @@ a t1.a in (select t2.a from t2) explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index -2 MATERIALIZED t2 index a a 5 NULL 3 100.00 Using index +2 SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`a`)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<`test`.`t1`.`a`>((`test`.`t1`.`a`,(((`test`.`t1`.`a`) in t2 on a checking NULL having `test`.`t2`.`a` is null)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` CREATE TABLE t3 (a int(11) default '0'); INSERT INTO t3 VALUES (1),(2),(3); SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; @@ -928,8 +928,8 @@ a t1.a in (select t2.a from t2,t3 where t3.a=t2.a) explain extended SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index -2 MATERIALIZED t3 ALL NULL NULL NULL NULL 3 100.00 -2 MATERIALIZED t2 index a a 5 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join) +2 MATERIALIZED t3 ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED t2 ref a a 5 test.t3.a 2 100.00 Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t3`.`a` ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` drop table t1,t2,t3; @@ -1432,6 +1432,9 @@ drop table if exists t1; (SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0); a 1 +# +# IN subselect optimization test +# create table t1 (a int not null, b int, primary key (a)); create table t2 (a int not null, primary key (a)); create table t3 (a int not null, b int, primary key (a)); @@ -1456,9 +1459,9 @@ a explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index -2 MATERIALIZED t1 ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <`test`.`t2`.`a`>((`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`b` <> 30 ), (`test`.`t2`.`a` in on distinct_key where `test`.`t2`.`a` = ``.`a`)))) +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <`test`.`t2`.`a`>((`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY where `test`.`t1`.`b` <> 30 and (`test`.`t2`.`a`) = `test`.`t1`.`a`)))) select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); a 2 @@ -1466,10 +1469,10 @@ a explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index -2 MATERIALIZED t1 ALL PRIMARY NULL NULL NULL 4 100.00 Using where -2 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <`test`.`t2`.`a`>((`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`b` ), (`test`.`t2`.`a` in on distinct_key where `test`.`t2`.`a` = ``.`a`)))) +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <`test`.`t2`.`a`>((`test`.`t2`.`a`,(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`b` and (`test`.`t2`.`a`) = `test`.`t1`.`a`))) drop table t1, t2, t3; create table t1 (a int, b int, index a (a,b)); create table t2 (a int, index a (a)); @@ -1478,23 +1481,19 @@ insert into t1 values (1,10), (2,20), (3,30), (4,40); create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t1 -select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +select rand()*100000+200,rand(1)*100000 from t0 A, t0 B, t0 C, t0 D; insert into t2 values (2), (3), (4), (5); insert into t3 values (10,3), (20,4), (30,5); -select * from t2 where t2.a in (select a from t1); -a -2 -3 -4 explain extended select * from t2 where t2.a in (select a from t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <`test`.`t2`.`a`>((`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on a)))) -select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +select * from t2 where t2.a in (select a from t1); a 2 +3 4 explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra @@ -1502,18 +1501,28 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <`test`.`t2`.`a`>((`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on a where `test`.`t1`.`b` <> 30 and (`test`.`t2`.`a`) = `test`.`t1`.`a`)))) -select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 -3 +4 explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index -2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 66.67 Using where; Using index; Using join buffer (flat, BNL join) Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <`test`.`t2`.`a`>((`test`.`t2`.`a`,(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`b` and (`test`.`t2`.`a`) = `test`.`t1`.`a`))) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 insert into t1 values (3,31); +explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <`test`.`t2`.`a`>((`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on a where `test`.`t1`.`b` <> 30 and (`test`.`t2`.`a`) = `test`.`t1`.`a`)))) select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 @@ -1523,12 +1532,6 @@ select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31 a 2 4 -explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where -Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <`test`.`t2`.`a`>((`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on a where `test`.`t1`.`b` <> 30 and (`test`.`t2`.`a`) = `test`.`t1`.`a`)))) drop table t0, t1, t2, t3; create table t1 (a int, b int); create table t2 (a int, b int); @@ -1590,6 +1593,9 @@ Note 1003 (select 'tttt' AS `s1` from dual) s1 tttt drop table t1; +# +# IN optimisation test results +# create table t1 (s1 char(5), index s1(s1)); create table t2 (s1 char(5), index s1(s1)); insert into t1 values ('a1'),('a2'),('a3'); @@ -1617,27 +1623,27 @@ a3 1 explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond((`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index -2 MATERIALIZED t2 range s1 s1 6 NULL 1 100.00 Using where; Using index +2 SUBQUERY t2 index_subquery s1 s1 6 func 2 50.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,`test`.`t1`.`s1` in ( (/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where `test`.`t2`.`s1` < 'a2' ), (`test`.`t1`.`s1` in on distinct_key where `test`.`t1`.`s1` = ``.`s1`)))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<`test`.`t1`.`s1`>((`test`.`t1`.`s1`,(((`test`.`t1`.`s1`) in t2 on s1 checking NULL where `test`.`t2`.`s1` < 'a2' having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; create table t2 (a int, b int not null); create table t3 (a int); @@ -1890,9 +1896,9 @@ id text explain extended select * from t1 where id not in (select id from t1 where id < 8); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where -2 MATERIALIZED t1 range PRIMARY PRIMARY 4 NULL 7 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where !<`test`.`t1`.`id`>((`test`.`t1`.`id`,`test`.`t1`.`id` in ( (/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 ), (`test`.`t1`.`id` in on distinct_key where `test`.`t1`.`id` = ``.`id`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where !<`test`.`t1`.`id`>((`test`.`t1`.`id`,(((`test`.`t1`.`id`) in t1 on PRIMARY where `test`.`t1`.`id` < 8 and (`test`.`t1`.`id`) = `test`.`t1`.`id`)))) explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where @@ -2423,21 +2429,22 @@ a 1 3 DROP TABLE t1; +# +# SELECT(EXISTS * ...)optimisation +# create table t1 (a int, b int); insert into t1 values (1,2),(3,4),(5,6),(7,8); -select * from t1 up where exists (select * from t1 where t1.a=up.a); -a b -1 2 -3 4 -5 6 -7 8 -explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a); +insert into t1 select seq,seq from seq_20_to_40; +select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); +sum(a+b) +1296 +explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY up ALL NULL NULL NULL NULL 4 100.00 Using where -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 4 100.00 +1 PRIMARY up ALL NULL NULL NULL NULL 25 100.00 Using where +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 25 100.00 Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <`test`.`up`.`a`>((`test`.`up`.`a`,`test`.`up`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where 1 ), (`test`.`up`.`a` in on distinct_key where `test`.`up`.`a` = ``.`a`)))) +Note 1003 /* select#1 */ select sum(`test`.`up`.`a` + `test`.`up`.`b`) AS `sum(a+b)` from `test`.`t1` `up` where <`test`.`up`.`a`>((`test`.`up`.`a`,`test`.`up`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where 1 ), (`test`.`up`.`a` in on distinct_key where `test`.`up`.`a` = ``.`a`)))) drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -3104,6 +3111,10 @@ retailerID statusID changed 0048 1 2006-01-06 12:37:50 0059 1 2006-01-06 12:37:50 drop table t1; +# +# Bug#21180 Subselect with index for both WHERE and ORDER BY +# produces empty result +# create table t1(a int, primary key (a)); insert into t1 values (10); create table t2 (a int primary key, b varchar(32), c int, unique key cb(c, b)); @@ -3119,7 +3130,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using where SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10; @@ -3131,7 +3142,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY r const PRIMARY PRIMARY 4 const 1 -2 SUBQUERY t2 ref cb cb 5 const 1 Using index condition; Using where +2 SUBQUERY t2 range cb cb 40 NULL 3 Using index condition SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899' ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10; @@ -4229,8 +4240,8 @@ INSERT INTO t2 VALUES (7), (5), (1), (3); SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); id st -3 FL 1 GA +3 FL 7 FL SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) @@ -4331,6 +4342,9 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; 0 0 DROP TABLE t1, t2; +# +# Bug#28076 inconsistent binary/varbinary comparison +# CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5)); INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43); SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); @@ -4623,7 +4637,7 @@ WHERE outr.int_key NOT IN (SELECT t1.pk FROM t1, t2) ORDER BY outr.pk; id select_type table type possible_keys key key_len ref rows Extra x x outr ALL x x x x x x -x x t1 index x x x x x x +x x t1 eq_ref x x x x x x x x t2 index x x x x x x # should not crash on debug binaries SELECT * FROM t2 outr @@ -5702,6 +5716,7 @@ CREATE TABLE t1 (a int) ; INSERT INTO t1 VALUES (NULL), (1), (NULL), (2); CREATE TABLE t2 (a int, INDEX idx(a)) ; INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000); +insert into t2 select seq from seq_3_to_500; SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a); a @@ -5711,7 +5726,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 502 SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); a @@ -5721,7 +5736,7 @@ SELECT * FROM t1 WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t2 index_subquery idx idx 5 func 2 Using index +2 DEPENDENT SUBQUERY t2 index_subquery idx idx 5 func 58 Using index DROP TABLE t1,t2; # # BUG#752992: Wrong results for a subquery with 'semijoin=on' diff --git a/mysql-test/main/subselect_partial_match.result b/mysql-test/main/subselect_partial_match.result index 3d10e912f22..16a487445e4 100644 --- a/mysql-test/main/subselect_partial_match.result +++ b/mysql-test/main/subselect_partial_match.result @@ -763,6 +763,7 @@ CREATE TABLE t1 (a1 int DEFAULT NULL, a2 int DEFAULT NULL); INSERT INTO t1 VALUES (NULL,2), (4,NULL),(100,100); CREATE TABLE t2 (b1 int DEFAULT NULL, b2 int DEFAULT NULL); INSERT INTO t2 VALUES (6,NULL), (NULL,0),(1000,1000); +insert into t2 select seq,seq from seq_2000_to_2100; set @@optimizer_switch='materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on'; set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='derived_merge=off,derived_with_keys=off'; @@ -771,7 +772,7 @@ SELECT * FROM (SELECT * FROM t1 WHERE a1 NOT IN (SELECT b2 FROM t2)) table1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY ALL NULL NULL NULL NULL 3 100.00 2 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where -3 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00 +3 MATERIALIZED t2 ALL NULL NULL NULL NULL 104 100.00 Warnings: Note 1003 /* select#1 */ select `table1`.`a1` AS `a1`,`table1`.`a2` AS `a2` from (/* select#2 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where !((`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( (/* select#3 */ select `test`.`t2`.`b2` from `test`.`t2` ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`b2`))))) `table1` set optimizer_switch=@tmp_optimizer_switch; @@ -780,12 +781,13 @@ DROP TABLE t1, t2; # LP BUG#613009 Crash in Ordered_key::get_field_idx # set @@optimizer_switch='materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=off'; -create table t1 (a1 char(3) DEFAULT NULL, a2 char(3) DEFAULT NULL); +create table t1 (a1 char(4) DEFAULT NULL, a2 char(4) DEFAULT NULL); insert into t1 values (NULL, 'a21'), (NULL, 'a22'), ('xxx','xxx'); +insert into t1 select seq,seq from seq_2000_to_2100; explain select * from t1 where (a1, a2) not in (select a1, a2 from t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 +1 PRIMARY t1 ALL NULL NULL NULL NULL 104 Using where +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 104 select * from t1 where (a1, a2) not in (select a1, a2 from t1); a1 a2 drop table t1; diff --git a/mysql-test/main/subselect_partial_match.test b/mysql-test/main/subselect_partial_match.test index 8fdd5e451ba..9a32ef5491c 100644 --- a/mysql-test/main/subselect_partial_match.test +++ b/mysql-test/main/subselect_partial_match.test @@ -2,6 +2,7 @@ # Tests for # MWL#68: Subquery optimization: Efficient NOT IN execution with NULLs # +--source include/have_sequence.inc set @save_optimizer_switch=@@optimizer_switch; @@ -618,6 +619,8 @@ INSERT INTO t1 VALUES (NULL,2), (4,NULL),(100,100); CREATE TABLE t2 (b1 int DEFAULT NULL, b2 int DEFAULT NULL); INSERT INTO t2 VALUES (6,NULL), (NULL,0),(1000,1000); +insert into t2 select seq,seq from seq_2000_to_2100; + set @@optimizer_switch='materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on'; set @tmp_optimizer_switch=@@optimizer_switch; @@ -634,8 +637,9 @@ DROP TABLE t1, t2; set @@optimizer_switch='materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=off'; -create table t1 (a1 char(3) DEFAULT NULL, a2 char(3) DEFAULT NULL); +create table t1 (a1 char(4) DEFAULT NULL, a2 char(4) DEFAULT NULL); insert into t1 values (NULL, 'a21'), (NULL, 'a22'), ('xxx','xxx'); +insert into t1 select seq,seq from seq_2000_to_2100; explain select * from t1 where (a1, a2) not in (select a1, a2 from t1); select * from t1 where (a1, a2) not in (select a1, a2 from t1); drop table t1; diff --git a/mysql-test/main/subselect_sj.result b/mysql-test/main/subselect_sj.result index 55fb1bfe367..a6905d5d819 100644 --- a/mysql-test/main/subselect_sj.result +++ b/mysql-test/main/subselect_sj.result @@ -76,19 +76,19 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where `test`.`t12`.`pk` = `test`.`t10`.`a` and `test`.`t10`.`pk` = `test`.`t1`.`a` subqueries within outer joins go into ON expr. -explAin extended +explain extended select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A And B.A in (select pk from t10)); -id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA +id select_type table type possible_keys key key_len ref rows filtered ExtrA 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY A ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY B ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t10 index PRIMARY PRIMARY 4 NULL 10 100.00 Using index +2 DEPENDENT SUBQUERY t10 unique_suBquery PRIMARY PRIMARY 4 func 1 100.00 Using index Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t2` `A` join `test`.`t2` `B`) on(`test`.`A`.`A` = `test`.`t1`.`A` And (`test`.`B`.`A`,`test`.`B`.`A` in ( (/* select#2 */ select `test`.`t10`.`pk` from `test`.`t10` ), (`test`.`B`.`A` in on distinct_key where `test`.`B`.`A` = ``.`pk`)))) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t2` `A` join `test`.`t2` `B`) on(`test`.`A`.`A` = `test`.`t1`.`A` And (`test`.`B`.`A`,(((`test`.`B`.`A`) in t10 on PRIMARY)))) where 1 t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" -explAin extended +explain extended select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10)); -id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA +id select_type table type possible_keys key key_len ref rows filtered ExtrA 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t10 unique_suBquery PRIMARY PRIMARY 4 func 1 100.00 Using index @@ -344,8 +344,8 @@ WHERE PNUM IN (SELECT PNUM FROM PROJ)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY STAFF ALL NULL NULL NULL NULL 5 -1 PRIMARY PROJ ALL NULL NULL NULL NULL 6 -1 PRIMARY WORKS ALL NULL NULL NULL NULL 12 Using where; FirstMatch(STAFF) +1 PRIMARY PROJ ALL NULL NULL NULL NULL 6 Start temporary +1 PRIMARY WORKS ALL NULL NULL NULL NULL 12 Using where; End temporary SELECT EMPNUM, EMPNAME FROM STAFF WHERE EMPNUM IN @@ -502,7 +502,7 @@ EXPLAIN EXTENDED SELECT vkey FROM t0 WHERE pk IN id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t0 ALL PRIMARY NULL NULL NULL 5 100.00 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where -1 PRIMARY t2 ref vkey vkey 4 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 ref vkey vkey 4 test.t1.vnokey 2 50.00 Using index; FirstMatch(t1) Warnings: Note 1003 select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` semi join (`test`.`t0` `t2`) join `test`.`t0` where `test`.`t1`.`pk` = `test`.`t0`.`pk` and `test`.`t2`.`vkey` = `test`.`t1`.`vnokey` SELECT vkey FROM t0 WHERE pk IN @@ -763,16 +763,16 @@ explain extended select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 -1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where; FirstMatch(t1) +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 16.67 Using where; End temporary; Using join buffer (flat, BNL join) 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`c` = `test`.`t1`.`a` and (<`test`.`t2`.`d`,`test`.`t1`.`b`>((`test`.`t2`.`d`,(/* select#3 */ select `test`.`t3`.`e` from `test`.`t3` where `test`.`t1`.`b` = `test`.`t3`.`e` and (`test`.`t2`.`d`) >= `test`.`t3`.`e`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t2`.`c` and (<`test`.`t2`.`d`,`test`.`t1`.`b`>((`test`.`t2`.`d`,(/* select#3 */ select `test`.`t3`.`e` from `test`.`t3` where `test`.`t1`.`b` = `test`.`t3`.`e` and (`test`.`t2`.`d`) >= `test`.`t3`.`e`)))) show warnings; Level Code Message Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`c` = `test`.`t1`.`a` and (<`test`.`t2`.`d`,`test`.`t1`.`b`>((`test`.`t2`.`d`,(/* select#3 */ select `test`.`t3`.`e` from `test`.`t3` where `test`.`t1`.`b` = `test`.`t3`.`e` and (`test`.`t2`.`d`) >= `test`.`t3`.`e`)))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t2`.`c` and (<`test`.`t2`.`d`,`test`.`t1`.`b`>((`test`.`t2`.`d`,(/* select#3 */ select `test`.`t3`.`e` from `test`.`t3` where `test`.`t1`.`b` = `test`.`t3`.`e` and (`test`.`t2`.`d`) >= `test`.`t3`.`e`)))) select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); a @@ -806,10 +806,9 @@ insert into t2 (pk) values (-1),(0); EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 11 func,func 1 100.00 -2 MATERIALIZED t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Rowid-ordered scan +1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Rowid-ordered scan; FirstMatch(t1) Warnings: -Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`pk` > 0 +Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t2`.`pk` > 0 SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); pk 2 @@ -1999,7 +1998,7 @@ explain extended SELECT * FROM t1 NATURAL LEFT JOIN (t2, t3) WHERE t2.f3 IN (SELECT * FROM t4 where f2 = 0 or f2 IS NULL); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY t4 ref_or_null f2 f2 5 const 4 100.00 Using where; Using index; FirstMatch(t2) +1 PRIMARY t4 ref_or_null f2 f2 5 const 4 25.00 Using where; Using index; FirstMatch(t2) 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t3 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) Warnings: @@ -2155,8 +2154,8 @@ explain SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY t3 ref b b 5 test.t1.b 2 Start temporary -1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t3 ref b b 5 test.t1.b 2 Using where; Start temporary +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 Using index; End temporary SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); b a 5 6 @@ -2179,10 +2178,10 @@ INSERT INTO t5 VALUES (7,0),(9,0); explain SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; Start temporary 1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where -1 PRIMARY t4 ALL NULL NULL NULL NULL 3 FirstMatch(t5) -1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 +1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; End temporary; Using join buffer (flat, BNL join) SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); a 0 @@ -2261,10 +2260,10 @@ alias1.c IN (SELECT SQ3_alias1.b FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2) LIMIT 100; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 20 -1 PRIMARY alias2 ALL NULL NULL NULL NULL 20 Using join buffer (flat, BNL join) +1 PRIMARY alias2 ALL NULL NULL NULL NULL 20 1 PRIMARY t2 ALL NULL NULL NULL NULL 20 Using join buffer (flat, BNL join) -1 PRIMARY SQ3_alias1 ALL NULL NULL NULL NULL 20 Using where; Start temporary +1 PRIMARY SQ3_alias1 ALL NULL NULL NULL NULL 20 Start temporary +1 PRIMARY ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join) 1 PRIMARY SQ3_alias2 index NULL PRIMARY 4 NULL 20 Using index; End temporary 2 DERIVED t2 ALL NULL NULL NULL NULL 20 create table t3 as @@ -2437,9 +2436,9 @@ SET SESSION optimizer_switch='loosescan=off'; EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 index idx idx 9 NULL 2 Using where; Using index; Start temporary -1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 +1 PRIMARY t2 range idx idx 4 NULL 2 Using where; Using index +1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); a 5 @@ -2447,9 +2446,9 @@ SET SESSION optimizer_switch='loosescan=on'; EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 index idx idx 9 NULL 2 Using where; Using index; Start temporary -1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 +1 PRIMARY t2 range idx idx 4 NULL 2 Using where; Using index +1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); a 5 @@ -2576,7 +2575,7 @@ WHERE ( b, d ) IN id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index b b 5 NULL 10 Using where; Using index; Start temporary 1 PRIMARY t2 ref c c 5 test.t1.b 1 -1 PRIMARY t1 ref b b 5 test.t1.b 2 +1 PRIMARY t1 ALL b NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 Using where; End temporary; Using join buffer (flat, BNL join) SELECT a, b, d FROM t1, t2 WHERE ( b, d ) IN @@ -2768,8 +2767,8 @@ SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where -1 PRIMARY ref key0 key0 5 test.t1_1.a 2 Start temporary -1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary +1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 +1 PRIMARY ref key0 key0 5 test.t1_1.a 2 Using where; FirstMatch(t1_2) 3 DERIVED t1 ALL NULL NULL NULL NULL 11 SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); @@ -3037,7 +3036,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort 1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 5 100.00 Start temporary 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 -1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 10.00 Using where; End temporary Warnings: Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1`,'x' AS `c2` from `test`.`t1` semi join (`test`.`t1` left join `test`.`t3` on(`test`.`t1`.`c1` = `test`.`t3`.`c3`)) where `test`.`t1`.`pk` = `test`.`t1`.`pk` order by 'x',`test`.`t1`.`c1` DROP TABLE t1,t2,t3; @@ -3289,7 +3288,7 @@ explain extended SELECT Id FROM t1 WHERE Id in (SELECT t1_Id FROM t2 WHERE t2.col1 IS NULL); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 100.00 -1 PRIMARY t2 ALL col1 NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +1 PRIMARY t2 ref col1 col1 5 const 2 50.00 Using index condition; Using where; FirstMatch(t1) Warnings: Note 1003 select 1 AS `Id` from (`test`.`t2`) where `test`.`t2`.`t1_Id` = 1 and `test`.`t2`.`col1` is null DROP TABLE t1, t2; diff --git a/mysql-test/main/subselect_sj.test b/mysql-test/main/subselect_sj.test index 4d35b4f0839..ed2d7c99ec2 100644 --- a/mysql-test/main/subselect_sj.test +++ b/mysql-test/main/subselect_sj.test @@ -70,13 +70,13 @@ explain extended select * from t1 where a in (select t10.pk from t10, t12 where --echo subqueries within outer joins go into ON expr. # TODO: psergey: check if case conversions like those are ok (it broke on windows) ---replace_result a A b B +--replace_result a A b B explain explain table table possible possible explain extended select * from t1 left join (t2 A, t2 B) on ( A.a= t1.a and B.a in (select pk from t10)); # TODO: psergey: check if case conversions like those are ok (it broke on windows) --echo t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" ---replace_result a A b B +--replace_result a A b B explain explain table table possible possible explain extended select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)); diff --git a/mysql-test/main/subselect_sj2.result b/mysql-test/main/subselect_sj2.result index 728014d0202..0a8a680adc0 100644 --- a/mysql-test/main/subselect_sj2.result +++ b/mysql-test/main/subselect_sj2.result @@ -25,11 +25,7 @@ key(b) ); insert into t2 select a, a/2 from t0; insert into t2 select a+10, a+10/2 from t0; -select * from t1; -a b -1 1 -1 1 -2 2 +insert into t1 values (1030,30),(1031,31),(1032,32),(1033,33); select * from t2; a b 0 0 @@ -54,9 +50,9 @@ a b 19 14 explain select * from t2 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 -1 PRIMARY t2 ref b b 5 test.t1.a 2 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t2 ALL b NULL NULL NULL 20 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 7 select * from t2 where b in (select a from t1); a b 1 1 @@ -82,9 +78,9 @@ test.t3 analyze status Engine-independent statistics collected test.t3 analyze status OK explain select * from t3 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 -1 PRIMARY t3 ref b b 5 test.t1.a 2 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t3 ALL b NULL NULL NULL 20 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 7 select * from t3 where b in (select a from t1); a b pk1 pk2 pk3 1 1 1 1 1 @@ -112,9 +108,8 @@ test.t3 analyze status Engine-independent statistics collected test.t3 analyze status OK explain select * from t3 where b in (select a from t0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL # -1 PRIMARY t3 ref b b 5 test.t0.a # -2 MATERIALIZED t0 ALL NULL NULL NULL NULL # Using where +1 PRIMARY t0 ALL NULL NULL NULL NULL # Using where; Start temporary +1 PRIMARY t3 ref b b 5 test.t0.a # End temporary select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); a b pk1 pk2 0 0 0 0 @@ -135,19 +130,17 @@ set join_buffer_size= @save_join_buffer_size; set max_heap_table_size= @save_max_heap_table_size; explain select * from t1 where a in (select b from t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where 1 PRIMARY t2 ref b b 5 test.t1.a 1 Using index; FirstMatch(t1) -select * from t1; -a b -1 1 -1 1 -2 2 select * from t1 where a in (select b from t2); a b 1 1 1 1 2 2 drop table t1, t2, t3; +# +# Test join buffering +# set @save_join_buffer_size = @@join_buffer_size; set join_buffer_size= 8192; create table t1 (a int, filler1 binary(200), filler2 binary(200)); @@ -307,7 +300,7 @@ from t0 where a in id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 1 PRIMARY eq_ref distinct_key distinct_key 8 func 1 Using where -2 MATERIALIZED t1 index a a 5 NULL 10 Using where; Using index +2 MATERIALIZED t1 range a a 5 NULL 10 Using where; Using index 2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index 2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index drop table t0, t1,t2,t3; @@ -348,7 +341,7 @@ WHERE Language='English' AND Percentage > 10 AND t2.Population > 100000); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary -1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary +1 PRIMARY t2 eq_ref|filter PRIMARY,Population PRIMARY|Population 3|4 test.t1.Country 1 (75%) Using where; End temporary; Using rowid filter 1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where set optimizer_switch=@bug35674_save_optimizer_switch; DROP TABLE t1,t2,t3; @@ -840,9 +833,9 @@ explain SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY alias1 const PRIMARY PRIMARY 4 const # Using index +1 PRIMARY alias1 const PRIMARY PRIMARY 4 const # 1 PRIMARY alias2 index f12 f12 7 NULL # Using index; LooseScan -1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index; FirstMatch(alias2) +1 PRIMARY t1 ALL NULL NULL NULL NULL # FirstMatch(alias2) 1 PRIMARY t3 ALL NULL NULL NULL NULL # Using where; Using join buffer (flat, BNL join) SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); @@ -1235,10 +1228,10 @@ t1_pk1 t1_pk2 t3_i t3_c explain SELECT * FROM t1, t3 WHERE t3_c IN ( SELECT t1_pk2 FROM t4, t2 WHERE t2_c = t1_pk2 AND t2_i >= t3_i ) AND ( t1_pk1 = 'POL' ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ref PRIMARY PRIMARY 5 const 1 Using where; Using index +1 PRIMARY t1 ref PRIMARY PRIMARY 5 const 1 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where -1 PRIMARY t4 index NULL PRIMARY 59 NULL 2 Using where; Using index; FirstMatch(t3) +1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t3) DROP TABLE t1,t2,t3,t4; # # MDEV-6263: Wrong result when using IN subquery with order by @@ -1356,9 +1349,9 @@ WHERE T3_0_.t3idref= 1 ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY T3_0_ ref PRIMARY,FK_T3_T2Id PRIMARY 8 const 3 Using index; Start temporary +1 PRIMARY T3_0_ ref PRIMARY,FK_T3_T2Id PRIMARY 8 const 3 Start temporary 1 PRIMARY T2_1_ eq_ref PRIMARY,FK_T2_T1Id PRIMARY 8 test.T3_0_.t2idref 1 -1 PRIMARY T1_1_ eq_ref PRIMARY PRIMARY 8 test.T2_1_.t1idref 1 Using index +1 PRIMARY T1_1_ eq_ref PRIMARY PRIMARY 8 test.T2_1_.t1idref 1 1 PRIMARY T2_0_ ref FK_T2_T1Id FK_T2_T1Id 8 test.T2_1_.t1idref 1 Using index; End temporary drop table t3,t2,t1; set optimizer_search_depth=@tmp7474; diff --git a/mysql-test/main/subselect_sj2.test b/mysql-test/main/subselect_sj2.test index 7601dc3a730..4ccdcc50a38 100644 --- a/mysql-test/main/subselect_sj2.test +++ b/mysql-test/main/subselect_sj2.test @@ -2,13 +2,15 @@ # DuplicateElimination strategy test # +--source include/have_innodb.inc +--source include/have_sequence.inc + set @innodb_stats_persistent_save= @@innodb_stats_persistent; set @innodb_stats_persistent_sample_pages_save= @@innodb_stats_persistent_sample_pages; set global innodb_stats_persistent= 1; set global innodb_stats_persistent_sample_pages=100; ---source include/have_innodb.inc set @subselect_sj2_tmp= @@optimizer_switch; set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; @@ -48,7 +50,7 @@ create table t2 ( insert into t2 select a, a/2 from t0; insert into t2 select a+10, a+10/2 from t0; -select * from t1; +insert into t1 values (1030,30),(1031,31),(1032,32),(1033,33); select * from t2; explain select * from t2 where b in (select a from t1); select * from t2 where b in (select a from t1); @@ -97,15 +99,15 @@ set max_heap_table_size= @save_max_heap_table_size; # O2I join orders, with shortcutting: explain select * from t1 where a in (select b from t2); -select * from t1; select * from t1 where a in (select b from t2); drop table t1, t2, t3; # (no need for anything in range/index_merge/DS-MRR) -# -# Test join buffering -# +--echo # +--echo # Test join buffering +--echo # + set @save_join_buffer_size = @@join_buffer_size; set join_buffer_size= 8192; @@ -256,6 +258,7 @@ INSERT INTO t3 VALUES # Disable materialization to avoid races between query plans set @bug35674_save_optimizer_switch=@@optimizer_switch; set optimizer_switch='materialization=off'; + EXPLAIN SELECT Name FROM t2 WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) diff --git a/mysql-test/main/subselect_sj2_jcl6.result b/mysql-test/main/subselect_sj2_jcl6.result index 94eebd167f1..c3e3a77c679 100644 --- a/mysql-test/main/subselect_sj2_jcl6.result +++ b/mysql-test/main/subselect_sj2_jcl6.result @@ -36,11 +36,7 @@ key(b) ); insert into t2 select a, a/2 from t0; insert into t2 select a+10, a+10/2 from t0; -select * from t1; -a b -1 1 -1 1 -2 2 +insert into t1 values (1030,30),(1031,31),(1032,32),(1033,33); select * from t2; a b 0 0 @@ -66,7 +62,7 @@ a b explain select * from t2 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL b NULL NULL NULL 20 -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; FirstMatch(t2); Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where; FirstMatch(t2); Using join buffer (flat, BNL join) select * from t2 where b in (select a from t1); a b 1 1 @@ -92,9 +88,8 @@ test.t3 analyze status Engine-independent statistics collected test.t3 analyze status OK explain select * from t3 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 -1 PRIMARY t3 ref b b 5 test.t1.a 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t3 ALL b NULL NULL NULL 20 +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where; FirstMatch(t3); Using join buffer (flat, BNL join) select * from t3 where b in (select a from t1); a b pk1 pk2 pk3 1 1 1 1 1 @@ -122,9 +117,8 @@ test.t3 analyze status Engine-independent statistics collected test.t3 analyze status OK explain select * from t3 where b in (select a from t0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL # -1 PRIMARY t3 ref b b 5 test.t0.a # Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -2 MATERIALIZED t0 ALL NULL NULL NULL NULL # Using where +1 PRIMARY t0 ALL NULL NULL NULL NULL # Using where; Start temporary +1 PRIMARY t3 ref b b 5 test.t0.a # End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); a b pk1 pk2 0 0 0 0 @@ -145,19 +139,17 @@ set join_buffer_size= @save_join_buffer_size; set max_heap_table_size= @save_max_heap_table_size; explain select * from t1 where a in (select b from t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where 1 PRIMARY t2 ref b b 5 test.t1.a 1 Using index; FirstMatch(t1) -select * from t1; -a b -1 1 -1 1 -2 2 select * from t1 where a in (select b from t2); a b 1 1 1 1 2 2 drop table t1, t2, t3; +# +# Test join buffering +# set @save_join_buffer_size = @@join_buffer_size; set join_buffer_size= 8192; create table t1 (a int, filler1 binary(200), filler2 binary(200)); @@ -174,8 +166,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z from t1 ot where a in (select a from t2 it); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ot ALL NULL NULL NULL NULL 32 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED it ALL NULL NULL NULL NULL 22 +1 PRIMARY it ALL NULL NULL NULL NULL 22 Using where; FirstMatch(ot); Using join buffer (flat, BNL join) select a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z from t1 ot where a in (select a from t2 it); @@ -199,16 +190,15 @@ a mid(filler1, 1,10) Z 16 filler1234 1 17 filler1234 1 18 filler1234 1 -19 filler1234 1 2 duplicate 1 18 duplicate 1 +19 filler1234 1 explain select a, mid(filler1, 1,10), length(filler1)=length(filler2) from t2 ot where a in (select a from t1 it); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ot ALL NULL NULL NULL NULL 22 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED it ALL NULL NULL NULL NULL 32 +1 PRIMARY it ALL NULL NULL NULL NULL 32 Using where; FirstMatch(ot); Using join buffer (flat, BNL join) select a, mid(filler1, 1,10), length(filler1)=length(filler2) from t2 ot where a in (select a from t1 it); @@ -232,8 +222,8 @@ a mid(filler1, 1,10) length(filler1)=length(filler2) 16 filler1234 1 17 filler1234 1 18 filler1234 1 -19 filler1234 1 3 duplicate 1 +19 filler1234 1 19 duplicate 1 insert into t1 select a+20, 'filler123456', 'filler123456' from t0; insert into t1 select a+20, 'filler123456', 'filler123456' from t0; @@ -317,7 +307,7 @@ from t0 where a in id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 1 PRIMARY eq_ref distinct_key distinct_key 8 func 1 Using where -2 MATERIALIZED t1 index a a 5 NULL 10 Using where; Using index +2 MATERIALIZED t1 range a a 5 NULL 10 Using where; Using index 2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index 2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index drop table t0, t1,t2,t3; @@ -358,7 +348,7 @@ WHERE Language='English' AND Percentage > 10 AND t2.Population > 100000); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary -1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t2 eq_ref|filter PRIMARY,Population PRIMARY|Population 3|4 test.t1.Country 1 (75%) Using where; End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter 1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan set optimizer_switch=@bug35674_save_optimizer_switch; DROP TABLE t1,t2,t3; @@ -852,10 +842,10 @@ explain SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY alias1 const PRIMARY PRIMARY 4 const # Using index -1 PRIMARY alias2 index f12 f12 7 NULL # Using index; Start temporary -1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index; Using join buffer (flat, BNL join) -1 PRIMARY t3 hash_ALL NULL #hash#$hj 3 test.alias2.f12 # Using where; End temporary; Using join buffer (incremental, BNLH join) +1 PRIMARY alias1 const PRIMARY PRIMARY 4 const # +1 PRIMARY alias2 index f12 f12 7 NULL # Using index; LooseScan +1 PRIMARY t1 ALL NULL NULL NULL NULL # FirstMatch(alias2) +1 PRIMARY t3 ALL NULL NULL NULL NULL # Using where; Using join buffer (flat, BNL join) SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); f12 @@ -923,10 +913,11 @@ EXPLAIN SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a WHERE t3.b IN (SELECT b FROM t4); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 ALL NULL NULL NULL NULL 1 Using where +1 PRIMARY t3 ALL NULL NULL NULL NULL 1 1 PRIMARY t2 hash_ALL NULL #hash#$hj 4 test.t3.a 1 Using where; Using join buffer (flat, BNLH join) 1 PRIMARY ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join) -1 PRIMARY t4 hash_ALL NULL #hash#$hj 4 test.t3.b 2 Using where; Start temporary; End temporary; Using join buffer (incremental, BNLH join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 3 DERIVED t1 ALL NULL NULL NULL NULL 1 SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a WHERE t3.b IN (SELECT b FROM t4); @@ -1246,10 +1237,10 @@ t1_pk1 t1_pk2 t3_i t3_c explain SELECT * FROM t1, t3 WHERE t3_c IN ( SELECT t1_pk2 FROM t4, t2 WHERE t2_c = t1_pk2 AND t2_i >= t3_i ) AND ( t1_pk1 = 'POL' ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ref PRIMARY PRIMARY 5 const 1 Using where; Using index -1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; Start temporary; Using join buffer (flat, BNL join) -1 PRIMARY t4 hash_index NULL #hash#$hj:PRIMARY 54:59 test.t2.t2_c 2 Using where; Using index; Using join buffer (incremental, BNLH join) -1 PRIMARY t3 hash_ALL NULL #hash#$hj 38 test.t2.t2_c 2 Using where; End temporary; Using join buffer (incremental, BNLH join) +1 PRIMARY t1 ref PRIMARY PRIMARY 5 const 1 Using where +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join) +1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t3); Using join buffer (incremental, BNL join) DROP TABLE t1,t2,t3,t4; # # MDEV-6263: Wrong result when using IN subquery with order by @@ -1367,9 +1358,9 @@ WHERE T3_0_.t3idref= 1 ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY T3_0_ ref PRIMARY,FK_T3_T2Id PRIMARY 8 const 3 Using index; Start temporary +1 PRIMARY T3_0_ ref PRIMARY,FK_T3_T2Id PRIMARY 8 const 3 Start temporary 1 PRIMARY T2_1_ eq_ref PRIMARY,FK_T2_T1Id PRIMARY 8 test.T3_0_.t2idref 1 Using join buffer (flat, BKA join); Key-ordered scan -1 PRIMARY T1_1_ eq_ref PRIMARY PRIMARY 8 test.T2_1_.t1idref 1 Using index +1 PRIMARY T1_1_ eq_ref PRIMARY PRIMARY 8 test.T2_1_.t1idref 1 Using join buffer (incremental, BKA join); Key-ordered scan 1 PRIMARY T2_0_ ref FK_T2_T1Id FK_T2_T1Id 8 test.T2_1_.t1idref 1 Using index; End temporary drop table t3,t2,t1; set optimizer_search_depth=@tmp7474; @@ -1469,17 +1460,18 @@ CREATE TABLE t3 (pk int PRIMARY KEY, a int); INSERT INTO t3 VALUES (1, 6), (2, 8); CREATE TABLE t4 (b int) ENGINE=InnoDB; INSERT INTO t4 VALUES (2),(88),(99); +insert into t2 select seq from seq_100_to_200; set @tmp_optimizer_switch=@@optimizer_switch; SET optimizer_switch = 'semijoin_with_cache=on'; SET join_cache_level = 2; EXPLAIN SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 1 -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 -2 MATERIALIZED t3 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL # +1 PRIMARY t2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join) +1 PRIMARY eq_ref distinct_key distinct_key 4 func # +2 MATERIALIZED t4 ALL NULL NULL NULL NULL # Using where +2 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 4 test.t4.b # SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk); pk a b 1 6 8 diff --git a/mysql-test/main/subselect_sj2_jcl6.test b/mysql-test/main/subselect_sj2_jcl6.test index ea3f07b289a..1001a213768 100644 --- a/mysql-test/main/subselect_sj2_jcl6.test +++ b/mysql-test/main/subselect_sj2_jcl6.test @@ -68,11 +68,14 @@ INSERT INTO t3 VALUES (1, 6), (2, 8); CREATE TABLE t4 (b int) ENGINE=InnoDB; INSERT INTO t4 VALUES (2),(88),(99); +insert into t2 select seq from seq_100_to_200; + set @tmp_optimizer_switch=@@optimizer_switch; SET optimizer_switch = 'semijoin_with_cache=on'; SET join_cache_level = 2; +--replace_column 9 # EXPLAIN SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk); SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk); diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result index e05cb85b470..a04e6333b07 100644 --- a/mysql-test/main/subselect_sj2_mat.result +++ b/mysql-test/main/subselect_sj2_mat.result @@ -27,11 +27,7 @@ key(b) ); insert into t2 select a, a/2 from t0; insert into t2 select a+10, a+10/2 from t0; -select * from t1; -a b -1 1 -1 1 -2 2 +insert into t1 values (1030,30),(1031,31),(1032,32),(1033,33); select * from t2; a b 0 0 @@ -56,9 +52,9 @@ a b 19 14 explain select * from t2 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 -1 PRIMARY t2 ref b b 5 test.t1.a 2 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t2 ALL b NULL NULL NULL 20 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 7 select * from t2 where b in (select a from t1); a b 1 1 @@ -84,9 +80,9 @@ test.t3 analyze status Engine-independent statistics collected test.t3 analyze status OK explain select * from t3 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 -1 PRIMARY t3 ref b b 5 test.t1.a 2 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t3 ALL b NULL NULL NULL 20 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 7 select * from t3 where b in (select a from t1); a b pk1 pk2 pk3 1 1 1 1 1 @@ -114,9 +110,8 @@ test.t3 analyze status Engine-independent statistics collected test.t3 analyze status OK explain select * from t3 where b in (select a from t0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL # -1 PRIMARY t3 ref b b 5 test.t0.a # -2 MATERIALIZED t0 ALL NULL NULL NULL NULL # Using where +1 PRIMARY t0 ALL NULL NULL NULL NULL # Using where; Start temporary +1 PRIMARY t3 ref b b 5 test.t0.a # End temporary select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); a b pk1 pk2 0 0 0 0 @@ -137,19 +132,17 @@ set join_buffer_size= @save_join_buffer_size; set max_heap_table_size= @save_max_heap_table_size; explain select * from t1 where a in (select b from t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where 1 PRIMARY t2 ref b b 5 test.t1.a 1 Using index; FirstMatch(t1) -select * from t1; -a b -1 1 -1 1 -2 2 select * from t1 where a in (select b from t2); a b 1 1 1 1 2 2 drop table t1, t2, t3; +# +# Test join buffering +# set @save_join_buffer_size = @@join_buffer_size; set join_buffer_size= 8192; create table t1 (a int, filler1 binary(200), filler2 binary(200)); @@ -309,7 +302,7 @@ from t0 where a in id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 1 PRIMARY eq_ref distinct_key distinct_key 8 func 1 Using where -2 MATERIALIZED t1 index a a 5 NULL 10 Using where; Using index +2 MATERIALIZED t1 range a a 5 NULL 10 Using where; Using index 2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index 2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index drop table t0, t1,t2,t3; @@ -350,7 +343,7 @@ WHERE Language='English' AND Percentage > 10 AND t2.Population > 100000); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary -1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary +1 PRIMARY t2 eq_ref|filter PRIMARY,Population PRIMARY|Population 3|4 test.t1.Country 1 (75%) Using where; End temporary; Using rowid filter 1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where set optimizer_switch=@bug35674_save_optimizer_switch; DROP TABLE t1,t2,t3; @@ -842,9 +835,9 @@ explain SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY alias1 const PRIMARY PRIMARY 4 const # Using index +1 PRIMARY alias1 const PRIMARY PRIMARY 4 const # 1 PRIMARY alias2 index f12 f12 7 NULL # Using index; LooseScan -1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index; FirstMatch(alias2) +1 PRIMARY t1 ALL NULL NULL NULL NULL # FirstMatch(alias2) 1 PRIMARY t3 ALL NULL NULL NULL NULL # Using where; Using join buffer (flat, BNL join) SELECT * FROM t3 WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); @@ -1237,10 +1230,10 @@ t1_pk1 t1_pk2 t3_i t3_c explain SELECT * FROM t1, t3 WHERE t3_c IN ( SELECT t1_pk2 FROM t4, t2 WHERE t2_c = t1_pk2 AND t2_i >= t3_i ) AND ( t1_pk1 = 'POL' ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ref PRIMARY PRIMARY 5 const 1 Using where; Using index +1 PRIMARY t1 ref PRIMARY PRIMARY 5 const 1 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where -1 PRIMARY t4 index NULL PRIMARY 59 NULL 2 Using where; Using index; FirstMatch(t3) +1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t3) DROP TABLE t1,t2,t3,t4; # # MDEV-6263: Wrong result when using IN subquery with order by @@ -1358,9 +1351,9 @@ WHERE T3_0_.t3idref= 1 ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY T3_0_ ref PRIMARY,FK_T3_T2Id PRIMARY 8 const 3 Using index; Start temporary +1 PRIMARY T3_0_ ref PRIMARY,FK_T3_T2Id PRIMARY 8 const 3 Start temporary 1 PRIMARY T2_1_ eq_ref PRIMARY,FK_T2_T1Id PRIMARY 8 test.T3_0_.t2idref 1 -1 PRIMARY T1_1_ eq_ref PRIMARY PRIMARY 8 test.T2_1_.t1idref 1 Using index +1 PRIMARY T1_1_ eq_ref PRIMARY PRIMARY 8 test.T2_1_.t1idref 1 1 PRIMARY T2_0_ ref FK_T2_T1Id FK_T2_T1Id 8 test.T2_1_.t1idref 1 Using index; End temporary drop table t3,t2,t1; set optimizer_search_depth=@tmp7474; @@ -1566,7 +1559,7 @@ WHERE ( b1, b1 ) IN ( SELECT a4, b4 FROM t3, t4); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary 1 PRIMARY t1 ref idx idx 2 test.t4.a4 1 100.00 Using index -1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 16.67 End temporary; Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t4`) left join `test`.`t2` on(`test`.`t2`.`a2` = `test`.`t4`.`a4`) where `test`.`t4`.`b4` = `test`.`t4`.`a4` and `test`.`t1`.`b1` = `test`.`t4`.`a4` @@ -1584,7 +1577,7 @@ WHERE ( b1, b1 ) IN ( SELECT a4, b4 FROM t3, t4); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary 1 PRIMARY t1 ref idx idx 2 test.t4.a4 1 100.00 Using index -1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 16.67 End temporary; Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t4`) left join `test`.`t2` on(`test`.`t2`.`a2` = `test`.`t4`.`a4`) where `test`.`t4`.`b4` = `test`.`t4`.`a4` and `test`.`t1`.`b1` = `test`.`t4`.`a4` @@ -1619,7 +1612,7 @@ WHERE c1 IN ( SELECT c4 FROM t3,t4 WHERE c3 = c4); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary; Using join buffer (flat, BNL join) -1 PRIMARY t3 ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 10 5.00 Using where; End temporary; Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t4`) left join `test`.`t2` on(`test`.`t2`.`c2` = `test`.`t1`.`c1` or `test`.`t1`.`c1` > 'z') where `test`.`t4`.`c4` = `test`.`t1`.`c1` and `test`.`t3`.`c3` = `test`.`t1`.`c1` @@ -1678,12 +1671,12 @@ set optimizer_switch='materialization=on,semijoin=on'; EXPLAIN EXTENDED SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 = i2 OR 1=2); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 100.00 -1 PRIMARY t1 hash_ALL NULL #hash#$hj 5 test.t2.i2 5 100.00 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where 2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join) Warnings: -Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`i1` = `test`.`t2`.`i2` +Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 = i2 OR 1=2); i1 7 @@ -1691,12 +1684,12 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 100.00 -1 PRIMARY t1 hash_ALL NULL #hash#$hj 5 test.t2.i2 5 100.00 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where 2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join) Warnings: -Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`i1` = `test`.`t2`.`i2` and `test`.`t3`.`i3` > 0 +Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t3`.`i3` > 0 SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2); i1 @@ -1723,11 +1716,10 @@ i explain extended select * from t1 where (rand() < 0) and i in (select i from t2); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 100.00 +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 10 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where rand() < 0 +Note 1003 select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`i` = `test`.`t1`.`i` and rand() < 0 drop table t1,t2; set optimizer_switch=@save_optimizer_switch; # @@ -1754,7 +1746,7 @@ WHERE f1 IN ( SELECT f2 FROM t2 WHERE f2 > 'bar' ) HAVING f1 != 'foo' ORDER BY f1; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index f1 f1 11 NULL 2 Using where; Using index; Using temporary; Using filesort +1 PRIMARY t1 range f1 f1 11 NULL 2 Using where; Using index; Using temporary; Using filesort 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) DROP TABLE t1,t2; # @@ -1793,7 +1785,7 @@ OR (t.id IN (0,4,12,13,1,10,3,11)) ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t index PRIMARY PRIMARY 4 NULL 114 Using where; Using index +1 PRIMARY t ALL PRIMARY NULL NULL NULL 114 Using where 2 MATERIALIZED A ALL PRIMARY NULL NULL NULL 114 2 MATERIALIZED eq_ref distinct_key distinct_key 67 func 1 3 MATERIALIZED B range PRIMARY PRIMARY 4 NULL 8 Using where @@ -1957,20 +1949,16 @@ AND t3.id_product IN (SELECT id_product FROM t2 t2_3 WHERE t2_3.id_t2 = 18 OR t2 AND t3.id_product IN (SELECT id_product FROM t2 t2_4 WHERE t2_4.id_t2 = 34 OR t2_4.id_t2 = 23) AND t3.id_product IN (SELECT id_product FROM t2 t2_5 WHERE t2_5.id_t2 = 29 OR t2_5.id_t2 = 28 OR t2_5.id_t2 = 26); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using index -1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t1.id_product 1 Using index -1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t1.id_product,const 1 Using where; Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where +1 PRIMARY t2_2 ref id_t2,id_product id_t2 5 const 12 Using where; Start temporary +1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t2_2.id_product 1 Using where; Using index; End temporary +1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where +1 PRIMARY t2_3 range id_t2,id_product id_t2 5 NULL 33 Using index condition; Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) 1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) -3 MATERIALIZED t2_2 ref id_t2,id_product id_t2 5 const 12 -4 MATERIALIZED t2_3 range id_t2,id_product id_t2 5 NULL 33 Using index condition; Using where -5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where -6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where -2 MATERIALIZED t2_1 ref id_t2,id_product id_t2 5 const 51 +1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using where; Using index; Using join buffer (flat, BNL join) +2 MATERIALIZED t2_1 ALL id_t2,id_product NULL NULL NULL 223 Using where set optimizer_switch='rowid_filter=default'; drop table t1,t2,t3,t4,t5; set global innodb_stats_persistent= @innodb_stats_persistent_save; diff --git a/mysql-test/main/subselect_sj_jcl6.result b/mysql-test/main/subselect_sj_jcl6.result index d07002f978e..78b2518891f 100644 --- a/mysql-test/main/subselect_sj_jcl6.result +++ b/mysql-test/main/subselect_sj_jcl6.result @@ -87,19 +87,19 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where `test`.`t12`.`pk` = `test`.`t10`.`a` and `test`.`t10`.`pk` = `test`.`t1`.`a` subqueries within outer joins go into ON expr. -explAin extended +explain extended select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A And B.A in (select pk from t10)); -id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA +id select_type table type possible_keys key key_len ref rows filtered ExtrA 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY A ALL NULL NULL NULL NULL 3 100.00 Using where; Using join Buffer (flAt, BNL join) 1 PRIMARY B ALL NULL NULL NULL NULL 3 100.00 Using where; Using join Buffer (incrementAl, BNL join) -2 MATERIALIZED t10 index PRIMARY PRIMARY 4 NULL 10 100.00 Using index +2 DEPENDENT SUBQUERY t10 unique_suBquery PRIMARY PRIMARY 4 func 1 100.00 Using index Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t2` `A` join `test`.`t2` `B`) on(`test`.`A`.`A` = `test`.`t1`.`A` And (`test`.`B`.`A`,`test`.`B`.`A` in ( (/* select#2 */ select `test`.`t10`.`pk` from `test`.`t10` ), (`test`.`B`.`A` in on distinct_key where `test`.`B`.`A` = ``.`pk`)))) where 1 +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t2` `A` join `test`.`t2` `B`) on(`test`.`A`.`A` = `test`.`t1`.`A` And (`test`.`B`.`A`,(((`test`.`B`.`A`) in t10 on PRIMARY)))) where 1 t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" -explAin extended +explain extended select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10)); -id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA +id select_type table type possible_keys key key_len ref rows filtered ExtrA 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join Buffer (flAt, BNL join) 2 DEPENDENT SUBQUERY t10 unique_suBquery PRIMARY PRIMARY 4 func 1 100.00 Using index @@ -355,8 +355,8 @@ WHERE PNUM IN (SELECT PNUM FROM PROJ)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY STAFF ALL NULL NULL NULL NULL 5 -1 PRIMARY PROJ ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join) -1 PRIMARY WORKS ALL NULL NULL NULL NULL 12 Using where; FirstMatch(STAFF); Using join buffer (incremental, BNL join) +1 PRIMARY PROJ ALL NULL NULL NULL NULL 6 Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY WORKS ALL NULL NULL NULL NULL 12 Using where; End temporary; Using join buffer (incremental, BNL join) SELECT EMPNUM, EMPNAME FROM STAFF WHERE EMPNUM IN @@ -513,7 +513,7 @@ EXPLAIN EXTENDED SELECT vkey FROM t0 WHERE pk IN id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t0 ALL PRIMARY NULL NULL NULL 5 100.00 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 PRIMARY t2 ref vkey vkey 4 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 ref vkey vkey 4 test.t1.vnokey 2 50.00 Using index; FirstMatch(t1) Warnings: Note 1003 select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` semi join (`test`.`t0` `t2`) join `test`.`t0` where `test`.`t1`.`pk` = `test`.`t0`.`pk` and `test`.`t2`.`vkey` = `test`.`t1`.`vnokey` SELECT vkey FROM t0 WHERE pk IN @@ -817,10 +817,9 @@ insert into t2 (pk) values (-1),(0); EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 11 func,func 1 100.00 -2 MATERIALIZED t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Rowid-ordered scan +1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Rowid-ordered scan; FirstMatch(t1); Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`pk` > 0 +Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t2`.`pk` > 0 SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); pk 2 @@ -986,10 +985,9 @@ FROM t1 WHERE `varchar_nokey` < 'n' XOR `pk` ) ; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 100.00 -2 MATERIALIZED t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where +1 PRIMARY t1 ref varchar_key varchar_key 3 test.t2.varchar_nokey 2 100.00 Using where; FirstMatch(t2); Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan Warnings: -Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key` and (`test`.`t1`.`varchar_key` < 'n' xor `test`.`t1`.`pk`) +Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`varchar_key` = `test`.`t2`.`varchar_nokey` and `test`.`t1`.`varchar_nokey` = `test`.`t2`.`varchar_nokey` and (`test`.`t2`.`varchar_nokey` < 'n' xor `test`.`t1`.`pk`) SELECT varchar_nokey FROM t2 WHERE ( `varchar_nokey` , `varchar_nokey` ) IN ( @@ -1068,10 +1066,8 @@ AND t1.val IN (SELECT t3.val FROM t3 WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%'); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 -1 PRIMARY eq_ref distinct_key distinct_key 13 func 1 -1 PRIMARY eq_ref distinct_key distinct_key 13 func 1 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where -3 MATERIALIZED t3 ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where; FirstMatch(t2); Using join buffer (incremental, BNL join) SELECT * FROM t1 WHERE t1.val IN (SELECT t2.val FROM t2 @@ -1653,11 +1649,9 @@ select * from t1 A, t1 B where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY A ALL NULL NULL NULL NULL 5 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -1 PRIMARY B ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED C ALL NULL NULL NULL NULL 5 -3 MATERIALIZED D ALL NULL NULL NULL NULL 5 +1 PRIMARY C ALL NULL NULL NULL NULL 5 Using where; FirstMatch(A); Using join buffer (flat, BNL join) +1 PRIMARY B ALL NULL NULL NULL NULL 5 Using where; Using join buffer (incremental, BNL join) +1 PRIMARY D ALL NULL NULL NULL NULL 5 Using where; FirstMatch(B); Using join buffer (incremental, BNL join) drop table t1, t2; # # BUG#784441: Abort on semijoin with a view as the inner table @@ -2010,7 +2004,7 @@ explain extended SELECT * FROM t1 NATURAL LEFT JOIN (t2, t3) WHERE t2.f3 IN (SELECT * FROM t4 where f2 = 0 or f2 IS NULL); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY t4 ref_or_null f2 f2 5 const 4 100.00 Using where; Using index; FirstMatch(t2) +1 PRIMARY t4 ref_or_null f2 f2 5 const 4 25.00 Using where; Using index; FirstMatch(t2) 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t3 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: @@ -2166,8 +2160,8 @@ explain SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY t3 ref b b 5 test.t1.b 2 Start temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index; End temporary; Using join buffer (incremental, BNL join) +1 PRIMARY t3 ref b b 5 test.t1.b 2 Using where; Start temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 Using index; End temporary SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); b a 5 6 @@ -2190,10 +2184,10 @@ INSERT INTO t5 VALUES (7,0),(9,0); explain SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where -1 PRIMARY t4 ALL NULL NULL NULL NULL 3 FirstMatch(t5) -1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; Start temporary +1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; End temporary; Using join buffer (incremental, BNL join) SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); a 0 @@ -2272,10 +2266,10 @@ alias1.c IN (SELECT SQ3_alias1.b FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2) LIMIT 100; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 20 -1 PRIMARY alias2 ALL NULL NULL NULL NULL 20 Using join buffer (flat, BNL join) -1 PRIMARY t2 ALL NULL NULL NULL NULL 20 Using join buffer (incremental, BNL join) -1 PRIMARY SQ3_alias1 ALL NULL NULL NULL NULL 20 Using where; Start temporary; Using join buffer (incremental, BNL join) +1 PRIMARY alias2 ALL NULL NULL NULL NULL 20 +1 PRIMARY t2 ALL NULL NULL NULL NULL 20 Using join buffer (flat, BNL join) +1 PRIMARY SQ3_alias1 ALL NULL NULL NULL NULL 20 Start temporary; Using join buffer (incremental, BNL join) +1 PRIMARY ALL NULL NULL NULL NULL 20 Using where; Using join buffer (incremental, BNL join) 1 PRIMARY SQ3_alias2 index NULL PRIMARY 4 NULL 20 Using index; End temporary; Using join buffer (incremental, BNL join) 2 DERIVED t2 ALL NULL NULL NULL NULL 20 create table t3 as @@ -2448,9 +2442,9 @@ SET SESSION optimizer_switch='loosescan=off'; EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 index idx idx 9 NULL 2 Using where; Using index; Start temporary -1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 +1 PRIMARY t2 range idx idx 4 NULL 2 Using where; Using index +1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); a 5 @@ -2458,9 +2452,9 @@ SET SESSION optimizer_switch='loosescan=on'; EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 index idx idx 9 NULL 2 Using where; Using index; Start temporary -1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 +1 PRIMARY t2 range idx idx 4 NULL 2 Using where; Using index +1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); a 5 @@ -2587,7 +2581,7 @@ WHERE ( b, d ) IN id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index b b 5 NULL 10 Using where; Using index; Start temporary 1 PRIMARY t2 ref c c 5 test.t1.b 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 PRIMARY t1 ref b b 5 test.t1.b 2 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t1 ALL b NULL NULL NULL 10 Using where; Using join buffer (incremental, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 Using where; End temporary; Using join buffer (incremental, BNL join) SELECT a, b, d FROM t1, t2 WHERE ( b, d ) IN @@ -2779,8 +2773,8 @@ SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where -1 PRIMARY ref key0 key0 5 test.t1_1.a 2 Start temporary -1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary +1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 +1 PRIMARY ref key0 key0 5 test.t1_1.a 2 Using where; FirstMatch(t1_2) 3 DERIVED t1 ALL NULL NULL NULL NULL 11 SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); @@ -3048,7 +3042,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort 1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 5 100.00 Start temporary 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (incremental, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 10.00 Using where; End temporary; Using join buffer (incremental, BNL join) Warnings: Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1`,'x' AS `c2` from `test`.`t1` semi join (`test`.`t1` left join `test`.`t3` on(`test`.`t1`.`c1` = `test`.`t3`.`c3`)) where `test`.`t1`.`pk` = `test`.`t1`.`pk` order by 'x',`test`.`t1`.`c1` DROP TABLE t1,t2,t3; @@ -3300,7 +3294,7 @@ explain extended SELECT Id FROM t1 WHERE Id in (SELECT t1_Id FROM t2 WHERE t2.col1 IS NULL); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 100.00 -1 PRIMARY t2 ALL col1 NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +1 PRIMARY t2 ref col1 col1 5 const 2 50.00 Using index condition; Using where; FirstMatch(t1) Warnings: Note 1003 select 1 AS `Id` from (`test`.`t2`) where `test`.`t2`.`t1_Id` = 1 and `test`.`t2`.`col1` is null DROP TABLE t1, t2; @@ -3481,20 +3475,21 @@ INSERT INTO t2 VALUES ('v'), ('v'), ('s'), ('j'); CREATE TABLE t3 (c varchar(1), d varchar(1), INDEX idx_c(c) ); INSERT INTO t3 VALUES ('v','v'), ('v','v'), ('s','s'), ('j','j'); INSERT INTO t3 VALUES ('m','m'), ('d','d'), ('k','k'), ('m','m'); +insert into t1 select 'z','z' from seq_1_to_20; set @tmp_otimizer_switch= @@optimizer_switch; set @tmp_join_cache_level=@@join_cache_level; set optimizer_switch = 'materialization=on,semijoin=on,join_cache_hashed=on'; set join_cache_level=0; EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON (c = b) -WHERE (a, b) IN (SELECT a, b FROM t1 t); +WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL idx_a NULL NULL NULL 3 +1 PRIMARY t1 ALL idx_a NULL NULL NULL 23 1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 1 PRIMARY t2 ref idx_c idx_c 4 test.t1.b 2 Using where; Using index -2 MATERIALIZED t ALL idx_a NULL NULL NULL 3 +2 MATERIALIZED t ALL idx_a NULL NULL NULL 23 SELECT * FROM t1 LEFT JOIN t2 ON (c = b) -WHERE (a, b) IN (SELECT a, b FROM t1 t); +WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; a b c v v v v v v @@ -3502,14 +3497,13 @@ w w NULL t t NULL EXPLAIN SELECT * FROM t1 LEFT JOIN t3 ON (c = b) -WHERE (a, b) IN (SELECT a, b FROM t1 t); +WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL idx_a NULL NULL NULL 3 -1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 -1 PRIMARY t3 ref idx_c idx_c 4 test.t1.b 2 Using where -2 MATERIALIZED t ALL idx_a NULL NULL NULL 3 +1 PRIMARY t ALL idx_a NULL NULL NULL 23 Using where; Start temporary +1 PRIMARY t1 ref idx_a idx_a 4 test.t.a 2 Using where; End temporary +1 PRIMARY t3 ref idx_c idx_c 4 test.t.b 2 Using where SELECT * FROM t1 LEFT JOIN t3 ON (c = b) -WHERE (a, b) IN (SELECT a, b FROM t1 t); +WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; a b c d v v v v v v v v @@ -3518,14 +3512,14 @@ t t NULL NULL set join_cache_level=6; EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON (c = b) -WHERE (a, b) IN (SELECT a, b FROM t1 t); +WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL idx_a NULL NULL NULL 3 +1 PRIMARY t1 ALL idx_a NULL NULL NULL 23 1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 1 PRIMARY t2 ref idx_c idx_c 4 test.t1.b 2 Using where; Using index -2 MATERIALIZED t ALL idx_a NULL NULL NULL 3 +2 MATERIALIZED t ALL idx_a NULL NULL NULL 23 SELECT * FROM t1 LEFT JOIN t2 ON (c = b) -WHERE (a, b) IN (SELECT a, b FROM t1 t); +WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; a b c v v v v v v @@ -3533,14 +3527,13 @@ w w NULL t t NULL EXPLAIN SELECT * FROM t1 LEFT JOIN t3 ON (c = b) -WHERE (a, b) IN (SELECT a, b FROM t1 t); +WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL idx_a NULL NULL NULL 3 -1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 -1 PRIMARY t3 ref idx_c idx_c 4 test.t1.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -2 MATERIALIZED t ALL idx_a NULL NULL NULL 3 +1 PRIMARY t ALL idx_a NULL NULL NULL 23 Start temporary +1 PRIMARY t1 ALL idx_a NULL NULL NULL 23 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t3 ref idx_c idx_c 4 test.t.b 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT * FROM t1 LEFT JOIN t3 ON (c = b) -WHERE (a, b) IN (SELECT a, b FROM t1 t); +WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; a b c d v v v v v v v v diff --git a/mysql-test/main/subselect_sj_jcl6.test b/mysql-test/main/subselect_sj_jcl6.test index f4f605c0406..e39a6887bde 100644 --- a/mysql-test/main/subselect_sj_jcl6.test +++ b/mysql-test/main/subselect_sj_jcl6.test @@ -3,6 +3,7 @@ # --source include/no_valgrind_without_big.inc --source include/default_optimizer_switch.inc +--source include/have_sequence.inc set @save_optimizer_switch_jcl6=@@optimizer_switch; set @@optimizer_switch='optimize_join_buffer_size=on'; @@ -132,6 +133,8 @@ CREATE TABLE t3 (c varchar(1), d varchar(1), INDEX idx_c(c) ); INSERT INTO t3 VALUES ('v','v'), ('v','v'), ('s','s'), ('j','j'); INSERT INTO t3 VALUES ('m','m'), ('d','d'), ('k','k'), ('m','m'); +insert into t1 select 'z','z' from seq_1_to_20; + set @tmp_otimizer_switch= @@optimizer_switch; set @tmp_join_cache_level=@@join_cache_level; set optimizer_switch = 'materialization=on,semijoin=on,join_cache_hashed=on'; @@ -140,29 +143,29 @@ set join_cache_level=0; EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON (c = b) - WHERE (a, b) IN (SELECT a, b FROM t1 t); + WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; SELECT * FROM t1 LEFT JOIN t2 ON (c = b) - WHERE (a, b) IN (SELECT a, b FROM t1 t); + WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; EXPLAIN SELECT * FROM t1 LEFT JOIN t3 ON (c = b) - WHERE (a, b) IN (SELECT a, b FROM t1 t); + WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; SELECT * FROM t1 LEFT JOIN t3 ON (c = b) - WHERE (a, b) IN (SELECT a, b FROM t1 t); + WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; set join_cache_level=6; EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON (c = b) - WHERE (a, b) IN (SELECT a, b FROM t1 t); + WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; SELECT * FROM t1 LEFT JOIN t2 ON (c = b) - WHERE (a, b) IN (SELECT a, b FROM t1 t); + WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; EXPLAIN SELECT * FROM t1 LEFT JOIN t3 ON (c = b) - WHERE (a, b) IN (SELECT a, b FROM t1 t); + WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; SELECT * FROM t1 LEFT JOIN t3 ON (c = b) - WHERE (a, b) IN (SELECT a, b FROM t1 t); + WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; set optimizer_switch=@tmp_optimizer_switch; set join_cache_level=@tmp_join_cache_level; diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result index 876b292df2d..68af9e9cd35 100644 --- a/mysql-test/main/subselect_sj_mat.result +++ b/mysql-test/main/subselect_sj_mat.result @@ -108,7 +108,7 @@ explain extended select * from t1i where a1 in (select b1 from t2i where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2i index it2i1,it2i3 it2i1 # NULL 5 50.00 Using where; Using index; LooseScan -1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00 +1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 20.00 Warnings: Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` > '0' select * from t1i where a1 in (select b1 from t2i where b1 > '0'); @@ -118,11 +118,11 @@ a1 a2 explain extended select * from t1i where a1 in (select max(b1) from t2i where b1 > '0' group by b1); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1i index it1i1,it1i3 # 18 # 3 100.00 # -1 PRIMARY eq_ref distinct_key # 8 # 1 100.00 # +1 PRIMARY ALL distinct_key # NULL # 5 100.00 # +1 PRIMARY t1i ref it1i1,it1i3 # 9 # 1 100.00 # 2 MATERIALIZED t2i range it2i1,it2i3 # 9 # 5 100.00 # Warnings: -Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from (/* select#2 */ select max(`test`.`t2i`.`b1`) from `test`.`t2i` where `test`.`t2i`.`b1` > '0' group by `test`.`t2i`.`b1`) join `test`.`t1i` where ``.`max(b1)` = `test`.`t1i`.`a1` +Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from (/* select#2 */ select max(`test`.`t2i`.`b1`) from `test`.`t2i` where `test`.`t2i`.`b1` > '0' group by `test`.`t2i`.`b1`) join `test`.`t1i` where `test`.`t1i`.`a1` = ``.`max(b1)` select * from t1i where a1 in (select max(b1) from t2i where b1 > '0' group by b1); a1 a2 1 - 01 2 - 01 @@ -131,7 +131,7 @@ explain extended select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2i index it2i1,it2i2,it2i3 it2i3 # NULL 5 50.00 Using where; Using index; LooseScan -1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00 +1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 20.00 Warnings: Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0' select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0'); @@ -141,11 +141,11 @@ a1 a2 explain extended select * from t1i where (a1, a2) in (select b1, max(b2) from t2i where b1 > '0' group by b1); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1i index it1i1,it1i2,it1i3 # # # 3 100.00 # -1 PRIMARY eq_ref distinct_key # # # 1 100.00 # +1 PRIMARY ALL distinct_key # # # 5 100.00 # +1 PRIMARY t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 # 2 MATERIALIZED t2i range it2i1,it2i3 # # # 5 100.00 # Warnings: -Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from (/* select#2 */ select `test`.`t2i`.`b1`,max(`test`.`t2i`.`b2`) from `test`.`t2i` where `test`.`t2i`.`b1` > '0' group by `test`.`t2i`.`b1`) join `test`.`t1i` where ``.`b1` = `test`.`t1i`.`a1` and ``.`max(b2)` = `test`.`t1i`.`a2` +Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from (/* select#2 */ select `test`.`t2i`.`b1`,max(`test`.`t2i`.`b2`) from `test`.`t2i` where `test`.`t2i`.`b1` > '0' group by `test`.`t2i`.`b1`) join `test`.`t1i` where `test`.`t1i`.`a1` = ``.`b1` and `test`.`t1i`.`a2` = ``.`max(b2)` select * from t1i where (a1, a2) in (select b1, max(b2) from t2i where b1 > '0' group by b1); a1 a2 1 - 01 2 - 01 @@ -153,11 +153,11 @@ a1 a2 explain extended select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1i index it1i1,it1i2,it1i3 # # # 3 100.00 # -1 PRIMARY eq_ref distinct_key # # # 1 100.00 # +1 PRIMARY ALL distinct_key # # # 5 100.00 # +1 PRIMARY t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 # 2 MATERIALIZED t2i range it2i1,it2i3 # # # 5 100.00 # Warnings: -Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from (/* select#2 */ select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where `test`.`t2i`.`b1` > '0' group by `test`.`t2i`.`b1`) join `test`.`t1i` where ``.`b1` = `test`.`t1i`.`a1` and ``.`min(b2)` = `test`.`t1i`.`a2` +Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from (/* select#2 */ select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where `test`.`t2i`.`b1` > '0' group by `test`.`t2i`.`b1`) join `test`.`t1i` where `test`.`t1i`.`a1` = ``.`b1` and `test`.`t1i`.`a2` = ``.`min(b2)` select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1); a1 a2 1 - 01 2 - 01 @@ -277,7 +277,7 @@ explain extended select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 50.00 Using where; Using index; LooseScan -1 PRIMARY t1i ref it1i1,it1i2,it1i3 it1i3 18 test.t2i.b1,test.t2i.b2 1 100.00 Using index +1 PRIMARY t1i ref it1i1,it1i2,it1i3 it1i3 18 test.t2i.b1,test.t2i.b2 1 20.00 Using index Warnings: Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2); @@ -329,14 +329,12 @@ where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and (a1, a2) in (select c1, c2 from t3 where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where -3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where -3 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t1.a1,test.t1.a2 1 100.00 Using index; Start temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 4 15.00 Using where; End temporary; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and `test`.`t2`.`b1` > '0' and `test`.`t3`.`c2` > '0' +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t1`.`a1` and `test`.`t2`.`b1` = `test`.`t1`.`a1` and `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b2` = `test`.`t1`.`a2` and `test`.`t2`.`b2` = `test`.`t1`.`a2` and `test`.`t3`.`c2` = `test`.`t1`.`a2` and `test`.`t1`.`a1` > '0' and `test`.`t1`.`a2` > '0' select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and (a1, a2) in (select c1, c2 from t3 @@ -351,9 +349,9 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2i index it2i1,it2i2,it2i3 # # # 5 50.00 # -1 PRIMARY t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 # +1 PRIMARY t1i ref it1i1,it1i2,it1i3 # # # 1 20.00 # 1 PRIMARY t3i ref it3i1,it3i2,it3i3 # # # 1 100.00 # -1 PRIMARY t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # +1 PRIMARY t2i ref it2i1,it2i2,it2i3 # # # 1 60.00 # Warnings: Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t3i`.`c1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t3i`.`c2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0' and `test`.`t2i`.`b2` > '0' select * from t1i @@ -371,16 +369,14 @@ b2 in (select c2 from t3 where c2 LIKE '%03')) and (a1, a2) in (select c1, c2 from t3 where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where -5 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where -5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t1.a1,test.t1.a2 1 100.00 Using index; Start temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 4 15.00 Using where; End temporary; Using join buffer (flat, BNL join) 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and (<`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`)))) or <`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`))))) and `test`.`t3`.`c2` > '0' +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t1`.`a1` and `test`.`t2`.`b1` = `test`.`t1`.`a1` and `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b2` = `test`.`t1`.`a2` and `test`.`t2`.`b2` = `test`.`t1`.`a2` and `test`.`t3`.`c2` = `test`.`t1`.`a2` and (<`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`)))) or <`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`))))) and `test`.`t1`.`a2` > '0' select * from t1 where (a1, a2) in (select b1, b2 from t2 where b2 in (select c2 from t3 where c2 LIKE '%02') or @@ -398,7 +394,7 @@ b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 5 20.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 5 MATERIALIZED t3c ALL NULL NULL NULL NULL 4 100.00 Using where 5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3c.c1,test.t3c.c2 1 100.00 Using index @@ -431,20 +427,18 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and where (c1, c2) in (select b1, b2 from t2i where b2 > '0'))); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL # # # 3 100.00 # -1 PRIMARY eq_ref distinct_key # # # 1 100.00 # -1 PRIMARY eq_ref distinct_key # # # 1 100.00 # -2 MATERIALIZED t2 ALL NULL # # # 5 100.00 # -5 MATERIALIZED t3 ALL NULL # # # 4 100.00 # -5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # +1 PRIMARY t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # +1 PRIMARY t2 ALL NULL # # # 5 20.00 # +1 PRIMARY t3 ALL NULL # # # 4 15.00 # 4 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 3 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 7 UNION t2i index it2i1,it2i2,it2i3 # # # 5 50.00 # -7 UNION t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 # +7 UNION t1i ref it1i1,it1i2,it1i3 # # # 1 20.00 # 7 UNION t3i ref it3i1,it3i2,it3i3 # # # 1 100.00 # -7 UNION t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # +7 UNION t2i ref it2i1,it2i2,it2i3 # # # 1 60.00 # NULL UNION RESULT ALL NULL # # # NULL NULL # Warnings: -Note 1003 (/* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and (<`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`)))) or <`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`))))) and `test`.`t3`.`c2` > '0') union (/* select#7 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t3i`.`c1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t3i`.`c2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0' and `test`.`t2i`.`b2` > '0') +Note 1003 (/* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t1`.`a1` and `test`.`t2`.`b1` = `test`.`t1`.`a1` and `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b2` = `test`.`t1`.`a2` and `test`.`t2`.`b2` = `test`.`t1`.`a2` and `test`.`t3`.`c2` = `test`.`t1`.`a2` and (<`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`)))) or <`test`.`t2`.`b2`>((`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), (`test`.`t2`.`b2` in on distinct_key where `test`.`t2`.`b2` = ``.`c2`))))) and `test`.`t1`.`a2` > '0') union (/* select#7 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t3i`.`c1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t3i`.`c2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0' and `test`.`t2i`.`b2` > '0') (select * from t1 where (a1, a2) in (select b1, b2 from t2 where b2 in (select c2 from t3 where c2 LIKE '%02') or @@ -536,9 +530,9 @@ b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and where (c1, c2) in (select b1, b2 from t2i where b2 > '0' or b2 = a2)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 5 20.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) 1 PRIMARY t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t1.a1,test.t1.a2 1 100.00 Using index; Start temporary -1 PRIMARY t3c ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t3c ALL NULL NULL NULL NULL 4 15.00 Using where; End temporary; Using join buffer (flat, BNL join) 4 MATERIALIZED t3b ALL NULL NULL NULL NULL 4 100.00 Using where 3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: @@ -652,7 +646,7 @@ from t1_16 where a1 in (select b1 from t2_16 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where `test`.`t2_16`.`b1` = `test`.`t1_16`.`a1` and `test`.`t1_16`.`a1` > '0' select left(a1,7), left(a2,7) @@ -666,7 +660,7 @@ from t1_16 where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where `test`.`t2_16`.`b1` = `test`.`t1_16`.`a1` and `test`.`t2_16`.`b2` = `test`.`t1_16`.`a2` and `test`.`t1_16`.`a1` > '0' select left(a1,7), left(a2,7) @@ -733,7 +727,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; Using join buffer (flat, BNL join) 1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 5 0.56 Using where; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2_16` join `test`.`t2` join `test`.`t1_16`) where `test`.`t2`.`b1` = `test`.`t3`.`c1` and `test`.`t2_16`.`b1` = `test`.`t1_16`.`a1` and `test`.`t2_16`.`b2` = `test`.`t1_16`.`a2` and `test`.`t2`.`b2` = substr(`test`.`t1_16`.`a2`,1,6) and `test`.`t3`.`c2` > '0' and concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8) drop table t1_16, t2_16, t3_16; @@ -767,7 +761,7 @@ from t1_512 where a1 in (select b1 from t2_512 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_512 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where `test`.`t2_512`.`b1` = `test`.`t1_512`.`a1` and `test`.`t1_512`.`a1` > '0' select left(a1,7), left(a2,7) @@ -781,7 +775,7 @@ from t1_512 where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_512 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where `test`.`t2_512`.`b1` = `test`.`t1_512`.`a1` and `test`.`t2_512`.`b2` = `test`.`t1_512`.`a2` and `test`.`t1_512`.`a1` > '0' select left(a1,7), left(a2,7) @@ -871,7 +865,7 @@ from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_1024 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where `test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1` and `test`.`t1_1024`.`a1` > '0' select left(a1,7), left(a2,7) @@ -885,7 +879,7 @@ from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_1024 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where `test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1` and `test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2` and `test`.`t1_1024`.`a1` > '0' select left(a1,7), left(a2,7) @@ -899,7 +893,7 @@ from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_1024 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where `test`.`t2_1024`.`b1` > '0' and `test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024) select left(a1,7), left(a2,7) @@ -974,7 +968,7 @@ from t1_1025 where a1 in (select b1 from t2_1025 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_1025 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where `test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1` and `test`.`t1_1025`.`a1` > '0' select left(a1,7), left(a2,7) @@ -988,7 +982,7 @@ from t1_1025 where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_1025 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where `test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1` and `test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2` and `test`.`t1_1025`.`a1` > '0' select left(a1,7), left(a2,7) @@ -1002,7 +996,7 @@ from t1_1025 where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2_1025 ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where `test`.`t2_1025`.`b1` > '0' and `test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025) select left(a1,7), left(a2,7) @@ -1084,7 +1078,7 @@ from t1bb where (a1, a2) in (select b1, b2 from t2bb); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1bb ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY t2bb ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2bb ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select conv(`test`.`t1bb`.`a1`,10,2) AS `bin(a1)`,`test`.`t1bb`.`a2` AS `a2` from `test`.`t1bb` semi join (`test`.`t2bb`) where `test`.`t2bb`.`b1` = `test`.`t1bb`.`a1` and `test`.`t2bb`.`b2` = `test`.`t1bb`.`a2` select bin(a1), a2 @@ -1146,11 +1140,10 @@ create index it1a on t1(a); explain extended select a from t1 where a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index it1a it1a 4 NULL 7 100.00 Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Start temporary +1 PRIMARY t1 ref it1a it1a 4 test.t2.c 2 16.67 Using index; End temporary Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`d` >= 20 +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t2`.`c` and `test`.`t2`.`d` >= 20 select a from t1 where a in (select c from t2 where d >= 20); a 2 @@ -1161,11 +1154,10 @@ insert into t2 values (1,10); explain extended select a from t1 where a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index it1a it1a 4 NULL 7 100.00 Using index -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 7 100.00 Using where; Start temporary +1 PRIMARY t1 ref it1a it1a 4 test.t2.c 2 14.29 Using index; End temporary Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`d` >= 20 +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t2`.`c` and `test`.`t2`.`d` >= 20 select a from t1 where a in (select c from t2 where d >= 20); a 2 @@ -1175,7 +1167,7 @@ a explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL it1a 4 NULL 7 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`c`)))) @@ -1187,7 +1179,7 @@ create index iab on t1(a, b); explain extended select a from t1 group by a having a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL it1a 4 NULL 7 100.00 Using index for group-by 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`>((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), (`test`.`t1`.`a` in on distinct_key where `test`.`t1`.`a` = ``.`c`)))) @@ -1199,7 +1191,7 @@ explain extended select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 index NULL iab 8 NULL 7 100.00 Using index +1 PRIMARY t1 range NULL iab 4 NULL 7 100.00 Using index for group-by 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: @@ -1216,7 +1208,7 @@ select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 100.00 Start temporary -1 PRIMARY t1 ref it1a,iab iab 4 test.t2.c 1 100.00 Using where; Using index; End temporary +1 PRIMARY t1 ref it1a,iab iab 4 test.t2.c 1 14.29 Using where; Using index; End temporary 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 @@ -1549,6 +1541,9 @@ COUNT(*) 2 set @@optimizer_switch= @local_optimizer_switch; DROP TABLE t1, t2; +# +# BUG#46548 IN-subqueries return 0 rows with materialization=on +# CREATE TABLE t1 ( pk int, a varchar(1), @@ -1558,15 +1553,19 @@ d varchar(4), PRIMARY KEY (pk) ); INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +insert into t1 select seq,'x','xxxx','xxxx','xxxx' from seq_10_to_40; CREATE TABLE t2 LIKE t1; INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +insert into t2 select -seq,'a','aaaa','aaaa','aaaa' from seq_1_to_20; +insert into t2 select seq,'b','bbbb','bbbb','bbbb' from seq_100_to_200; set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; SET @@optimizer_switch='semijoin=on,materialization=on'; EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 -1 PRIMARY t2 ALL PRIMARY NULL NULL NULL 2 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 33 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 123 Using where SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); pk 2 @@ -1885,7 +1884,7 @@ SELECT * FROM t1 WHERE a IN ( SELECT MIN(a) FROM t1 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 system a NULL NULL NULL 1 100.00 -1 PRIMARY system NULL NULL NULL NULL 1 100.00 +1 PRIMARY system NULL NULL NULL NULL 0 0.00 2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: Note 1003 /* select#1 */ select 8 AS `a` from dual where 1 @@ -1927,12 +1926,13 @@ DROP TABLE t1,t2; # create table t1 (a int, b int); insert into t1 values (7,5), (3,3), (5,4), (9,3); +insert into t1 select seq,seq from seq_100_to_200; create table t2 (a int, b int, index i_a(a)); insert into t2 values (4,2), (7,9), (7,4), (3,1), (5,3), (3,1), (9,4), (8,1); explain select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 +1 PRIMARY t1 ALL NULL NULL NULL NULL 105 1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 2 MATERIALIZED t2 ALL i_a NULL NULL NULL 8 Using where select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1); @@ -2228,8 +2228,8 @@ mysqltest1 EXPLAIN EXTENDED SELECT db FROM t1 WHERE db IN (SELECT SCHEMA_NAME FROM information_schema.schemata) ORDER BY db DESC; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY schemata ALL NULL NULL NULL NULL NULL NULL Start temporary; Using temporary; Using filesort -1 PRIMARY t1 eq_ref db db 764 information_schema.schemata.SCHEMA_NAME 1 100.00 Using where; Using index; End temporary +1 PRIMARY t1 index db db 764 NULL 4 100.00 Using index; Using temporary; Using filesort +1 PRIMARY schemata ALL NULL NULL NULL NULL NULL NULL Using where; FirstMatch(t1); Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`db` AS `db` from `test`.`t1` semi join (`information_schema`.`schemata`) where `test`.`t1`.`db` = `information_schema`.`schemata`.`SCHEMA_NAME` order by `test`.`t1`.`db` desc drop table t1; @@ -2261,8 +2261,10 @@ drop table t1; CREATE TABLE t1 ( pk INT, f1 INT NOT NULL, f2 VARCHAR(3), f3 INT NULL, PRIMARY KEY(pk)) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,1,'foo',8), (2,5,'bar',7); +create table t2 like t1; +insert into t2 select * from t1; SELECT sq1.f2 FROM t1 AS sq1 -WHERE EXISTS ( SELECT * FROM t1 AS sq2 +WHERE EXISTS ( SELECT * FROM t2 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); f2 foo @@ -2279,12 +2281,12 @@ id select_type table type possible_keys key key_len ref rows Extra # this checks the result set above set optimizer_switch= 'materialization=off,semijoin=off'; SELECT sq1.f2 FROM t1 AS sq1 -WHERE EXISTS ( SELECT * FROM t1 AS sq2 +WHERE EXISTS ( SELECT * FROM t2 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); f2 foo set optimizer_switch= @local_optimizer_switch; -DROP TABLE t1; +DROP TABLE t1,t2; # # MDEV-12145: IN subquery used in WHERE of EXISTS subquery # @@ -2307,8 +2309,8 @@ WHERE EXISTS ( SELECT * FROM t2, t3 WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where -2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch -2 DEPENDENT SUBQUERY t2 index i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch +2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index Warnings: Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 @@ -2345,7 +2347,7 @@ SELECT pk, f1, ( SELECT COUNT(*) FROM t2 WHERE t1.pk IN ( SELECT f2 FROM t2 ) ) AS sq FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; FirstMatch +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 @@ -2429,11 +2431,10 @@ WHERE t2.ugroup = t3_i.sys_id AND t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND t2.user = '86826bf03710200044e0bfc8bcbe5d79'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where +1 PRIMARY t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where; Start temporary +1 PRIMARY t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where +1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t3_i.sys_id 2 Using index condition; Using where; End temporary 1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index -2 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where -2 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where set statement optimizer_prune_level=1 for explain SELECT t1.assignment_group FROM t1, t3 WHERE t1.assignment_group = t3.sys_id AND @@ -2444,11 +2445,10 @@ WHERE t2.ugroup = t3_i.sys_id AND t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND t2.user = '86826bf03710200044e0bfc8bcbe5d79'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where +1 PRIMARY t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where; Start temporary +1 PRIMARY t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where +1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t3_i.sys_id 2 Using index condition; Using where; End temporary 1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index -3 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where -3 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where SELECT t1.assignment_group FROM t1, t3 WHERE t1.assignment_group = t3.sys_id AND @@ -2491,9 +2491,8 @@ alter table t1 add key(id); explain SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 -1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t1 index id id 4 NULL 9 Using index +1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); 1 1 @@ -2542,20 +2541,17 @@ drop procedure prepare_data; set @@optimizer_switch= @local_optimizer_switch; drop table t1,t2,t3; CREATE TABLE t1 ( id int NOT NULL, key(id)); -INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO t1 select seq from seq_11_to_39; CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL); -INSERT INTO t2 VALUES (11,11),(12,12),(13,13); +INSERT INTO t2 select seq,seq+1 from seq_11_to_50; CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2; explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 3 -1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t1 index id id 4 NULL 29 Using index +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 40 Using where SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); 1 -1 -1 -1 drop table t1,t2; drop view v1; # diff --git a/mysql-test/main/subselect_sj_mat.test b/mysql-test/main/subselect_sj_mat.test index 6a9c78adc52..4302fc10c81 100644 --- a/mysql-test/main/subselect_sj_mat.test +++ b/mysql-test/main/subselect_sj_mat.test @@ -4,6 +4,7 @@ # --source include/default_optimizer_switch.inc +--source include/have_sequence.inc set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; @@ -1174,9 +1175,9 @@ set @@optimizer_switch= @local_optimizer_switch; DROP TABLE t1, t2; -# -# BUG#46548 IN-subqueries return 0 rows with materialization=on -# +--echo # +--echo # BUG#46548 IN-subqueries return 0 rows with materialization=on +--echo # CREATE TABLE t1 ( pk int, a varchar(1), @@ -1186,9 +1187,12 @@ CREATE TABLE t1 ( PRIMARY KEY (pk) ); INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +insert into t1 select seq,'x','xxxx','xxxx','xxxx' from seq_10_to_40; CREATE TABLE t2 LIKE t1; INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +insert into t2 select -seq,'a','aaaa','aaaa','aaaa' from seq_1_to_20; +insert into t2 select seq,'b','bbbb','bbbb','bbbb' from seq_100_to_200; set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; @@ -1553,6 +1557,7 @@ DROP TABLE t1,t2; --echo # create table t1 (a int, b int); insert into t1 values (7,5), (3,3), (5,4), (9,3); +insert into t1 select seq,seq from seq_100_to_200; create table t2 (a int, b int, index i_a(a)); @@ -1883,9 +1888,11 @@ drop table t1; CREATE TABLE t1 ( pk INT, f1 INT NOT NULL, f2 VARCHAR(3), f3 INT NULL, PRIMARY KEY(pk)) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,1,'foo',8), (2,5,'bar',7); +create table t2 like t1; +insert into t2 select * from t1; SELECT sq1.f2 FROM t1 AS sq1 - WHERE EXISTS ( SELECT * FROM t1 AS sq2 + WHERE EXISTS ( SELECT * FROM t2 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); set @local_optimizer_switch= @@optimizer_switch; @@ -1899,12 +1906,12 @@ SELECT sq1.f2 FROM t1 AS sq1 --echo # this checks the result set above set optimizer_switch= 'materialization=off,semijoin=off'; SELECT sq1.f2 FROM t1 AS sq1 - WHERE EXISTS ( SELECT * FROM t1 AS sq2 + WHERE EXISTS ( SELECT * FROM t2 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); set optimizer_switch= @local_optimizer_switch; -DROP TABLE t1; +DROP TABLE t1,t2; --echo # --echo # MDEV-12145: IN subquery used in WHERE of EXISTS subquery @@ -2248,9 +2255,9 @@ set @@optimizer_switch= @local_optimizer_switch; drop table t1,t2,t3; CREATE TABLE t1 ( id int NOT NULL, key(id)); -INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO t1 select seq from seq_11_to_39; CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL); -INSERT INTO t2 VALUES (11,11),(12,12),(13,13); +INSERT INTO t2 select seq,seq+1 from seq_11_to_50; CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2; explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); diff --git a/mysql-test/main/subselect_sj_nonmerged.result b/mysql-test/main/subselect_sj_nonmerged.result index 99ce641da8e..2413ce3a557 100644 --- a/mysql-test/main/subselect_sj_nonmerged.result +++ b/mysql-test/main/subselect_sj_nonmerged.result @@ -67,8 +67,8 @@ insert into t4 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t0 A, t0 B; explain select * from t0, t4 where t4.b=t0.a and t4.a in (select max(t2.a) from t1, t2 group by t2.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where -1 PRIMARY ALL distinct_key NULL NULL NULL 5 Using join buffer (flat, BNL join) +1 PRIMARY ALL distinct_key NULL NULL NULL 5 +1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t4 eq_ref a a 10 .max(t2.a),test.t0.a 1 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using temporary 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join) diff --git a/mysql-test/main/type_blob.result b/mysql-test/main/type_blob.result index abde3db7fac..ccbbe5c9118 100644 --- a/mysql-test/main/type_blob.result +++ b/mysql-test/main/type_blob.result @@ -625,7 +625,7 @@ id txt 3 NULL explain select * from t1 where txt='Chevy' or txt is NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL txt_index NULL NULL NULL 6 Using where +1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 3 Using where explain select * from t1 FORCE INDEX (`txt_index`) where txt='Chevy' or txt is NULL; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 3 Using where @@ -690,18 +690,18 @@ id txt 2 Chevy select * from t1 where txt > 'Chevy'; id txt -4 Honda -5 Subaru -6 Honda 7 Ford +4 Honda +6 Honda +5 Subaru select * from t1 where txt >= 'Chevy'; id txt 1 Chevy 2 Chevy -4 Honda -5 Subaru -6 Honda 7 Ford +4 Honda +6 Honda +5 Subaru alter table t1 modify column txt blob; explain select * from t1 where txt='Chevy' or txt is NULL; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/type_datetime.result b/mysql-test/main/type_datetime.result index c4568e80ae6..96f3c568446 100644 --- a/mysql-test/main/type_datetime.result +++ b/mysql-test/main/type_datetime.result @@ -105,7 +105,7 @@ date numfacture expedition 0000-00-00 00:00:00 1212 0001-00-00 00:00:00 EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL expedition NULL NULL NULL 2 Using where +1 SIMPLE t1 ref expedition expedition 5 const 2 drop table t1; create table t1 (a datetime not null, b datetime not null); insert into t1 values (now(), now()); diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index aec4a5d09f2..1adf577e4f8 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -4213,10 +4213,10 @@ INSERT INTO t2 VALUES EXPLAIN EXTENDED SELECT t1.a,t2.c FROM t1,t2 WHERE t2.pk = t1.a AND t2.pk > 8; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 16 100.00 Using where -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 +1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 12 75.00 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 16 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`pk` = `test`.`t1`.`a` and `test`.`t1`.`a` > 8 +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`pk` and `test`.`t2`.`pk` > 8 FLUSH STATUS; SELECT t1.a,t2.c FROM t1,t2 WHERE t2.pk = t1.a AND t2.pk > 8; a c @@ -4225,22 +4225,34 @@ a c SHOW STATUS LIKE 'Handler_read_%'; Variable_name Value Handler_read_first 0 -Handler_read_key 1 +Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 -Handler_read_rnd_next 17 +Handler_read_rnd_next 30 +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +explain extended SELECT t1.a,t2.c FROM t1,t2 WHERE t2.pk = t1.a AND t2.pk > 8; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 16 12.50 Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`pk` = `test`.`t1`.`a` and `test`.`t1`.`a` > 8 CREATE VIEW v AS SELECT * FROM t2; EXPLAIN EXTENDED SELECT t1.a,v.c FROM t1,v WHERE v.pk = t1.a AND v.pk > 8; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 16 100.00 Using where -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 +1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 12 75.00 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 16 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`pk` = `test`.`t1`.`a` and `test`.`t1`.`a` > 8 +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`pk` and `test`.`t2`.`pk` > 8 FLUSH STATUS; SELECT t1.a,v.c FROM t1,v WHERE v.pk = t1.a AND v.pk > 8; a c @@ -4249,14 +4261,20 @@ a c SHOW STATUS LIKE 'Handler_read_%'; Variable_name Value Handler_read_first 0 -Handler_read_key 1 +Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 -Handler_read_rnd_next 17 +Handler_read_rnd_next 30 +set statement optimizer_where_cost=100 FOR explain extended SELECT t1.a,v.c FROM t1,v WHERE v.pk = t1.a AND v.pk > 8; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 16 100.00 Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`pk` = `test`.`t1`.`a` and `test`.`t1`.`a` > 8 DROP VIEW v; DROP TABLE t1, t2; # diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index c1efbbb5000..3b3d1124a09 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -4165,12 +4165,18 @@ FLUSH STATUS; SELECT t1.a,t2.c FROM t1,t2 WHERE t2.pk = t1.a AND t2.pk > 8; SHOW STATUS LIKE 'Handler_read_%'; +analyze table t1,t2; +explain extended SELECT t1.a,t2.c FROM t1,t2 WHERE t2.pk = t1.a AND t2.pk > 8; + CREATE VIEW v AS SELECT * FROM t2; EXPLAIN EXTENDED SELECT t1.a,v.c FROM t1,v WHERE v.pk = t1.a AND v.pk > 8; FLUSH STATUS; SELECT t1.a,v.c FROM t1,v WHERE v.pk = t1.a AND v.pk > 8; SHOW STATUS LIKE 'Handler_read_%'; + +set statement optimizer_where_cost=100 FOR explain extended SELECT t1.a,v.c FROM t1,v WHERE v.pk = t1.a AND v.pk > 8; + DROP VIEW v; DROP TABLE t1, t2; diff --git a/mysql-test/suite/archive/archive.result b/mysql-test/suite/archive/archive.result index 022b400fd97..0a6ec04fb31 100644 --- a/mysql-test/suite/archive/archive.result +++ b/mysql-test/suite/archive/archive.result @@ -12488,6 +12488,10 @@ SELECT b FROM t5 WHERE a =3; b in order to form a more pefect union foo this is mine to think about +explain +SELECT b FROM t5 WHERE a IN (32, 23, 5); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t5 ALL a NULL NULL NULL 11 Using where SELECT b FROM t5 WHERE a IN (32, 23, 5); b foo grok diff --git a/mysql-test/suite/archive/archive.test b/mysql-test/suite/archive/archive.test index b6920827005..df5f6503321 100644 --- a/mysql-test/suite/archive/archive.test +++ b/mysql-test/suite/archive/archive.test @@ -1445,8 +1445,9 @@ INSERT INTO t5 VALUES (NULL, "promote the general welfare"); SELECT * FROM t5; SELECT b FROM t5; SELECT b FROM t5 WHERE a =3; +explain +SELECT b FROM t5 WHERE a IN (32, 23, 5); SELECT b FROM t5 WHERE a IN (32, 23, 5); - #More blob tests diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index c88a3a9ac8d..be0d6aa7740 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -210,6 +210,19 @@ def information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA 10 NULL YES varc def information_schema KEY_COLUMN_USAGE TABLE_CATALOG 4 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) select NEVER NULL def information_schema KEY_COLUMN_USAGE TABLE_NAME 6 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL def information_schema KEY_COLUMN_USAGE TABLE_SCHEMA 5 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL +def information_schema OPTIMIZER_COSTS ENGINE 1 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_DISK_READ_COST 2 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_DISK_READ_RATIO 8 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_INDEX_BLOCK_COPY_COST 3 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_COMPARE_COST 4 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_COPY_COST 5 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_LOOKUP_COST 6 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_NEXT_FIND_COST 7 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROWID_COMPARE_COST 12 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROWID_COPY_COST 13 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_COPY_COST 9 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_LOOKUP_COST 10 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_NEXT_FIND_COST 11 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) select NEVER NULL def information_schema OPTIMIZER_TRACE INSUFFICIENT_PRIVILEGES 4 NULL NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) select NEVER NULL def information_schema OPTIMIZER_TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE 3 NULL NO int NULL NULL 10 0 NULL NULL NULL int(20) select NEVER NULL def information_schema OPTIMIZER_TRACE QUERY 1 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8mb3 utf8mb3_general_ci longtext select NEVER NULL @@ -761,6 +774,19 @@ NULL information_schema KEY_COLUMN_USAGE POSITION_IN_UNIQUE_CONSTRAINT bigint NU 3.0000 information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) 3.0000 information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) 3.0000 information_schema KEY_COLUMN_USAGE REFERENCED_COLUMN_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) +3.0000 information_schema OPTIMIZER_COSTS ENGINE varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_DISK_READ_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_INDEX_BLOCK_COPY_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_COMPARE_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_COPY_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_LOOKUP_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_NEXT_FIND_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_DISK_READ_RATIO decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_COPY_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_LOOKUP_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_NEXT_FIND_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROWID_COMPARE_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROWID_COPY_COST decimal NULL NULL NULL NULL decimal(9,6) 1.0000 information_schema OPTIMIZER_TRACE QUERY longtext 4294967295 4294967295 utf8mb3 utf8mb3_general_ci longtext 1.0000 information_schema OPTIMIZER_TRACE TRACE longtext 4294967295 4294967295 utf8mb3 utf8mb3_general_ci longtext NULL information_schema OPTIMIZER_TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE int NULL NULL NULL NULL int(20) diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result index bb12a0c38df..f9906d3f177 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result @@ -210,6 +210,19 @@ def information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA 10 NULL YES varc def information_schema KEY_COLUMN_USAGE TABLE_CATALOG 4 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) NEVER NULL def information_schema KEY_COLUMN_USAGE TABLE_NAME 6 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) NEVER NULL def information_schema KEY_COLUMN_USAGE TABLE_SCHEMA 5 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) NEVER NULL +def information_schema OPTIMIZER_COSTS ENGINE 1 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_DISK_READ_COST 2 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_DISK_READ_RATIO 8 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_INDEX_BLOCK_COPY_COST 3 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_COMPARE_COST 4 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_COPY_COST 5 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_LOOKUP_COST 6 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_NEXT_FIND_COST 7 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROWID_COMPARE_COST 12 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROWID_COPY_COST 13 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_COPY_COST 9 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_LOOKUP_COST 10 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL +def information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_NEXT_FIND_COST 11 NULL NO decimal NULL NULL 9 6 NULL NULL NULL decimal(9,6) NEVER NULL def information_schema OPTIMIZER_TRACE INSUFFICIENT_PRIVILEGES 4 NULL NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) NEVER NULL def information_schema OPTIMIZER_TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE 3 NULL NO int NULL NULL 10 0 NULL NULL NULL int(20) NEVER NULL def information_schema OPTIMIZER_TRACE QUERY 1 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8mb3 utf8mb3_general_ci longtext NEVER NULL @@ -761,6 +774,19 @@ NULL information_schema KEY_COLUMN_USAGE POSITION_IN_UNIQUE_CONSTRAINT bigint NU 3.0000 information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) 3.0000 information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) 3.0000 information_schema KEY_COLUMN_USAGE REFERENCED_COLUMN_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) +3.0000 information_schema OPTIMIZER_COSTS ENGINE varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_DISK_READ_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_INDEX_BLOCK_COPY_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_COMPARE_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_COPY_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_LOOKUP_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_KEY_NEXT_FIND_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_DISK_READ_RATIO decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_COPY_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_LOOKUP_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROW_NEXT_FIND_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROWID_COMPARE_COST decimal NULL NULL NULL NULL decimal(9,6) +NULL information_schema OPTIMIZER_COSTS OPTIMIZER_ROWID_COPY_COST decimal NULL NULL NULL NULL decimal(9,6) 1.0000 information_schema OPTIMIZER_TRACE QUERY longtext 4294967295 4294967295 utf8mb3 utf8mb3_general_ci longtext 1.0000 information_schema OPTIMIZER_TRACE TRACE longtext 4294967295 4294967295 utf8mb3 utf8mb3_general_ci longtext NULL information_schema OPTIMIZER_TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE int NULL NULL NULL NULL int(20) diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result index c18f733c86f..93ede4d08cc 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is.result @@ -514,6 +514,31 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME OPTIMIZER_COSTS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8mb3_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME OPTIMIZER_TRACE TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -1630,6 +1655,31 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME OPTIMIZER_COSTS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8mb3_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME OPTIMIZER_TRACE TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA diff --git a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result index c18f733c86f..93ede4d08cc 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result @@ -514,6 +514,31 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME OPTIMIZER_COSTS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8mb3_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME OPTIMIZER_TRACE TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -1630,6 +1655,31 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME OPTIMIZER_COSTS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8mb3_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME OPTIMIZER_TRACE TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA diff --git a/mysql-test/suite/galera/r/galera_many_indexes.result b/mysql-test/suite/galera/r/galera_many_indexes.result index 963d3552252..c0eabffd06d 100644 --- a/mysql-test/suite/galera/r/galera_many_indexes.result +++ b/mysql-test/suite/galera/r/galera_many_indexes.result @@ -74,7 +74,7 @@ LENGTH(f1) = 767 1 EXPLAIN SELECT COUNT(*) = 1 FROM t1 FORCE KEY (PRIMARY) WHERE f1 = REPEAT('a', 767); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY PRIMARY 769 const 1 Using index +1 SIMPLE t1 const PRIMARY PRIMARY 769 const 1 SELECT COUNT(*) = 1 FROM t1 FORCE KEY (PRIMARY) WHERE f1 = REPEAT('a', 767); COUNT(*) = 1 1 diff --git a/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result b/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result index 193ef064da8..bc3b5493dbd 100644 --- a/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result @@ -497,7 +497,7 @@ WHERE OUTR1.pk = 1 id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY OUTR1 const PRIMARY PRIMARY 4 const 1 1 PRIMARY INNR1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(OUTR1) -1 PRIMARY OUTR2 index NULL PRIMARY 4 NULL 2 Using index +1 PRIMARY OUTR2 ALL NULL NULL NULL NULL 2 DROP TABLE IF EXISTS b,bb,d; # # Bug#21216067 ASSERTION FAILED ROW_UPD_SEC_INDEX_ENTRY (INNOBASE/ROW/ROW0UPD.CC:2103) diff --git a/mysql-test/suite/gcol/r/gcol_select_innodb.result b/mysql-test/suite/gcol/r/gcol_select_innodb.result index 4bd1efd49cf..b57aceac9e0 100644 --- a/mysql-test/suite/gcol/r/gcol_select_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_select_innodb.result @@ -146,7 +146,7 @@ count(distinct c) 3 explain select count(distinct c) from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by (scanning) +1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by ### ### filesort & range-based utils ### @@ -699,11 +699,10 @@ WHERE t4.c1 < 'o' ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) +1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where; End temporary 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1 FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2 WHERE ( t3.pk IN @@ -754,11 +753,10 @@ WHERE t4.c1 < 'o' ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) +1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where; End temporary 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1 FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2 WHERE ( t3.pk IN @@ -810,11 +808,10 @@ WHERE t4.c1 < 'o' ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) +1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where; End temporary 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1 FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2 WHERE ( t3.pk IN @@ -874,11 +871,10 @@ WHERE t4.c1 < 'o' ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) +1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where; End temporary 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1, t3.i1 FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2 WHERE ( t3.pk IN @@ -930,8 +926,8 @@ WHERE t4.c1 < 'o' and t4.i1 < (t2.i1 + 1) ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) 1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where; End temporary; Using join buffer (flat, BNL join) SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1 diff --git a/mysql-test/suite/gcol/r/gcol_select_myisam.result b/mysql-test/suite/gcol/r/gcol_select_myisam.result index e368094b20b..070808fec4f 100644 --- a/mysql-test/suite/gcol/r/gcol_select_myisam.result +++ b/mysql-test/suite/gcol/r/gcol_select_myisam.result @@ -146,7 +146,7 @@ count(distinct c) 3 explain select count(distinct c) from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by (scanning) +1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by ### ### filesort & range-based utils ### @@ -1325,11 +1325,10 @@ WHERE t4.c1 < 'o' ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t3 eq_ref PRIMARY,v_idx PRIMARY 4 test.t4.i1 1 Using where +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) +1 PRIMARY t3 eq_ref PRIMARY,v_idx PRIMARY 4 test.t4.i1 1 Using where; End temporary 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1 FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2 WHERE ( t3.pk IN @@ -1381,11 +1380,10 @@ WHERE t4.c1 < 'o' ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t3 eq_ref PRIMARY,v_idx,v_idx2 PRIMARY 4 test.t4.i1 1 Using where +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) +1 PRIMARY t3 eq_ref PRIMARY,v_idx,v_idx2 PRIMARY 4 test.t4.i1 1 Using where; End temporary 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1 FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2 WHERE ( t3.pk IN @@ -1439,11 +1437,10 @@ WHERE t4.c1 < 'o' ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t3 eq_ref PRIMARY,v_idx2 PRIMARY 4 test.t4.i1 1 Using where +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) +1 PRIMARY t3 eq_ref PRIMARY,v_idx2 PRIMARY 4 test.t4.i1 1 Using where; End temporary 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1 FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2 WHERE ( t3.pk IN @@ -1506,11 +1503,10 @@ WHERE t4.c1 < 'o' ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY ALL distinct_key NULL NULL NULL 2 -1 PRIMARY t3 eq_ref PRIMARY,v_idx PRIMARY 4 test.t4.i1 1 Using where +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) +1 PRIMARY t3 eq_ref PRIMARY,v_idx PRIMARY 4 test.t4.i1 1 Using where; End temporary 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join) -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1, t3.i1 FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2 WHERE ( t3.pk IN @@ -1562,8 +1558,8 @@ WHERE t4.c1 < 'o' and t4.i1 < (t2.i1 + 1) ) AND t1.i1 <= t3.i2_key; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join) 1 PRIMARY t3 eq_ref PRIMARY,v_idx PRIMARY 4 test.t4.i1 1 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where; End temporary; Using join buffer (flat, BNL join) SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1 diff --git a/mysql-test/suite/heap/heap.result b/mysql-test/suite/heap/heap.result index 904bf2b2c42..bef3913dcb1 100644 --- a/mysql-test/suite/heap/heap.result +++ b/mysql-test/suite/heap/heap.result @@ -66,7 +66,7 @@ a alter table t1 engine=myisam; explain select * from t1 where a in (869751,736494,226312,802616); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index uniq_id uniq_id 4 NULL 5 Using where; Using index +1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index drop table t1; create table t1 (x int not null, y int not null, key x (x), unique y (y)) engine=heap; diff --git a/mysql-test/suite/heap/heap_btree.result b/mysql-test/suite/heap/heap_btree.result index a534e25565a..3eb618a0680 100644 --- a/mysql-test/suite/heap/heap_btree.result +++ b/mysql-test/suite/heap/heap_btree.result @@ -69,7 +69,7 @@ id select_type table type possible_keys key key_len ref rows Extra alter table t1 engine=myisam; explain select * from t1 where a in (869751,736494,226312,802616); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index uniq_id uniq_id 4 NULL 5 Using where; Using index +1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index insert into t1 values (1),(2),(3),(4),(5),(6); explain select * from t1 where a in (869751,736494,226312,802616); id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result index a76837b91a2..1ebed058aaf 100644 --- a/mysql-test/suite/innodb/r/innodb-index.result +++ b/mysql-test/suite/innodb/r/innodb-index.result @@ -853,10 +853,10 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK explain select * from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 explain select * from t1 order by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index +1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 drop table t1; SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET FOREIGN_KEY_CHECKS=0; diff --git a/mysql-test/suite/innodb/r/innodb-isolation.result b/mysql-test/suite/innodb/r/innodb-isolation.result index b6e512cc6de..8ff2c7f12e9 100644 --- a/mysql-test/suite/innodb/r/innodb-isolation.result +++ b/mysql-test/suite/innodb/r/innodb-isolation.result @@ -971,7 +971,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBQUERY t1 index NULL k2 5 NULL # Using index EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL # Using where; Using index +1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL # Using where 2 SUBQUERY t1 index NULL k2 5 NULL # Using index # # Make all indexes in t2 obsolete to the active repeatable read transaction diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index a36652bebbd..a4c1115bfd4 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -931,7 +931,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort explain select a from t1 order by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL # Using index +1 SIMPLE t1 index NULL PRIMARY 4 NULL # explain select b from t1 order by b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL b 4 NULL # Using index @@ -1379,7 +1379,7 @@ explain SELECT t2.id, t1.`label` FROM t2 INNER JOIN ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL id_object NULL NULL NULL 6 Using where -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id_object 1 Using index +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id_object 1 1 SIMPLE t1 ref id_object id_object 5 test.t1.id_object 1 SELECT t2.id, t1.`label` FROM t2 INNER JOIN (SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl @@ -1690,7 +1690,7 @@ count(*) 0 explain select count(*) from t1 where x > -16; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 2 Using where; Using index +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 Using where select count(*) from t1 where x > -16; count(*) 2 diff --git a/mysql-test/suite/innodb/r/innodb_bug30423.result b/mysql-test/suite/innodb/r/innodb_bug30423.result index 786041370ef..8f66cedad4d 100644 --- a/mysql-test/suite/innodb/r/innodb_bug30423.result +++ b/mysql-test/suite/innodb/r/innodb_bug30423.result @@ -54,7 +54,7 @@ ON orgs.org_id=sa_opportunities.org_id LEFT JOIN bug30243_2 contacts ON orgs.org_id=contacts.org_id ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE orgs index NULL org_id 4 NULL ROWS Using index +1 SIMPLE orgs ALL NULL NULL NULL NULL ROWS 1 SIMPLE sa_opportunities ref org_id org_id 5 test.orgs.org_id ROWS Using index 1 SIMPLE contacts ref contacts$org_id contacts$org_id 5 test.orgs.org_id ROWS Using index select @@innodb_stats_method; @@ -83,7 +83,7 @@ ON orgs.org_id=sa_opportunities.org_id LEFT JOIN bug30243_2 contacts ON orgs.org_id=contacts.org_id; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE orgs index NULL org_id 4 NULL ROWS Using index +1 SIMPLE orgs ALL NULL NULL NULL NULL ROWS 1 SIMPLE sa_opportunities ref org_id org_id 5 test.orgs.org_id ROWS Using index 1 SIMPLE contacts ref contacts$org_id contacts$org_id 5 test.orgs.org_id ROWS Using index SELECT COUNT(*) FROM table_bug30423 WHERE org_id IS NULL; diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index cc25045767a..31f6dafd082 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -346,10 +346,10 @@ insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d"); alter table t1 drop primary key, add primary key (f2, f1); explain select distinct f1 a, f1 b from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 5 NULL 4 Using index; Using temporary +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using temporary explain select distinct f1, f2 from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 5 NULL 4 Using index +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 drop table t1; CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20), INDEX (name)); @@ -396,7 +396,7 @@ test.t1 analyze status OK flush tables; EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref name name 22 const 2 Using where; Using index +1 SIMPLE t1 range name name 44 NULL 2 Using where; Using index for group-by SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; name dept rs5 cs10 @@ -405,7 +405,7 @@ DELETE FROM t1; # Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746). EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref name name 22 const # Using where; Using index +1 SIMPLE t1 range name name 44 NULL # Using where; Using index for group-by SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; name dept DROP TABLE t1; @@ -1629,7 +1629,7 @@ c b d 3 2 40 EXPLAIN SELECT c,b FROM t1 GROUP BY c,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL c 8 NULL 3 Using index +1 SIMPLE t1 index NULL c 8 NULL 3 SELECT c,b FROM t1 GROUP BY c,b; c b 1 1 @@ -1787,7 +1787,7 @@ INSERT INTO t1 VALUES (191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2); EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL idx NULL NULL NULL 4 Using where; Using filesort +1 SIMPLE t1 ref_or_null idx idx 5 const 3 Using index condition; Using filesort SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d; id type d 191 member 1 @@ -1797,13 +1797,16 @@ DROP TABLE t1; set @my_innodb_autoextend_increment=@@global.innodb_autoextend_increment; set global innodb_autoextend_increment=8; set global innodb_autoextend_increment=@my_innodb_autoextend_increment; +# +# Bug #37830: ORDER BY ASC/DESC - no difference +# CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b)) ENGINE=InnoDB; -INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1); +INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1), (100,2,2); INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1; EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range t1_b t1_b 5 NULL 8 Using where +1 SIMPLE t1 ref t1_b t1_b 5 const 8 Using where SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; a b c 8 1 1 @@ -2190,7 +2193,7 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 2 -2 DERIVED t1 ref c3,c2 c3 5 const 2 Using where +2 DERIVED t1 ref c3,c2 c2 10 const,const 1 DROP TABLE t1; CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3)) ENGINE=InnoDB; @@ -2204,7 +2207,7 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 2 -2 DERIVED t1 ref c3,c2 c3 9 const 2 Using where +2 DERIVED t1 ref c3,c2 c2 18 const,const 1 DROP TABLE t1; CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2), KEY (c3), KEY (c2, c3)) @@ -2219,7 +2222,7 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 2 -2 DERIVED t1 ref c3,c2 c3 7 const 2 Using where +2 DERIVED t1 ref c3,c2 c2 14 const,const 1 DROP TABLE t1; End of 5.1 tests # @@ -2342,24 +2345,24 @@ EXPLAIN SELECT c FROM bar WHERE b>2;; id 1 select_type SIMPLE table bar -type ALL +type range possible_keys b -key NULL -key_len NULL +key b +key_len 5 ref NULL -rows 6 -Extra Using where +rows 5 +Extra Using index condition EXPLAIN SELECT c FROM foo WHERE b>2;; id 1 select_type SIMPLE table foo -type ALL +type range possible_keys b -key NULL -key_len NULL +key b +key_len 5 ref NULL -rows 6 -Extra Using where +rows 5 +Extra Using index condition EXPLAIN SELECT c FROM foo2 WHERE b>2;; id 1 select_type SIMPLE @@ -2970,7 +2973,7 @@ NULL 75 EXPLAIN SELECT t1.id,t2.id FROM t2 LEFT JOIN t1 ON t1.id>=74 AND t1.id<=0 WHERE t2.id=75 AND t1.id IS NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY NULL NULL NULL 1 Impossible ON condition +1 SIMPLE t1 const PRIMARY NULL NULL NULL 0 Impossible ON condition 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where DROP TABLE t1,t2; # @@ -3066,7 +3069,7 @@ f1 f2 f3 f4 EXPLAIN SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE ORDER BY f1 DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range f2,f4 f4 1 NULL 22 Using where +1 SIMPLE t1 index f2,f4 PRIMARY 4 NULL 5 Using where DROP TABLE t1; # # Bug#54117 crash in thr_multi_unlock, temporary table @@ -3114,8 +3117,8 @@ select_type SIMPLE table t1 type index possible_keys NULL -key PRIMARY -key_len 8 +key b +key_len 13 ref NULL rows 3 Extra Using index @@ -3127,8 +3130,8 @@ select_type SIMPLE table t1 type index possible_keys NULL -key PRIMARY -key_len 8 +key b +key_len 18 ref NULL rows 3 Extra Using index @@ -3291,7 +3294,7 @@ SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t2 index NULL PRIMARY 4 NULL 1 Using index; FirstMatch(t1); Using join buffer (incremental, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 1 FirstMatch(t1); Using join buffer (incremental, BNL join) SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); b 1 diff --git a/mysql-test/suite/innodb/r/table_index_statistics.result b/mysql-test/suite/innodb/r/table_index_statistics.result index 286c5f9325f..ddb23afd346 100644 --- a/mysql-test/suite/innodb/r/table_index_statistics.result +++ b/mysql-test/suite/innodb/r/table_index_statistics.result @@ -14,13 +14,11 @@ ROWS_READ 10 SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1'; ROWS_READ -10 FLUSH TABLE_STATISTICS; SELECT ROWS_READ FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t1'; ROWS_READ SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1'; ROWS_READ -10 FLUSH INDEX_STATISTICS; SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1'; ROWS_READ @@ -32,7 +30,6 @@ ROWS_READ 10 SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1'; ROWS_READ -10 DROP TABLE t1; CREATE TABLE t2 (c1 INT UNSIGNED); ALTER TABLE t2 MODIFY c1 FLOAT; diff --git a/mysql-test/suite/innodb/r/temporary_table.result b/mysql-test/suite/innodb/r/temporary_table.result index 3800b0e6579..ffcee726f0d 100644 --- a/mysql-test/suite/innodb/r/temporary_table.result +++ b/mysql-test/suite/innodb/r/temporary_table.result @@ -28,7 +28,7 @@ id select_type table type possible_keys key key_len ref rows Extra alter table t1 add index sec_index(f); explain select * from t1 where f > 1.29999; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL sec_index NULL NULL NULL 5 Using where +1 SIMPLE t1 range sec_index sec_index 5 NULL 3 Using index condition select * from t1 where f > 1.29999; i f c 98 1.3 jaipur diff --git a/mysql-test/suite/innodb/r/temporary_table_optimization.result b/mysql-test/suite/innodb/r/temporary_table_optimization.result index c559268d29a..e2e9131b09d 100644 --- a/mysql-test/suite/innodb/r/temporary_table_optimization.result +++ b/mysql-test/suite/innodb/r/temporary_table_optimization.result @@ -128,7 +128,7 @@ ERROR 23000: Duplicate entry '2.5' for key 'sec_index' alter table t1 add index sec_index(t1_f); explain select * from t1 where t1_f >= 2.5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL sec_index NULL NULL NULL 4 Using where +1 SIMPLE t1 range sec_index sec_index 5 NULL 3 Using index condition select * from t1 where t1_f >= 2.5; t1_i t1_f 2 2.5 diff --git a/mysql-test/suite/innodb_fts/r/fulltext.result b/mysql-test/suite/innodb_fts/r/fulltext.result index cb615069067..2a6fb81f4bb 100644 --- a/mysql-test/suite/innodb_fts/r/fulltext.result +++ b/mysql-test/suite/innodb_fts/r/fulltext.result @@ -537,6 +537,9 @@ CREATE TABLE t2 (a int, b2 char(10), FULLTEXT KEY b2 (b2)) ENGINE = InnoDB; INSERT INTO t2 VALUES (1,'Scargill'); CREATE TABLE t3 (a int, b int) ENGINE = InnoDB; INSERT INTO t3 VALUES (1,1), (2,1); +SELECT * FROM t2 where MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE); +a b2 +1 Scargill # t2 should use full text index EXPLAIN SELECT count(*) FROM t1 WHERE @@ -546,8 +549,8 @@ WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE) ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 MATERIALIZED t2 fulltext b2 b2 0 1 Using where -2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 fulltext b2 b2 0 1 Using where +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where # should return 0 SELECT count(*) FROM t1 WHERE not exists( diff --git a/mysql-test/suite/innodb_fts/r/fulltext_misc.result b/mysql-test/suite/innodb_fts/r/fulltext_misc.result index a4b3faf2d42..f6087a01422 100644 --- a/mysql-test/suite/innodb_fts/r/fulltext_misc.result +++ b/mysql-test/suite/innodb_fts/r/fulltext_misc.result @@ -8,9 +8,9 @@ EXPLAIN SELECT 1 FROM t1 WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a ON (MATCH(t1.f1) AGAINST ("")) WHERE t1.f1 GROUP BY t1.f1)); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index -2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 1 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a ALL NULL NULL NULL NULL 1 PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE 1 > ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a @@ -18,14 +18,14 @@ PREPARE stmt FROM WHERE t1.f1 GROUP BY t1.f1))'; EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index -2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 1 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a ALL NULL NULL NULL NULL 1 EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index -2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 1 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a ALL NULL NULL NULL NULL 1 DEALLOCATE PREPARE stmt; PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 @@ -34,14 +34,14 @@ PREPARE stmt FROM WHERE t1.f1 GROUP BY t1.f1))'; EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index -2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 1 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a ALL NULL NULL NULL NULL 1 EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index -2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 1 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a ALL NULL NULL NULL NULL 1 DEALLOCATE PREPARE stmt; DROP TABLE t1; drop table if exists t1; diff --git a/mysql-test/suite/innodb_fts/t/fulltext.test b/mysql-test/suite/innodb_fts/t/fulltext.test index 3ddc1856b7f..d9bf14cbe6b 100644 --- a/mysql-test/suite/innodb_fts/t/fulltext.test +++ b/mysql-test/suite/innodb_fts/t/fulltext.test @@ -570,6 +570,8 @@ INSERT INTO t2 VALUES (1,'Scargill'); CREATE TABLE t3 (a int, b int) ENGINE = InnoDB; INSERT INTO t3 VALUES (1,1), (2,1); +SELECT * FROM t2 where MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE); + --echo # t2 should use full text index EXPLAIN SELECT count(*) FROM t1 WHERE diff --git a/mysql-test/suite/innodb_gis/r/create_spatial_index.result b/mysql-test/suite/innodb_gis/r/create_spatial_index.result index 86634acaa01..30b41b41e62 100644 --- a/mysql-test/suite/innodb_gis/r/create_spatial_index.result +++ b/mysql-test/suite/innodb_gis/r/create_spatial_index.result @@ -59,9 +59,12 @@ test.tab analyze status Engine-independent statistics collected test.tab analyze status OK # Test the MBRContains SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'); -EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; +EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1+0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 3 POLYGON((7 1,6 2,6 3,10 3,10 1,7 1)) @@ -75,7 +78,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 300 300,400 400)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300)) @@ -90,7 +93,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) '); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -105,7 +108,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('POLYGON((100 200,200 300,400 500,500 300,300 200,100 300,100 200))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300)) @@ -119,7 +122,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 10 10,30 30,40 40)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE ST_CRosses(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -149,15 +152,15 @@ c1 ST_Astext(c4) EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)') WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where EXPLAIN DELETE FROM tab WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where # Test the MBREquals SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 10 POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010)) @@ -187,7 +190,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 30 30,40 40,50 50)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -203,7 +206,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 2,4 5,5 5,7 1,0 0 ))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 3 POLYGON((7 1,6 2,6 3,10 3,10 1,7 1)) @@ -224,10 +227,10 @@ c1 ST_Astext(c4) EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)') WHERE MBROverlaps(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 8 Using where EXPLAIN DELETE FROM tab WHERE MBROverlaps(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 8 Using where # Test the ST_Touches SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 30,30 40,40 50,50 30,0 0))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1) ORDER BY c1; @@ -246,7 +249,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 100 100,200 200,300 300)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300)) @@ -261,7 +264,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 3 POLYGON((7 1,6 2,6 3,10 3,10 1,7 1)) @@ -275,7 +278,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) '); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -305,15 +308,15 @@ c1 ST_Astext(c4) EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)') WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where EXPLAIN DELETE FROM tab WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where # Test the MBREquals SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 10 POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010)) @@ -344,7 +347,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 30 30,40 40,50 50)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -360,7 +363,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 2,4 5,5 5,7 1,0 0 ))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 3 POLYGON((7 1,6 2,6 3,10 3,10 1,7 1)) @@ -397,7 +400,7 @@ EXPLAIN DELETE FROM tab WHERE MBRContains(tab.c4, @g1); END | CALL proc_wl6968(); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where id select_type table type possible_keys key key_len ref rows Extra @@ -578,7 +581,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('POLYGON((4 -2,5 -4,6 -5,7 -4,7 2,4 -2))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRDisjoint(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where; Using filesort +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where; Using filesort SELECT c1,ST_Astext(c4) FROM tab WHERE MBRDisjoint(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -593,10 +596,10 @@ c1 ST_Astext(c4) EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)') WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where EXPLAIN DELETE FROM tab WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where # Test the MBREquals SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; @@ -662,17 +665,17 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING(7 1,30 30,1010 3010,1010 2010,3010 3010,4010 4010,5010 5010 )'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where; Using filesort +1 SIMPLE tab range idx3 idx3 34 NULL 8 Using where; Using filesort SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 3 POLYGON((7 1,6 2,6 3,10 3,10 1,7 1)) EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)') WHERE MBROverlaps(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 8 Using where EXPLAIN DELETE FROM tab WHERE MBROverlaps(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 8 Using where # Test the ST_Touches SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 30,30 40,40 50,50 30,0 0))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1) ORDER BY c1; @@ -735,7 +738,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('POLYGON((4 -2,5 -4,6 -5,7 -4,7 2,4 -2))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRDisjoint(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where; Using filesort +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where; Using filesort SELECT c1,ST_Astext(c4) FROM tab WHERE MBRDisjoint(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -750,10 +753,10 @@ c1 ST_Astext(c4) EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)') WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where EXPLAIN DELETE FROM tab WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where # Test the MBREquals SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; @@ -939,7 +942,7 @@ test.tab analyze status OK SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 3 POLYGON((7 1,6 2,6 3,10 3,10 1,7 1)) @@ -953,7 +956,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 300 300,400 400)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300)) @@ -968,7 +971,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) '); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -983,7 +986,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('POLYGON((100 200,200 300,400 500,500 300,300 200,100 300,100 200))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300)) @@ -997,7 +1000,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 10 10,30 30,40 40)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE ST_CRosses(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -1027,15 +1030,15 @@ c1 ST_Astext(c4) EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)') WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where EXPLAIN DELETE FROM tab WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where # Test the MBREquals SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 10 POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010)) @@ -1066,7 +1069,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 30 30,40 40,50 50)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -1082,7 +1085,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 2,4 5,5 5,7 1,0 0 ))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 3 POLYGON((7 1,6 2,6 3,10 3,10 1,7 1)) @@ -1103,10 +1106,10 @@ c1 ST_Astext(c4) EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)') WHERE MBROverlaps(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 8 Using where EXPLAIN DELETE FROM tab WHERE MBROverlaps(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 8 Using where # Test the ST_Touches SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 30,30 40,40 50,50 30,0 0))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1) ORDER BY c1; @@ -1125,7 +1128,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 100 100,200 200,300 300)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300)) @@ -1140,7 +1143,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 3 POLYGON((7 1,6 2,6 3,10 3,10 1,7 1)) @@ -1154,7 +1157,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) '); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -1184,15 +1187,15 @@ c1 ST_Astext(c4) EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)') WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where EXPLAIN DELETE FROM tab WHERE MBRDisjoint(tab.c4, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab ALL idx3 NULL NULL NULL 10 Using where +1 SIMPLE tab range idx3 idx3 34 NULL 9 Using where # Test the MBREquals SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 10 POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010)) @@ -1223,7 +1226,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText('LINESTRING( 30 30,40 40,50 50)'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 1 POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) @@ -1239,7 +1242,7 @@ id select_type table type possible_keys key key_len ref rows Extra SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 2,4 5,5 5,7 1,0 0 ))'); EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort +1 SIMPLE tab index idx3 PRIMARY 4 NULL 10 Using where SELECT c1,ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1; c1 ST_Astext(c4) 3 POLYGON((7 1,6 2,6 3,10 3,10 1,7 1)) diff --git a/mysql-test/suite/innodb_gis/r/rtree.result b/mysql-test/suite/innodb_gis/r/rtree.result index 2fd39f9ca32..5b6ea14e228 100644 --- a/mysql-test/suite/innodb_gis/r/rtree.result +++ b/mysql-test/suite/innodb_gis/r/rtree.result @@ -11,11 +11,11 @@ test.t1 analyze status OK set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))'); explain select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL g NULL NULL NULL 5 Using where +1 SIMPLE t1 range g g 34 NULL 5 Using where select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1); ST_astext(t1.g) -POINT(1 1) POINT(1.5 1.5) +POINT(1 1) set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))'); delete from t1 where MBRWithin(t1.g, @g1); check table t1; @@ -61,9 +61,9 @@ name ST_AsText(square) small POLYGON((0 0,0 1,1 1,1 0,0 0)) SELECT name, ST_AsText(square) from t1 where MBRDisjoint(@p, square); name ST_AsText(square) +right3 POLYGON((3 0,3 2,5 2,5 0,3 0)) up3 POLYGON((0 3,0 5,2 5,2 3,0 3)) down3 POLYGON((0 -3,0 -1,2 -1,2 -3,0 -3)) -right3 POLYGON((3 0,3 2,5 2,5 0,3 0)) left3 POLYGON((-3 0,-3 2,-1 2,-1 0,-3 0)) SELECT name, ST_AsText(square) from t1 where MBREquals(@p, square); name ST_AsText(square) @@ -157,11 +157,11 @@ test.t1 analyze status OK set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))'); explain select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL g NULL NULL NULL 5 Using where +1 SIMPLE t1 range g g 34 NULL 5 Using where select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1); ST_astext(t1.g) -POINT(1 1) POINT(1.5 1.5) +POINT(1 1) set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))'); delete from t1 where MBRWithin(t1.g, @g1); check table t1; diff --git a/mysql-test/suite/innodb_gis/r/rtree_multi_pk.result b/mysql-test/suite/innodb_gis/r/rtree_multi_pk.result index 3e6464df997..bab710a5559 100644 --- a/mysql-test/suite/innodb_gis/r/rtree_multi_pk.result +++ b/mysql-test/suite/innodb_gis/r/rtree_multi_pk.result @@ -11,11 +11,11 @@ test.t1 analyze status OK set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))'); explain select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL g NULL NULL NULL 5 Using where +1 SIMPLE t1 range g g 34 NULL 5 Using where select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1); ST_astext(t1.g) -POINT(1 1) POINT(1.5 1.5) +POINT(1 1) set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))'); delete from t1 where MBRWithin(t1.g, @g1); check table t1; @@ -63,10 +63,10 @@ name ST_AsText(square) small POLYGON((0 0,0 1,1 1,1 0,0 0)) SELECT name, ST_AsText(square) from t1 where MBRDisjoint(@p, square); name ST_AsText(square) -up3 POLYGON((0 3,0 5,2 5,2 3,0 3)) down3 POLYGON((0 -3,0 -1,2 -1,2 -3,0 -3)) -right3 POLYGON((3 0,3 2,5 2,5 0,3 0)) left3 POLYGON((-3 0,-3 2,-1 2,-1 0,-3 0)) +right3 POLYGON((3 0,3 2,5 2,5 0,3 0)) +up3 POLYGON((0 3,0 5,2 5,2 3,0 3)) SELECT name, ST_AsText(square) from t1 where MBREquals(@p, square); name ST_AsText(square) SELECT name, ST_AsText(square) from t1 where MBRIntersects(@p, square); diff --git a/mysql-test/suite/innodb_gis/t/create_spatial_index.test b/mysql-test/suite/innodb_gis/t/create_spatial_index.test index cdf317503d1..178041d0414 100644 --- a/mysql-test/suite/innodb_gis/t/create_spatial_index.test +++ b/mysql-test/suite/innodb_gis/t/create_spatial_index.test @@ -97,6 +97,8 @@ ANALYZE TABLE tab; --echo # Test the MBRContains SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'); +# Show plan if we cannot use index order +EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1+0; EXPLAIN SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1; diff --git a/mysql-test/suite/innodb_gis/t/rtree_multi_pk.test b/mysql-test/suite/innodb_gis/t/rtree_multi_pk.test index f606e569376..567e16947b7 100644 --- a/mysql-test/suite/innodb_gis/t/rtree_multi_pk.test +++ b/mysql-test/suite/innodb_gis/t/rtree_multi_pk.test @@ -66,6 +66,7 @@ INSERT INTO t1 VALUES("left3", ST_GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 SET @p = ST_GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))'); SELECT name, ST_AsText(square) from t1 where MBRContains(@p, square); +--sorted_result SELECT name, ST_AsText(square) from t1 where MBRDisjoint(@p, square); SELECT name, ST_AsText(square) from t1 where MBREquals(@p, square); SELECT name, ST_AsText(square) from t1 where MBRIntersects(@p, square); diff --git a/mysql-test/suite/json/r/json_table_mysql.result b/mysql-test/suite/json/r/json_table_mysql.result index 2357d9d3cf0..cdca41b3a24 100644 --- a/mysql-test/suite/json/r/json_table_mysql.result +++ b/mysql-test/suite/json/r/json_table_mysql.result @@ -530,8 +530,7 @@ EXPLAIN SELECT * FROM t1 WHERE id IN (id INT PATH '$')) AS jt); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED jt ALL NULL NULL NULL NULL 40 Table function: json_table +1 PRIMARY jt ALL NULL NULL NULL NULL 40 Table function: json_table; Using where; FirstMatch(t1); Using join buffer (flat, BNL join) DROP TABLE t1; SELECT * FROM JSON_TABLE('"asdf"', '$' COLUMNS( tm TIME PATH '$', diff --git a/mysql-test/suite/maria/icp.result b/mysql-test/suite/maria/icp.result index 259078fb1ad..a421ba6d3ea 100644 --- a/mysql-test/suite/maria/icp.result +++ b/mysql-test/suite/maria/icp.result @@ -409,7 +409,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 ORDER BY c1 LIMIT 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,k1 PRIMARY 4 NULL 3 Using index condition; Using where; Rowid-ordered scan; Using filesort +1 SIMPLE t1 range PRIMARY,k1 k1 5 NULL 4 Using index condition; Using where DROP TABLE t1; # # @@ -431,8 +431,8 @@ SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL # Using where -2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL # Using index 2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func # Using index condition +2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL # Using index; Using join buffer (flat, BNL join) SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); pk i @@ -450,9 +450,10 @@ c1 INT NOT NULL, PRIMARY KEY (pk) ); INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +insert into t1 select seq,seq from seq_100_to_110; EXPLAIN SELECT pk, c1 FROM t1 WHERE (pk<3 or pk>3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 5 Using where +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 16 Using index condition; Rowid-ordered scan SET SESSION optimizer_switch='index_condition_pushdown=off'; SELECT pk, c1 FROM t1 WHERE (pk<3 or pk>3); pk c1 @@ -460,6 +461,17 @@ pk c1 2 7 4 3 5 1 +100 100 +101 101 +102 102 +103 103 +104 104 +105 105 +106 106 +107 107 +108 108 +109 109 +110 110 DROP TABLE t1; set optimizer_switch= @save_optimizer_switch; # @@ -677,7 +689,6 @@ DROP TABLE t1; # CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b)); INSERT INTO t1 VALUES (1,4,'Ill'); -insert into t1 select seq+100,5,seq from seq_1_to_100; CREATE TABLE t2 (a varchar(1024), KEY (a(512))); INSERT INTO t2 VALUES ('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w'); @@ -687,8 +698,8 @@ EXPLAIN SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL # Using where; Using filesort -1 SIMPLE t2 ref a a 515 test.t1.a # Using where +1 SIMPLE t1 system PRIMARY NULL NULL NULL # +1 SIMPLE t2 ref a a 515 const # Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; b c @@ -698,8 +709,8 @@ EXPLAIN SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY NULL NULL NULL # Using where; Using filesort -1 SIMPLE t2 ref a a 515 test.t1.a # Using where +1 SIMPLE t1 system PRIMARY NULL NULL NULL # +1 SIMPLE t2 ref a a 515 const # Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND (t1.b<0 OR t1.b>0) HAVING t1.c != 5 ORDER BY t1.c; b c @@ -811,6 +822,8 @@ test.t2 analyze status Engine-independent statistics collected test.t2 analyze status Table is already up to date SET @save_optimize_switch=@@optimizer_switch; SET optimizer_switch='materialization=on'; +set @save_optimizer_where_cost=@@optimizer_where_cost; +set @@optimizer_where_cost=1; EXPLAIN SELECT COUNT(*) FROM t1 AS t, t2 WHERE c = g @@ -834,6 +847,7 @@ OR a = 0 AND h < 'z' ); COUNT(*) 1478 SET optimizer_switch=@save_optimizer_switch; +set @@optimizer_where_cost=@save_optimizer_where_cost; DROP TABLE t1,t2; # check "Handler_pushed" status varuiables CREATE TABLE t1 ( diff --git a/mysql-test/suite/maria/mrr.result b/mysql-test/suite/maria/mrr.result index 066f1a50aab..326f3ca6a6c 100644 --- a/mysql-test/suite/maria/mrr.result +++ b/mysql-test/suite/maria/mrr.result @@ -364,9 +364,9 @@ EXPLAIN SELECT COUNT(t1.v) FROM t1, t2 IGNORE INDEX (idx), t3 IGNORE INDEX (idx) WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL idx 7 NULL 15 Using index -1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 16 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 25 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 16 Using index condition; Rowid-ordered scan +1 SIMPLE t1 index NULL idx 7 NULL 15 Using index; Using join buffer (flat, BNL join) +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 25 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) SELECT COUNT(t1.v) FROM t1, t2, t3 WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0; COUNT(t1.v) @@ -375,9 +375,9 @@ EXPLAIN SELECT COUNT(t1.v) FROM t1, t2, t3 WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL idx 7 NULL 15 Using index -1 SIMPLE t2 ALL PRIMARY,idx NULL NULL NULL 16 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 range PRIMARY,idx PRIMARY 4 NULL 16 Using index condition; Rowid-ordered scan 1 SIMPLE t3 ref PRIMARY,idx idx 3 test.t2.v 2 Using index condition; Using where +1 SIMPLE t1 index NULL idx 7 NULL 15 Using index; Using join buffer (flat, BNL join) set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3; # diff --git a/mysql-test/suite/parts/inc/partition_decimal.inc b/mysql-test/suite/parts/inc/partition_decimal.inc index 93e9e48c9c9..4ad2a000355 100644 --- a/mysql-test/suite/parts/inc/partition_decimal.inc +++ b/mysql-test/suite/parts/inc/partition_decimal.inc @@ -6,9 +6,11 @@ partition pa3 max_rows=30 min_rows=4, partition pa4 max_rows=40 min_rows=2); show create table t1; insert into t1 values (999999.9999), (-999999.9999), (123456.7899), (-123456.7899), (-1.5), (1), (0), (-1), (1.5), (1234.567), (-1234.567); +--sorted_result select * from t1; select * from t1 where a=1234.567; delete from t1 where a=1234.567; +--sorted_result select * from t1; drop table t1; @@ -16,9 +18,11 @@ eval create table t2 (a decimal(18,9) not null, primary key(a)) engine=$engine partition by key (a) partitions 10; show create table t2; insert into t2 values (999999999.999999999), (-999999999.999999999), (-1.5), (-1), (0), (1.5), (1234.567), (-1234.567); +--sorted_result select * from t2; select * from t2 where a=1234.567; delete from t2 where a=1234.567; +--sorted_result select * from t2; delete from t2; let $count=$maxrows; diff --git a/mysql-test/suite/parts/inc/partition_double.inc b/mysql-test/suite/parts/inc/partition_double.inc index 9e43887be09..dd2fd10090d 100644 --- a/mysql-test/suite/parts/inc/partition_double.inc +++ b/mysql-test/suite/parts/inc/partition_double.inc @@ -6,9 +6,11 @@ partition pa3 max_rows=30 min_rows=4, partition pa4 max_rows=40 min_rows=2); show create table t1; insert into t1 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208); +--sorted_result select * from t1; select * from t1 where a=1.5; delete from t1 where a=1.5; +--sorted_result select * from t1; drop table t1; @@ -16,9 +18,11 @@ eval create table t2 (a double not null, primary key(a)) engine=$engine partition by key (a) partitions 10; show create table t2; insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208); +--sorted_result select * from t2; select * from t2 where a=1234.567; delete from t2 where a=1234.567; +--sorted_result select * from t2; delete from t2; let $count=$maxrows; diff --git a/mysql-test/suite/parts/inc/partition_key_16col.inc b/mysql-test/suite/parts/inc/partition_key_16col.inc index 988dc4554ab..e7917451f1f 100644 --- a/mysql-test/suite/parts/inc/partition_key_16col.inc +++ b/mysql-test/suite/parts/inc/partition_key_16col.inc @@ -10,6 +10,7 @@ insert into t1 values ('1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127,'1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, 'liuugbzvdmrlti b itiortudirtfgtibm dfi'), ('1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124,'1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, 'd,f söierugsig msireg siug ei5ggth lrutluitgzeöjrtnb.rkjthuekuhzrkuthgjdnffjmbr'), ('2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, '2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, 'pib mdotkbm.m'); +--sorted_result select * from t1; select * from t1 where a<19851231; drop table t1; diff --git a/mysql-test/suite/parts/inc/partition_key_32col.inc b/mysql-test/suite/parts/inc/partition_key_32col.inc index 0acedefaa8e..880751db52a 100644 --- a/mysql-test/suite/parts/inc/partition_key_32col.inc +++ b/mysql-test/suite/parts/inc/partition_key_32col.inc @@ -28,6 +28,7 @@ insert into t1 values ('1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127,'1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, '1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, '1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, 'liuugbzvdmrlti b itiortudirtfgtibm dfi'), ('1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, '1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, '1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, '1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, 'd,f söierugsig msireg siug ei5ggth lrutluitgzeöjrtnb.rkjthuekuhzrkuthgjdnffjmbr'), ('2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, '2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, '2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, '2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, 'pib mdotkbm.m'); +--sorted_result select * from t1; select * from t1 where a<19851231; drop table t1; diff --git a/mysql-test/suite/parts/inc/partition_key_4col.inc b/mysql-test/suite/parts/inc/partition_key_4col.inc index a94ab581620..706c8addc7e 100644 --- a/mysql-test/suite/parts/inc/partition_key_4col.inc +++ b/mysql-test/suite/parts/inc/partition_key_4col.inc @@ -10,6 +10,7 @@ insert into t1 values ('1983-12-31', 'cdef', 'srtbvsr', 'w'), ('1980-10-14', 'fgbbd', 'dtzndtz', 'w'), ('2000-06-15', 'jukg','zikhuk','m'); +--sorted_result select * from t1; select * from t1 where a<19851231; drop table t1; diff --git a/mysql-test/suite/parts/inc/partition_key_8col.inc b/mysql-test/suite/parts/inc/partition_key_8col.inc index fcbab7c355d..1e49ee0b342 100644 --- a/mysql-test/suite/parts/inc/partition_key_8col.inc +++ b/mysql-test/suite/parts/inc/partition_key_8col.inc @@ -10,6 +10,7 @@ insert into t1 values ('1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, 'liuugbzvdmrlti b itiortudirtfgtibm dfi'), ('1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, 'd,f söierugsig msireg siug ei5ggth lrutluitgzeöjrtnb.rkjthuekuhzrkuthgjdnffjmbr'), ('2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, 'pib mdotkbm.m' ); +--sorted_result select * from t1; select * from t1 where a<19851231; drop table t1; diff --git a/mysql-test/suite/parts/inc/partition_time.inc b/mysql-test/suite/parts/inc/partition_time.inc index 674fe546a1f..5f9466ba64e 100644 --- a/mysql-test/suite/parts/inc/partition_time.inc +++ b/mysql-test/suite/parts/inc/partition_time.inc @@ -57,7 +57,7 @@ dec $count; commit; --enable_query_log select count(*) from t3; -select * from t3; +select a, second(a), if(second(a)<16,1,if(second(a)<31,2,if(second(a)<45,3,4))) from t3; drop table t3; eval create table t4 (a time not null, primary key(a)) engine=$engine diff --git a/mysql-test/suite/parts/inc/partition_timestamp.inc b/mysql-test/suite/parts/inc/partition_timestamp.inc index fb1bf391999..53334c13af0 100644 --- a/mysql-test/suite/parts/inc/partition_timestamp.inc +++ b/mysql-test/suite/parts/inc/partition_timestamp.inc @@ -6,9 +6,11 @@ partition pa3 max_rows=30 min_rows=4, partition pa4 max_rows=40 min_rows=2); show create table t1; insert into t1 values ('1975-01-01 21:21:21'), ('2020-12-31 12:10:30'), ('1980-10-14 03:03'), ('2000-06-15 23:59'); +--sorted_result select * from t1; select * from t1 where a=19801014030300; delete from t1 where a=19801014030300; +--sorted_result select * from t1; drop table t1; @@ -16,9 +18,11 @@ eval create table t2 (a timestamp not null DEFAULT CURRENT_TIMESTAMP ON UPDATE C partition by key (a) partitions 12; show create table t2; insert into t2 values ('1975-01-01 0:1:1'), ('2020-12-31 10:11:12'), ('1980-10-14 13:14:15'), ('2000-06-15 14:15:16'); +--sorted_result select * from t2; select * from t2 where a='1980-10-14 13:14:15'; delete from t2 where a='1980-10-14 13:14:15'; +--sorted_result select * from t2; delete from t2; let $count=59; @@ -33,6 +37,7 @@ dec $count; commit; --enable_query_log select count(*) from t2; +--sorted_result select * from t2; drop table t2; diff --git a/mysql-test/suite/parts/r/optimizer.result b/mysql-test/suite/parts/r/optimizer.result index 42d85dbbd39..95f0e561b0a 100644 --- a/mysql-test/suite/parts/r/optimizer.result +++ b/mysql-test/suite/parts/r/optimizer.result @@ -22,10 +22,10 @@ INSERT INTO t2 SELECT * FROM t1; # plans should be identical EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10,100) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index +1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index for group-by EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index +1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index for group-by FLUSH status; SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100) GROUP BY a; a MAX(b) @@ -33,7 +33,7 @@ a MAX(b) # Should be no more than 4 reads. SHOW status LIKE 'handler_read_key'; Variable_name Value -Handler_read_key 2 +Handler_read_key 4 FLUSH status; SELECT a, MAX(b) FROM t2 WHERE a IN (10, 100) GROUP BY a; a MAX(b) @@ -41,5 +41,5 @@ a MAX(b) # Should be no more than 4 reads. SHOW status LIKE 'handler_read_key'; Variable_name Value -Handler_read_key 2 +Handler_read_key 4 DROP TABLE t1, t2; diff --git a/mysql-test/suite/parts/r/partition_char_innodb.result b/mysql-test/suite/parts/r/partition_char_innodb.result index 3131ba58cdf2088d2cf4702af550ac360fbfcd10..da6f9bb6c276c9a0f475bb04beb8deea180711a8 100644 GIT binary patch delta 18 acmaFV#r&v?dBg6t%&uH6oA<3 select * from t1 union select * from t2; @@ -133,7 +133,7 @@ count(distinct c) 3 explain select count(distinct c) from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by (scanning) +1 SIMPLE t1 range NULL c 5 NULL 5 Using index for group-by ### ### filesort & range-based utils ### diff --git a/mysql-test/suite/versioning/r/cte.result b/mysql-test/suite/versioning/r/cte.result index 6ca9c238d45..53b0e7c3efb 100644 --- a/mysql-test/suite/versioning/r/cte.result +++ b/mysql-test/suite/versioning/r/cte.result @@ -140,7 +140,7 @@ where e.mgr = a.emp_id select name from emp where emp_id in (select emp_id from ancestors for system_time as of timestamp @ts_1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY emp ALL PRIMARY NULL NULL NULL 4 100.00 Using where -1 PRIMARY ref key0 key0 5 test.emp.emp_id 2 100.00 FirstMatch(emp) +1 PRIMARY ref key0 key0 5 test.emp.emp_id 2 50.00 FirstMatch(emp) 2 DERIVED e ALL NULL NULL NULL NULL 4 100.00 Using where 3 RECURSIVE UNION e ALL mgr-fk NULL NULL NULL 4 100.00 Using where 3 RECURSIVE UNION ref key0 key0 5 test.e.mgr 2 100.00 diff --git a/sql/handler.cc b/sql/handler.cc index 7a8e4d6b036..d409de8f298 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3593,6 +3593,9 @@ int handler::ha_rnd_next(uchar *buf) } table->status=result ? STATUS_NOT_FOUND: 0; + + DEBUG_SYNC(ha_thd(), "handler_rnd_next_end"); + DBUG_RETURN(result); } diff --git a/storage/connect/mysql-test/connect/r/index.result b/storage/connect/mysql-test/connect/r/index.result index 2197f9bcf1e..fdb44d06ee1 100644 --- a/storage/connect/mysql-test/connect/r/index.result +++ b/storage/connect/mysql-test/connect/r/index.result @@ -96,18 +96,25 @@ sexe genre 0 Inconnu 1 Masculin 2 Feminin -SELECT nom, prenom, genre FROM t1 NATURAL JOIN t2 LIMIT 10; +# t2 has only 3 rows. Force eq_ref by increasing table scan cost! +set @@optimizer_scan_setup_cost=10000; +explain SELECT nom, prenom, genre FROM t1 NATURAL JOIN t2 order by nom,prenom LIMIT 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4545 Using filesort +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.sexe 1 Using where +SELECT nom, prenom, genre FROM t1 NATURAL JOIN t2 order by nom,prenom LIMIT 10; nom prenom genre -NICOLAS ROGER Masculin -MOGADOR ALAIN Masculin -CHAUSSEE ERIC DENIS Masculin -MAILLOT GEORGES Masculin -BRUYERES JEAN MARC Masculin -LONES GERARD Masculin -CROISILLES DOMINIQUE Masculin -SEYSSAUD GERARD Masculin -QUINET OLIVIER Masculin -KOMITAS YVES Masculin +ABBADIE MONIQUE Feminin +ABBAYE ANNICK Feminin +ABBAYE GERALD Masculin +ABBE KATIA Feminin +ABBE MICHELE Feminin +ABBE SOPHIE Feminin +ABBEVILLE PASCAL Masculin +ABEBERRY PATRICK Masculin +ABEILLES RENE Masculin +ABEL JEAN PIERRE Masculin +set @@optimizer_scan_setup_cost=default; # # Another table # diff --git a/storage/connect/mysql-test/connect/t/index.test b/storage/connect/mysql-test/connect/t/index.test index 47bfbae7680..546d5184e9f 100644 --- a/storage/connect/mysql-test/connect/t/index.test +++ b/storage/connect/mysql-test/connect/t/index.test @@ -57,8 +57,11 @@ create table t2 genre CHAR(8) NOT NULL ) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='sexe.csv' SEP_CHAR=';' ENDING=2; SELECT * FROM t2; -SELECT nom, prenom, genre FROM t1 NATURAL JOIN t2 LIMIT 10; - +--echo # t2 has only 3 rows. Force eq_ref by increasing table scan cost! +set @@optimizer_scan_setup_cost=10000; +explain SELECT nom, prenom, genre FROM t1 NATURAL JOIN t2 order by nom,prenom LIMIT 10; +SELECT nom, prenom, genre FROM t1 NATURAL JOIN t2 order by nom,prenom LIMIT 10; +set @@optimizer_scan_setup_cost=default; --echo # --echo # Another table --echo # diff --git a/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_index_not_equal.result b/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_index_not_equal.result index 199edf9d758..837ca2b6381 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_index_not_equal.result +++ b/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_index_not_equal.result @@ -9,10 +9,13 @@ INSERT INTO users (age) VALUES (28); INSERT INTO users (age) VALUES (29); INSERT INTO users (age) VALUES (29); INSERT INTO users (age) VALUES (29); +explain SELECT COUNT(*) FROM users WHERE age <> 29; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE users range age age 5 NULL 4 Using where; Using index SELECT COUNT(*) FROM users WHERE age <> 29; COUNT(*) 2 SHOW STATUS LIKE 'mroonga_count_skip'; Variable_name Value -Mroonga_count_skip 0 +Mroonga_count_skip 2 DROP TABLE users; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/optimization_count_skip_index_not_equal.test b/storage/mroonga/mysql-test/mroonga/storage/t/optimization_count_skip_index_not_equal.test index 3948d218a69..7e6cf5f510b 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/optimization_count_skip_index_not_equal.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/optimization_count_skip_index_not_equal.test @@ -33,6 +33,7 @@ INSERT INTO users (age) VALUES (29); INSERT INTO users (age) VALUES (29); INSERT INTO users (age) VALUES (29); +explain SELECT COUNT(*) FROM users WHERE age <> 29; SELECT COUNT(*) FROM users WHERE age <> 29; SHOW STATUS LIKE 'mroonga_count_skip'; diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/r/geometry_contains.result b/storage/mroonga/mysql-test/mroonga/wrapper/r/geometry_contains.result index 550554eac8c..6dd6dd25f3f 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/r/geometry_contains.result +++ b/storage/mroonga/mysql-test/mroonga/wrapper/r/geometry_contains.result @@ -154,7 +154,7 @@ id name location_text select id, name, ST_AsText(location) as location_text from shops where MBRContains(ST_GeomFromText('LineString(139.7727 35.6684, 139.7038 35.7121)'), location); id name location_text +26 kazuya POINT(139.760895 35.673508) 14 tetsuji POINT(139.76857 35.680912) 19 daruma POINT(139.770599 35.681461) -26 kazuya POINT(139.760895 35.673508) drop table shops; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result index 730e12d02f6..6645a33e356 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result @@ -39,8 +39,8 @@ a varchar(10) NOT NULL, e int(11) DEFAULT 0, KEY (a) ) ENGINE=ROCKSDB DEFAULT CHARSET=utf8; -insert into t1 values (1,1,1),(2,2,2); -explain select a from t1 where a <'zzz'; +insert into t1 values (1,"a",1),(2,"b",2),(3,"c",2); +explain select a from t1 where a <'b'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 32 NULL # Using where CREATE TABLE t2( diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result index 989d28e773d..ad20f37fb3d 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result @@ -280,8 +280,8 @@ j EXPLAIN SELECT * FROM t10, t11 WHERE i=j; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t10 index PRIMARY PRIMARY 4 NULL # Using index -1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t10.i # Using index +1 SIMPLE t11 index PRIMARY PRIMARY 4 NULL # Using index +1 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t11.j # Using index SELECT * FROM t10, t11 WHERE i=j; i j 1 1 diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result index 3c9c30bb617..39413ea5987 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result @@ -45,7 +45,7 @@ t1 1 v16 1 v16 A 500 NULL NULL YES LSMTREE NO INSERT INTO t1 (c,c20,v16,v128,pk) VALUES ('a','char1','varchar1a','varchar1b','1'),('a','char2','varchar2a','varchar2b','2'),('b','char3','varchar1a','varchar1b','3'),('c','char4','varchar3a','varchar3b','4'); EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 WHERE v16 LIKE 'varchar%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v16 v16 19 NULL # Using where; Using index +1 SIMPLE t1 index v16 v16 19 NULL # Using where; Using index SELECT SUBSTRING(v16,7,3) FROM t1 WHERE v16 LIKE 'varchar%'; SUBSTRING(v16,7,3) r1a diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_date_time_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_date_time_indexes.result index bd40e32f94d..5e89648648d 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/type_date_time_indexes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/type_date_time_indexes.result @@ -62,7 +62,7 @@ INSERT INTO t1 (d,dt,ts,t,y,pk) VALUES (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),'12:05:00'); EXPLAIN SELECT ts FROM t1 WHERE ts > NOW(); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range ts ts 5 NULL # Using where; Using index +1 SIMPLE t1 index ts ts 5 NULL # Using where; Using index SELECT ts FROM t1 WHERE ts > NOW(); ts EXPLAIN SELECT ts FROM t1 USE INDEX () WHERE ts > NOW(); diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_enum_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_enum_indexes.result index b0bcfd7075c..011fa0894ec 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/type_enum_indexes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/type_enum_indexes.result @@ -49,7 +49,7 @@ t1 0 PRIMARY 1 pk A 1000 NULL NULL LSMTREE NO t1 1 b 1 b A 500 NULL NULL YES LSMTREE NO EXPLAIN SELECT DISTINCT b FROM t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 2 NULL # +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using temporary SELECT DISTINCT b FROM t1; b test1 diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result index 89dc65e56f8..a98f90f28da 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result @@ -114,7 +114,7 @@ INSERT INTO t1 (f,r,d,dp,pk) VALUES (4644,1422.22,466664.999,0.5,5); EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL d 9 NULL # Using index for group-by +1 SIMPLE t1 index NULL d 9 NULL # Using index SELECT DISTINCT d FROM t1 ORDER BY d; d -1 @@ -177,7 +177,7 @@ INSERT INTO t1 (f,r,d,dp,pk) VALUES (1.2345,0,0,0,6); EXPLAIN SELECT DISTINCT f FROM t1 ORDER BY f; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL f 5 NULL # Using index for group-by +1 SIMPLE t1 index NULL f 5 NULL # Using index SELECT DISTINCT f FROM t1 ORDER BY f; f -1 diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test index 99d4e2d117c..da4ac350654 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test @@ -37,9 +37,9 @@ CREATE TABLE t1( e int(11) DEFAULT 0, KEY (a) ) ENGINE=ROCKSDB DEFAULT CHARSET=utf8; -insert into t1 values (1,1,1),(2,2,2); +insert into t1 values (1,"a",1),(2,"b",2),(3,"c",2); --replace_column 9 # -explain select a from t1 where a <'zzz'; +explain select a from t1 where a <'b'; CREATE TABLE t2( pk int, diff --git a/storage/sequence/mysql-test/sequence/group_by.result b/storage/sequence/mysql-test/sequence/group_by.result index bcda2ba5c76..7c098de9afd 100644 --- a/storage/sequence/mysql-test/sequence/group_by.result +++ b/storage/sequence/mysql-test/sequence/group_by.result @@ -86,7 +86,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL PRIMARY 8 NULL 8 Using index; Using join buffer (flat, BNL join) explain select count(*) from seq_1_to_15_step_2 where seq > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE seq_1_to_15_step_2 index PRIMARY PRIMARY 8 NULL 8 Using where; Using index +1 SIMPLE seq_1_to_15_step_2 range PRIMARY PRIMARY 8 NULL 8 Using where; Using index explain select count(*) from seq_1_to_15_step_2 group by mod(seq,2); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE seq_1_to_15_step_2 index NULL PRIMARY 8 NULL 8 Using index; Using temporary; Using filesort diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result index 7a9c58e6f36..789478457d9 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result @@ -72,8 +72,11 @@ connection child2_1; SET NAMES utf8; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select `a`,`b` from `auto_test_remote`.`ta_r2` order by `a`,`b` -select `a`,`b` from `auto_test_remote`.`ta_r3` order by `a`,`b` +select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 11 order by `b` +select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 12 order by `b` +select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 13 order by `b` +select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 14 order by `b` +select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 15 order by `b` SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, c FROM ta_r2 ORDER BY a ; SELECT a, b, c FROM ta_r3 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result index 89a07bf64e6..62e1b2e64b2 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result +++ b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result @@ -57,6 +57,10 @@ TRUNCATE TABLE mysql.general_log; connection child2_2; TRUNCATE TABLE mysql.general_log; connection master_1; +explain SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE a index PRIMARY PRIMARY 4 NULL 2 Using index +1 SIMPLE b eq_ref PRIMARY PRIMARY 4 auto_test_local.a.pkey 1 Using index SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_22246.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_22246.test index 9e58bc1a836..be993647bb9 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_22246.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_22246.test @@ -64,6 +64,7 @@ TRUNCATE TABLE mysql.general_log; --connection master_1 SELECT * FROM tbl_a; +--sorted_result SELECT * FROM tbl_a WHERE id <0 || id >0; --connection child2_1 diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test index 01fa0cb5128..c878a738c53 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test @@ -74,6 +74,7 @@ TRUNCATE TABLE mysql.general_log; TRUNCATE TABLE mysql.general_log; --connection master_1 +explain SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result index ff4f211faf5..b2c4a209016 100644 --- a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result @@ -87,7 +87,7 @@ NULL NULL NULL 3 connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t1.`c` = t2.`c`) and (t0.`a` = t1.`a`) and (t3.`b` is not null) and (t1.`a` is not null)) where 1 order by t3.`a` desc +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null) and (t3.`b` is not null)) where 1 order by t3.`a` desc SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result index 840328508fa..9a2f1882b94 100644 --- a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result @@ -87,7 +87,7 @@ NULL c 2000-01-03 00:00:00 3 connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t1.`c` = t2.`c`) and (t3.`b` is not null)) where 1 order by t3.`a` desc +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t3.`b` is not null)) where 1 order by t3.`a` desc SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') From 5bf2421eed893669cf7eccb815c974b0cca36821 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 21 Nov 2022 17:28:43 +0300 Subject: [PATCH 063/123] MDEV-30059: Optimizer Trace: plan_prefix should be a comma-separated-list --- mysql-test/main/opt_trace.result | 826 ++++++------------ mysql-test/main/opt_trace_index_merge.result | 15 +- .../main/opt_trace_index_merge_innodb.result | 4 +- mysql-test/main/opt_trace_security.result | 8 +- mysql-test/main/opt_trace_selectivity.result | 12 +- mysql-test/main/range_notembedded.result | 1 - sql/opt_trace.cc | 43 +- sql/opt_trace.h | 3 +- sql/sql_select.cc | 6 +- 9 files changed, 298 insertions(+), 620 deletions(-) diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 35cae556d92..158df0b1e9a 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -127,7 +127,7 @@ select * from v1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -158,7 +158,7 @@ select * from v1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 1, "cost_for_plan": 0.01034841 @@ -295,7 +295,7 @@ select * from (select * from t1 where t1.a=1)q { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -326,7 +326,7 @@ select * from (select * from t1 where t1.a=1)q { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 1, "cost_for_plan": 0.01034841 @@ -468,7 +468,7 @@ select * from v2 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -500,7 +500,7 @@ select * from v2 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 1, "cost_for_plan": 0.01034841, @@ -558,7 +558,7 @@ select * from v2 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -589,7 +589,7 @@ select * from v2 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "", "rows_for_plan": 2, "cost_for_plan": 0.012418701 @@ -712,7 +712,7 @@ explain select * from v2 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -743,7 +743,7 @@ explain select * from v2 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t2", "rows_for_plan": 10, "cost_for_plan": 0.01159965 @@ -845,7 +845,7 @@ explain select * from v1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -877,7 +877,7 @@ explain select * from v1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 10, "cost_for_plan": 0.01159965, @@ -929,7 +929,7 @@ explain select * from v1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -960,7 +960,7 @@ explain select * from v1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "", "rows_for_plan": 10, "cost_for_plan": 0.012757506 @@ -1119,7 +1119,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -1176,13 +1176,13 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 100, "cost_for_plan": 0.0256761, "rest_of_plan": [ { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "get_costs_for_tables": [ { "best_access_path": { @@ -1222,7 +1222,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { ] }, { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "table": "t2", "rows_for_plan": 100, "cost_for_plan": 0.1987835 @@ -1230,13 +1230,13 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t2", "rows_for_plan": 100, "cost_for_plan": 0.0256761, "rest_of_plan": [ { - "plan_prefix": ["t2"], + "plan_prefix": "t2", "get_costs_for_tables": [ { "best_access_path": { @@ -1276,7 +1276,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { ] }, { - "plan_prefix": ["t2"], + "plan_prefix": "t2", "table": "t1", "rows_for_plan": 100, "cost_for_plan": 0.1987835, @@ -1440,7 +1440,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -1470,7 +1470,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 5, "cost_for_plan": 0.004191135 @@ -1649,7 +1649,7 @@ set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 wher { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -1681,7 +1681,7 @@ set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 wher ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 0.571428573, "cost_for_plan": 0.001758432, @@ -1889,7 +1889,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -1920,7 +1920,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 9, "cost_for_plan": 0.005620843, @@ -2092,7 +2092,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -2123,7 +2123,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 9, "cost_for_plan": 0.005620843, @@ -2380,7 +2380,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -2423,7 +2423,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 41, "cost_for_plan": 0.051288586 @@ -2662,7 +2662,7 @@ select t1.a from t1 left join t2 on t1.a=t2.a { { "considered_execution_plans": [ { - "plan_prefix": ["t2"], + "plan_prefix": "t2", "get_costs_for_tables": [ { "best_access_path": { @@ -2693,7 +2693,7 @@ select t1.a from t1 left join t2 on t1.a=t2.a { ] }, { - "plan_prefix": ["t2"], + "plan_prefix": "t2", "table": "t1", "rows_for_plan": 4, "cost_for_plan": 0.01066122 @@ -2820,7 +2820,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -2851,13 +2851,13 @@ explain select * from t1 left join t2 on t2.a=t1.a { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 4, "cost_for_plan": 0.01066122, "rest_of_plan": [ { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "get_costs_for_tables": [ { "best_access_path": { @@ -2891,7 +2891,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { ] }, { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "table": "t2", "rows_for_plan": 4, "cost_for_plan": 0.017782124 @@ -3061,7 +3061,7 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and { "considered_execution_plans": [ { - "plan_prefix": ["t3", "t2"], + "plan_prefix": "t3,t2", "get_costs_for_tables": [ { "best_access_path": { @@ -3092,7 +3092,7 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and ] }, { - "plan_prefix": ["t3", "t2"], + "plan_prefix": "t3,t2", "table": "t1", "rows_for_plan": 4, "cost_for_plan": 0.01066122 @@ -3281,7 +3281,7 @@ explain extended select * from t1 where a in (select p from t2) { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -3312,7 +3312,7 @@ explain extended select * from t1 where a in (select p from t2) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t2", "rows_for_plan": 101, "cost_for_plan": 0.025832505 @@ -3325,7 +3325,7 @@ explain extended select * from t1 where a in (select p from t2) { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -3382,14 +3382,14 @@ explain extended select * from t1 where a in (select p from t2) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 4, "cost_for_plan": 0.01066122, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "get_costs_for_tables": [ { "best_access_path": { @@ -3420,7 +3420,7 @@ explain extended select * from t1 where a in (select p from t2) { ] }, { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "table": "t2", "rows_for_plan": 404, "cost_for_plan": 0.074255053, @@ -3457,7 +3457,7 @@ explain extended select * from t1 where a in (select p from t2) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t2", "rows_for_plan": 101, "cost_for_plan": 0.025832505, @@ -3819,7 +3819,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -3871,7 +3871,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 1, "cost_for_plan": 0.000838227 @@ -3986,7 +3986,7 @@ select f1(a) from t1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -4017,7 +4017,7 @@ select f1(a) from t1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 4, "cost_for_plan": 0.01066122 @@ -4100,7 +4100,7 @@ select f2(a) from t1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -4131,7 +4131,7 @@ select f2(a) from t1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 4, "cost_for_plan": 0.01066122 @@ -4499,7 +4499,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -4556,13 +4556,13 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t0", "rows_for_plan": 3, "cost_for_plan": 0.001664909, "rest_of_plan": [ { - "plan_prefix": ["t0"], + "plan_prefix": "t0", "get_costs_for_tables": [ { "best_access_path": { @@ -4598,7 +4598,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ] }, { - "plan_prefix": ["t0"], + "plan_prefix": "t0", "table": "t1", "rows_for_plan": 3, "cost_for_plan": 0.00376999 @@ -4606,13 +4606,13 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 3, "cost_for_plan": 0.001664909, "rest_of_plan": [ { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "get_costs_for_tables": [ { "best_access_path": { @@ -4649,7 +4649,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ] }, { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "table": "t0", "rows_for_plan": 6, "cost_for_plan": 0.0041848, @@ -4782,7 +4782,7 @@ explain select * from (select rand() from t1)q { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -4813,7 +4813,7 @@ explain select * from (select rand() from t1)q { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 3, "cost_for_plan": 0.010504815 @@ -4864,7 +4864,7 @@ explain select * from (select rand() from t1)q { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -4895,7 +4895,7 @@ explain select * from (select rand() from t1)q { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "", "rows_for_plan": 3, "cost_for_plan": 0.012461052 @@ -5090,7 +5090,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -5147,13 +5147,13 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_1", "rows_for_plan": 3, "cost_for_plan": 0.010504815, "rest_of_plan": [ { - "plan_prefix": ["t_inner_1"], + "plan_prefix": "t_inner_1", "get_costs_for_tables": [ { "best_access_path": { @@ -5184,7 +5184,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ] }, { - "plan_prefix": ["t_inner_1"], + "plan_prefix": "t_inner_1", "table": "t_inner_2", "rows_for_plan": 9, "cost_for_plan": 0.022028022 @@ -5192,7 +5192,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_2", "rows_for_plan": 3, "cost_for_plan": 0.010504815, @@ -5206,7 +5206,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -5289,14 +5289,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 3, "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "get_costs_for_tables": [ { "best_access_path": { @@ -5353,14 +5353,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ] }, { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "table": "t_inner_1", "rows_for_plan": 9, "cost_for_plan": 0.022028022, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t1", "t_inner_1"], + "plan_prefix": "t1,t_inner_1", "get_costs_for_tables": [ { "best_access_path": { @@ -5391,7 +5391,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ] }, { - "plan_prefix": ["t1", "t_inner_1"], + "plan_prefix": "t1,t_inner_1", "table": "t_inner_2", "rows_for_plan": 27, "cost_for_plan": 0.037231395, @@ -5428,7 +5428,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ] }, { - "plan_prefix": ["t1"], + "plan_prefix": "t1", "table": "t_inner_2", "rows_for_plan": 9, "cost_for_plan": 0.022028022, @@ -5438,7 +5438,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_1", "rows_for_plan": 3, "cost_for_plan": 0.010504815, @@ -5446,7 +5446,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "pruned_by_heuristic": true }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_2", "rows_for_plan": 3, "cost_for_plan": 0.010504815, @@ -5752,7 +5752,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -5913,14 +5913,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_outer_1", "rows_for_plan": 3, "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "get_costs_for_tables": [ { "best_access_path": { @@ -6055,14 +6055,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_outer_2", "rows_for_plan": 27, "cost_for_plan": 0.02463804, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -6171,14 +6171,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "table": "t_inner_1", "rows_for_plan": 81, "cost_for_plan": 0.049238529, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1", "get_costs_for_tables": [ { "best_access_path": { @@ -6261,7 +6261,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1", "table": "t_inner_2", "rows_for_plan": 729, "cost_for_plan": 0.222053862, @@ -6291,12 +6291,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "sj_filtered": 3.703703704, "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2", "get_costs_for_tables": [ { "best_access_path": { @@ -6353,25 +6348,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2", "table": "t_inner_4", "rows_for_plan": 81, "cost_for_plan": 0.403207963, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -6402,13 +6386,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2,t_inner_4", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.664765924, @@ -6440,12 +6418,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2", "table": "t_inner_3", "rows_for_plan": 243, "cost_for_plan": 0.448771561, @@ -6455,19 +6428,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1", "table": "t_inner_4", "rows_for_plan": 243, "cost_for_plan": 0.116820804, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -6524,25 +6492,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_4", "table": "t_inner_2", "rows_for_plan": 2187, "cost_for_plan": 0.745494255, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_4", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_4,t_inner_2", "get_costs_for_tables": [ { "best_access_path": { @@ -6573,13 +6530,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_4", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_4,t_inner_2", "table": "t_inner_3", "rows_for_plan": 19683, "cost_for_plan": 7.510034832, @@ -6614,12 +6565,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_4", "table": "t_inner_3", "rows_for_plan": 2187, "cost_for_plan": 0.745494255, @@ -6629,7 +6575,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.222053862, @@ -6639,7 +6585,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "table": "t_inner_2", "rows_for_plan": 243, "cost_for_plan": 0.075081543, @@ -6647,7 +6593,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "table": "t_inner_4", "rows_for_plan": 81, "cost_for_plan": 0.049238529, @@ -6655,7 +6601,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "table": "t_inner_3", "rows_for_plan": 243, "cost_for_plan": 0.075081543, @@ -6665,14 +6611,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_inner_1", "rows_for_plan": 9, "cost_for_plan": 0.022028022, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "get_costs_for_tables": [ { "best_access_path": { @@ -6781,14 +6727,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "table": "t_outer_2", "rows_for_plan": 81, "cost_for_plan": 0.046471353, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -6871,7 +6817,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2", "table": "t_inner_2", "rows_for_plan": 729, "cost_for_plan": 0.219286686, @@ -6896,12 +6842,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "sj_filtered": 3.703703704, "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_2", "get_costs_for_tables": [ { "best_access_path": { @@ -6958,25 +6899,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_2", "table": "t_inner_4", "rows_for_plan": 81, "cost_for_plan": 0.400440787, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_2,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -7007,13 +6937,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_2,t_inner_4", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.661998748, @@ -7045,12 +6969,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_2", "table": "t_inner_3", "rows_for_plan": 243, "cost_for_plan": 0.446004385, @@ -7060,19 +6979,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2", "table": "t_inner_4", "rows_for_plan": 243, "cost_for_plan": 0.114053628, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -7129,25 +7043,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4", "table": "t_inner_2", "rows_for_plan": 2187, "cost_for_plan": 0.742727079, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4,t_inner_2", "get_costs_for_tables": [ { "best_access_path": { @@ -7178,13 +7081,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4,t_inner_2", "table": "t_inner_3", "rows_for_plan": 19683, "cost_for_plan": 7.507267656, @@ -7214,12 +7111,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4", "table": "t_inner_3", "rows_for_plan": 2187, "cost_for_plan": 0.742727079, @@ -7229,7 +7121,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.219286686, @@ -7239,7 +7131,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "table": "t_inner_2", "rows_for_plan": 81, "cost_for_plan": 0.046471353, @@ -7269,7 +7161,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "sj_filtered": 3.703703704, "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2", "get_costs_for_tables": [ { "best_access_path": { @@ -7352,19 +7244,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2", "table": "t_outer_2", "rows_for_plan": 27, "cost_for_plan": 0.102412822, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -7421,25 +7308,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2", "table": "t_inner_4", "rows_for_plan": 81, "cost_for_plan": 0.136873603, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -7470,13 +7346,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2,t_inner_4", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.398431564, @@ -7508,12 +7378,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2", "table": "t_inner_3", "rows_for_plan": 243, "cost_for_plan": 0.182437201, @@ -7523,19 +7388,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2", "table": "t_inner_4", "rows_for_plan": 9, "cost_for_plan": 0.097611628, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -7592,25 +7452,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4", "table": "t_outer_2", "rows_for_plan": 81, "cost_for_plan": 0.131915251, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -7641,13 +7490,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4,t_outer_2", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.393473212, @@ -7674,12 +7517,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4", "table": "t_inner_3", "rows_for_plan": 81, "cost_for_plan": 0.131915251, @@ -7689,7 +7527,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2", "table": "t_inner_3", "rows_for_plan": 27, "cost_for_plan": 0.102412822, @@ -7699,14 +7537,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "table": "t_inner_4", "rows_for_plan": 27, "cost_for_plan": 0.037231395, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -7789,19 +7627,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4", "table": "t_outer_2", "rows_for_plan": 243, "cost_for_plan": 0.102465336, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -7858,12 +7691,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4,t_outer_2", "table": "t_inner_2", "rows_for_plan": 2187, "cost_for_plan": 0.731138787, @@ -7873,12 +7701,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "best_cost": 0.540166532 }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4,t_outer_2", "table": "t_inner_3", "rows_for_plan": 2187, "cost_for_plan": 0.731138787, @@ -7890,7 +7713,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4", "table": "t_inner_2", "rows_for_plan": 243, "cost_for_plan": 0.102465336, @@ -7898,7 +7721,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4", "table": "t_inner_3", "rows_for_plan": 243, "cost_for_plan": 0.102465336, @@ -7908,7 +7731,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "table": "t_inner_3", "rows_for_plan": 81, "cost_for_plan": 0.046471353, @@ -7918,7 +7741,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_inner_2", "rows_for_plan": 27, "cost_for_plan": 0.02463804, @@ -7926,7 +7749,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_inner_4", "rows_for_plan": 9, "cost_for_plan": 0.022028022, @@ -7934,7 +7757,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_inner_3", "rows_for_plan": 27, "cost_for_plan": 0.02463804, @@ -7944,7 +7767,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_outer_2", "rows_for_plan": 9, "cost_for_plan": 0.011443245, @@ -7952,7 +7775,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_1", "rows_for_plan": 3, "cost_for_plan": 0.010504815, @@ -7960,7 +7783,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_2", "rows_for_plan": 9, "cost_for_plan": 0.011443245, @@ -7968,7 +7791,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_4", "rows_for_plan": 3, "cost_for_plan": 0.010504815, @@ -7976,7 +7799,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_3", "rows_for_plan": 9, "cost_for_plan": 0.011443245, @@ -8287,7 +8110,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -8344,13 +8167,13 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_1", "rows_for_plan": 3, "cost_for_plan": 0.010504815, "rest_of_plan": [ { - "plan_prefix": ["t_inner_1"], + "plan_prefix": "t_inner_1", "get_costs_for_tables": [ { "best_access_path": { @@ -8381,7 +8204,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_inner_1"], + "plan_prefix": "t_inner_1", "table": "t_inner_2", "rows_for_plan": 27, "cost_for_plan": 0.02463804 @@ -8389,7 +8212,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_2", "rows_for_plan": 9, "cost_for_plan": 0.011443245, @@ -8400,7 +8223,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -8457,13 +8280,13 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_4", "rows_for_plan": 3, "cost_for_plan": 0.010504815, "rest_of_plan": [ { - "plan_prefix": ["t_inner_4"], + "plan_prefix": "t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -8494,7 +8317,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_inner_4"], + "plan_prefix": "t_inner_4", "table": "t_inner_3", "rows_for_plan": 27, "cost_for_plan": 0.02463804 @@ -8502,7 +8325,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_3", "rows_for_plan": 9, "cost_for_plan": 0.011443245, @@ -8516,7 +8339,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -8677,14 +8500,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_outer_1", "rows_for_plan": 3, "cost_for_plan": 0.010504815, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "get_costs_for_tables": [ { "best_access_path": { @@ -8819,14 +8642,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_outer_2", "rows_for_plan": 27, "cost_for_plan": 0.02463804, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -8935,14 +8758,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "table": "t_inner_1", "rows_for_plan": 81, "cost_for_plan": 0.049238529, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1", "get_costs_for_tables": [ { "best_access_path": { @@ -9025,7 +8848,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1", "table": "t_inner_2", "rows_for_plan": 729, "cost_for_plan": 0.222053862, @@ -9060,12 +8883,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "sj_filtered": 3.703703704, "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2", "get_costs_for_tables": [ { "best_access_path": { @@ -9122,25 +8940,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2", "table": "t_inner_4", "rows_for_plan": 81, "cost_for_plan": 0.118419277, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -9171,13 +8978,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2,t_inner_4", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.379977238, @@ -9214,12 +9015,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_outer_2", - "t_inner_1", - "t_inner_2" - ], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1,t_inner_2", "table": "t_inner_3", "rows_for_plan": 243, "cost_for_plan": 0.163982875, @@ -9231,7 +9027,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1", "table": "t_inner_4", "rows_for_plan": 243, "cost_for_plan": 0.116820804, @@ -9239,7 +9035,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1", "t_outer_2", "t_inner_1"], + "plan_prefix": "t_outer_1,t_outer_2,t_inner_1", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.222053862, @@ -9251,7 +9047,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "table": "t_inner_2", "rows_for_plan": 243, "cost_for_plan": 0.075081543, @@ -9259,7 +9055,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "table": "t_inner_4", "rows_for_plan": 81, "cost_for_plan": 0.049238529, @@ -9267,7 +9063,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_outer_2", "table": "t_inner_3", "rows_for_plan": 243, "cost_for_plan": 0.075081543, @@ -9277,14 +9073,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_inner_1", "rows_for_plan": 9, "cost_for_plan": 0.022028022, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "get_costs_for_tables": [ { "best_access_path": { @@ -9393,14 +9189,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "table": "t_outer_2", "rows_for_plan": 81, "cost_for_plan": 0.046471353, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -9483,7 +9279,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2", "table": "t_inner_2", "rows_for_plan": 729, "cost_for_plan": 0.219286686, @@ -9511,19 +9307,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "best_cost": 0.143278952 }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2", "table": "t_inner_4", "rows_for_plan": 243, "cost_for_plan": 0.114053628, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -9580,12 +9371,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4", "table": "t_inner_2", "rows_for_plan": 2187, "cost_for_plan": 0.742727079, @@ -9595,12 +9381,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "best_cost": 0.143278952 }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4", "table": "t_inner_3", "rows_for_plan": 2187, "cost_for_plan": 0.742727079, @@ -9619,13 +9400,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "sj_filtered": 3.703703704, "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4", - "t_inner_3" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4,t_inner_3", "get_costs_for_tables": [ { "best_access_path": { @@ -9656,13 +9431,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_outer_2", - "t_inner_4", - "t_inner_3" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2,t_inner_4,t_inner_3", "table": "t_inner_2", "rows_for_plan": 729, "cost_for_plan": 0.377896186, @@ -9694,7 +9463,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_outer_2", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.219286686, @@ -9706,7 +9475,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "table": "t_inner_2", "rows_for_plan": 81, "cost_for_plan": 0.046471353, @@ -9741,7 +9510,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "sj_filtered": 3.703703704, "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2", "get_costs_for_tables": [ { "best_access_path": { @@ -9824,19 +9593,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2", "table": "t_outer_2", "rows_for_plan": 27, "cost_for_plan": 0.082557964, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -9893,25 +9657,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2", "table": "t_inner_4", "rows_for_plan": 81, "cost_for_plan": 0.117018745, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -9942,13 +9695,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2,t_inner_4", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.378576706, @@ -9985,12 +9732,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_outer_2", "table": "t_inner_3", "rows_for_plan": 243, "cost_for_plan": 0.162582343, @@ -10002,19 +9744,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2", "table": "t_inner_4", "rows_for_plan": 9, "cost_for_plan": 0.07775677, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -10071,25 +9808,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4", "table": "t_outer_2", "rows_for_plan": 81, "cost_for_plan": 0.112060393, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -10120,13 +9846,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4,t_outer_2", "table": "t_inner_3", "rows_for_plan": 729, "cost_for_plan": 0.373618354, @@ -10156,12 +9876,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_2", - "t_inner_4" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2,t_inner_4", "table": "t_inner_3", "rows_for_plan": 81, "cost_for_plan": 0.112060393, @@ -10171,7 +9886,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_2", "table": "t_inner_3", "rows_for_plan": 27, "cost_for_plan": 0.082557964, @@ -10181,14 +9896,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "table": "t_inner_4", "rows_for_plan": 27, "cost_for_plan": 0.037231395, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4", "get_costs_for_tables": [ { "best_access_path": { @@ -10271,19 +9986,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4", "table": "t_outer_2", "rows_for_plan": 243, "cost_for_plan": 0.102465336, "semijoin_strategy_choice": [], "rest_of_plan": [ { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4,t_outer_2", "get_costs_for_tables": [ { "best_access_path": { @@ -10340,12 +10050,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4,t_outer_2", "table": "t_inner_2", "rows_for_plan": 2187, "cost_for_plan": 0.731138787, @@ -10355,12 +10060,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "best_cost": 0.14187842 }, { - "plan_prefix": [ - "t_outer_1", - "t_inner_1", - "t_inner_4", - "t_outer_2" - ], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4,t_outer_2", "table": "t_inner_3", "rows_for_plan": 2187, "cost_for_plan": 0.731138787, @@ -10372,7 +10072,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4", "table": "t_inner_2", "rows_for_plan": 243, "cost_for_plan": 0.102465336, @@ -10380,7 +10080,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"], + "plan_prefix": "t_outer_1,t_inner_1,t_inner_4", "table": "t_inner_3", "rows_for_plan": 243, "cost_for_plan": 0.102465336, @@ -10390,7 +10090,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1", "t_inner_1"], + "plan_prefix": "t_outer_1,t_inner_1", "table": "t_inner_3", "rows_for_plan": 81, "cost_for_plan": 0.046471353, @@ -10400,7 +10100,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_inner_2", "rows_for_plan": 27, "cost_for_plan": 0.02463804, @@ -10408,7 +10108,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_inner_4", "rows_for_plan": 9, "cost_for_plan": 0.022028022, @@ -10416,7 +10116,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": ["t_outer_1"], + "plan_prefix": "t_outer_1", "table": "t_inner_3", "rows_for_plan": 27, "cost_for_plan": 0.02463804, @@ -10426,7 +10126,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_outer_2", "rows_for_plan": 9, "cost_for_plan": 0.011443245, @@ -10434,7 +10134,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_1", "rows_for_plan": 3, "cost_for_plan": 0.010504815, @@ -10442,7 +10142,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_2", "rows_for_plan": 9, "cost_for_plan": 0.011443245, @@ -10450,7 +10150,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_4", "rows_for_plan": 3, "cost_for_plan": 0.010504815, @@ -10458,7 +10158,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "pruned_by_heuristic": true }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t_inner_3", "rows_for_plan": 9, "cost_for_plan": 0.011443245, @@ -11074,8 +10774,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [ [ { - "plan_prefix": - [], + "plan_prefix": "", "get_costs_for_tables": [ { @@ -11141,16 +10840,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - [], + "plan_prefix": "", "table": "A", "rows_for_plan": 5, "cost_for_plan": 0.01159965, "rest_of_plan": [ { - "plan_prefix": - ["A"], + "plan_prefix": "A", "get_costs_for_tables": [ { @@ -11186,8 +10883,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - ["A"], + "plan_prefix": "A", "table": "B", "rows_for_plan": 4000, "cost_for_plan": 0.84620665 @@ -11195,8 +10891,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - [], + "plan_prefix": "", "table": "B", "rows_for_plan": 800, "cost_for_plan": 0.1669214, @@ -11215,8 +10910,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [ [ { - "plan_prefix": - [], + "plan_prefix": "", "get_costs_for_tables": [ { @@ -11282,16 +10976,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - [], + "plan_prefix": "", "table": "A", "rows_for_plan": 10, "cost_for_plan": 0.01159965, "rest_of_plan": [ { - "plan_prefix": - ["A"], + "plan_prefix": "A", "get_costs_for_tables": [ { @@ -11332,8 +11024,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - ["A"], + "plan_prefix": "A", "table": "B", "rows_for_plan": 10, "cost_for_plan": 0.02970911, @@ -11346,8 +11037,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - [], + "plan_prefix": "", "table": "B", "rows_for_plan": 800, "cost_for_plan": 0.1669214, @@ -11465,8 +11155,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [ [ { - "plan_prefix": - [], + "plan_prefix": "", "get_costs_for_tables": [ { @@ -11533,16 +11222,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 10, "cost_for_plan": 0.01159965, "rest_of_plan": [ { - "plan_prefix": - ["t1"], + "plan_prefix": "t1", "get_costs_for_tables": [ { @@ -11583,8 +11270,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - ["t1"], + "plan_prefix": "t1", "table": "t2", "rows_for_plan": 10, "cost_for_plan": 0.02909471, @@ -11593,22 +11279,16 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - [], + "plan_prefix": "", "table": "t2", "rows_for_plan": 100, "cost_for_plan": 0.0256761, "rest_of_plan": [ - { - "plan_prefix": - [ - "t2" - ], + "plan_prefix": "t2", "get_costs_for_tables": [ - { "best_access_path": { @@ -11619,7 +11299,6 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) }, "considered_access_paths": [ - { "access_type": "ref", "index": "a", @@ -11629,7 +11308,6 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "cost": 0.1731074, "chosen": true }, - { "access_type": "scan_with_join_cache", "rows": 10, @@ -11652,12 +11330,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) } ] }, - { - "plan_prefix": - [ - "t2" - ], + "plan_prefix": "t2", "table": "t1", "rows_for_plan": 100, "cost_for_plan": 0.13622835, @@ -11874,7 +11548,7 @@ select count(*) from seq_1_to_10000000 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -11905,7 +11579,7 @@ select count(*) from seq_1_to_10000000 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "seq_1_to_10000000", "rows_for_plan": 10000000, "cost_for_plan": 444.7880673 @@ -12255,8 +11929,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "considered_execution_plans": [ { - "plan_prefix": - [], + "plan_prefix": "", "get_costs_for_tables": [ { @@ -12297,8 +11970,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) ] }, { - "plan_prefix": - [], + "plan_prefix": "", "table": "t2", "rows_for_plan": 1.8367, "cost_for_plan": 0.0019606, @@ -12553,7 +12225,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -12601,7 +12273,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 0.017766, "cost_for_plan": 0.00267627, @@ -12921,7 +12593,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -12978,13 +12650,13 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "three", "rows_for_plan": 3, "cost_for_plan": 0.010504815, "rest_of_plan": [ { - "plan_prefix": ["three"], + "plan_prefix": "three", "get_costs_for_tables": [ { "best_access_path": { @@ -13040,7 +12712,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and ] }, { - "plan_prefix": ["three"], + "plan_prefix": "three", "table": "t1", "rows_for_plan": 1292.3064, "cost_for_plan": 1.712236739 @@ -13048,7 +12720,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 430.7688, "cost_for_plan": 1.581538, diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result index a042a621d91..7d2833f1bd2 100644 --- a/mysql-test/main/opt_trace_index_merge.result +++ b/mysql-test/main/opt_trace_index_merge.result @@ -208,7 +208,7 @@ explain select * from t1 where a=1 or b=1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -238,7 +238,7 @@ explain select * from t1 where a=1 or b=1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 2, "cost_for_plan": 0.005004612 @@ -424,17 +424,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "analyzing_index_merge_union": [] }, - { "range_scan_alternatives": [ - { "index": "key2", "ranges": - [ - "(100) <= (key2) <= (100)" - ], + ["(100) <= (key2) <= (100)"], "rowid_ordered": true, "using_mrr": false, "index_only": true, @@ -478,7 +474,6 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) "cost_for_plan": 0.572490756, "chosen": true }, - { "range_access_plan": { @@ -486,9 +481,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) "index": "key2", "rows": 2243, "ranges": - [ - "(100) <= (key2) <= (100)" - ] + ["(100) <= (key2) <= (100)"] }, "rows_for_plan": 2243, "cost_for_plan": 0.312832109, diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result index 0b0f6f0d2fc..7add3824a8f 100644 --- a/mysql-test/main/opt_trace_index_merge_innodb.result +++ b/mysql-test/main/opt_trace_index_merge_innodb.result @@ -202,7 +202,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -237,7 +237,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 1, "cost_for_plan": 0.00335956 diff --git a/mysql-test/main/opt_trace_security.result b/mysql-test/main/opt_trace_security.result index d1b6900bddb..ab7dc1fa606 100644 --- a/mysql-test/main/opt_trace_security.result +++ b/mysql-test/main/opt_trace_security.result @@ -89,7 +89,7 @@ select * from db1.t1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -120,7 +120,7 @@ select * from db1.t1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 3, "cost_for_plan": 0.010504815 @@ -228,7 +228,7 @@ select * from db1.v1 { { "considered_execution_plans": [ { - "plan_prefix": [], + "plan_prefix": "", "get_costs_for_tables": [ { "best_access_path": { @@ -259,7 +259,7 @@ select * from db1.v1 { ] }, { - "plan_prefix": [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 3, "cost_for_plan": 0.010504815 diff --git a/mysql-test/main/opt_trace_selectivity.result b/mysql-test/main/opt_trace_selectivity.result index 60c0acc7216..600e99f9059 100644 --- a/mysql-test/main/opt_trace_selectivity.result +++ b/mysql-test/main/opt_trace_selectivity.result @@ -34,8 +34,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [ [ { - "plan_prefix": - [], + "plan_prefix": "", "get_costs_for_tables": [ { @@ -96,8 +95,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 7, "cost_for_plan": 0.045367017 @@ -129,8 +127,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [ [ { - "plan_prefix": - [], + "plan_prefix": "", "get_costs_for_tables": [ { @@ -188,8 +185,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] }, { - "plan_prefix": - [], + "plan_prefix": "", "table": "t1", "rows_for_plan": 0.6, "cost_for_plan": 0.005306142, diff --git a/mysql-test/main/range_notembedded.result b/mysql-test/main/range_notembedded.result index d774c81d6e1..7834418bd2b 100644 --- a/mysql-test/main/range_notembedded.result +++ b/mysql-test/main/range_notembedded.result @@ -25,7 +25,6 @@ json_detailed(JSON_EXTRACT(trace, '$**.ranges')) "(2) <= (key1) <= (2)", "(3) <= (key1) <= (3)" ], - [ "(1) <= (key1) <= (1)", "(2) <= (key1) <= (2)", diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc index 406e867c2e9..b34a29f9687 100644 --- a/sql/opt_trace.cc +++ b/sql/opt_trace.cc @@ -562,13 +562,10 @@ void Opt_trace_stmt::set_allowed_mem_size(size_t mem_size) current_json->set_size_limit(mem_size); } -/* - Prefer this when you are iterating over JOIN_TABs -*/ -void Json_writer::add_table_name(const JOIN_TAB *tab) +void get_table_name_for_trace(const JOIN_TAB *tab, String *out) { - char table_name_buffer[SAFE_NAME_LEN]; + char table_name_buffer[64]; DBUG_ASSERT(tab != NULL); DBUG_ASSERT(tab->join->thd->trace_started()); @@ -578,7 +575,7 @@ void Json_writer::add_table_name(const JOIN_TAB *tab) size_t len= my_snprintf(table_name_buffer, sizeof(table_name_buffer)-1, "", tab->table->derived_select_number); - add_str(table_name_buffer, len); + out->copy(table_name_buffer, len, &my_charset_bin); } else if (tab->bush_children) { @@ -587,15 +584,27 @@ void Json_writer::add_table_name(const JOIN_TAB *tab) sizeof(table_name_buffer)-1, "", ctab->emb_sj_nest->sj_subq_pred->get_identifier()); - add_str(table_name_buffer, len); + out->copy(table_name_buffer, len, &my_charset_bin); } else { TABLE_LIST *real_table= tab->table->pos_in_table_list; - add_str(real_table->alias.str, real_table->alias.length); + out->set(real_table->alias.str, real_table->alias.length, &my_charset_bin); } } +/* + Prefer this when you are iterating over JOIN_TABs +*/ + +void Json_writer::add_table_name(const JOIN_TAB *tab) +{ + String sbuf; + get_table_name_for_trace(tab, &sbuf); + add_str(sbuf.ptr(), sbuf.length()); +} + + void Json_writer::add_table_name(const TABLE *table) { add_str(table->pos_in_table_list->alias.str); @@ -642,18 +651,26 @@ void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab) analysis of the various join orders. */ -void trace_plan_prefix(JOIN *join, uint idx, table_map join_tables) +void trace_plan_prefix(Json_writer_object *jsobj, JOIN *join, uint idx, + table_map join_tables) { - THD *const thd= join->thd; - DBUG_ASSERT(thd->trace_started()); + DBUG_ASSERT(join->thd->trace_started()); - Json_writer_array plan_prefix(thd, "plan_prefix"); + String prefix_str; + prefix_str.length(0); for (uint i= 0; i < idx; i++) { TABLE_LIST *const tr= join->positions[i].table->tab_list; if (!(tr->map & join_tables)) - plan_prefix.add_table_name(join->positions[i].table); + { + String str; + get_table_name_for_trace(join->positions[i].table, &str); + if (prefix_str.length() != 0) + prefix_str.append(','); + prefix_str.append(str); + } } + jsobj->add("plan_prefix", prefix_str.ptr(), prefix_str.length()); } diff --git a/sql/opt_trace.h b/sql/opt_trace.h index a43c1dde54b..c6b5c4ea338 100644 --- a/sql/opt_trace.h +++ b/sql/opt_trace.h @@ -107,7 +107,8 @@ void opt_trace_print_expanded_query(THD *thd, SELECT_LEX *select_lex, Json_writer_object *trace_object); void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab); -void trace_plan_prefix(JOIN *join, uint idx, table_map join_tables); +void trace_plan_prefix(Json_writer_object *jsobj, JOIN *join, uint idx, + table_map join_tables); void print_final_join_order(JOIN *join); void print_best_access_for_table(THD *thd, POSITION *pos); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 325cd92c152..a6841b87410 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9748,7 +9748,7 @@ optimize_straight_join(JOIN *join, table_map remaining_tables) double original_record_count, current_record_count; if (unlikely(thd->trace_started())) - trace_plan_prefix(join, idx, remaining_tables); + trace_plan_prefix(&trace_one_table, join, idx, remaining_tables); /* Find the best access method from 's' to the current partial plan */ best_access_path(join, s, remaining_tables, join->positions, idx, disable_jbuf, record_count, @@ -10955,7 +10955,7 @@ best_extension_by_limited_search(JOIN *join, Json_writer_object trace_one_table(thd); JOIN_TAB **best_ref= join->best_ref + idx; if (unlikely(thd->trace_started())) - trace_plan_prefix(join, idx, remaining_tables); + trace_plan_prefix(&trace_one_table, join, idx, remaining_tables); Json_writer_array arr(thd, "get_costs_for_tables"); @@ -11022,7 +11022,7 @@ best_extension_by_limited_search(JOIN *join, if (unlikely(thd->trace_started())) { - trace_plan_prefix(join, idx, remaining_tables); + trace_plan_prefix(&trace_one_table, join, idx, remaining_tables); trace_one_table.add_table_name(s); } From 7a17b65919cd2000a96cf8403b244ac8ee871c11 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 2 Nov 2022 17:43:02 +0200 Subject: [PATCH 064/123] Don't do zerofill of Aria table if it's already zerofilled This will speed up using tables that are already zerofilled with aria_chk --zerofill. --- storage/maria/aria_chk.c | 2 ++ storage/maria/ma_check.c | 21 ++++++++++++++------- storage/maria/maria_def.h | 1 + 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/storage/maria/aria_chk.c b/storage/maria/aria_chk.c index 92a9945e3ba..61821ec9099 100644 --- a/storage/maria/aria_chk.c +++ b/storage/maria/aria_chk.c @@ -1618,6 +1618,8 @@ static void descript(HA_CHECK *param, register MARIA_HA *info, char *name) pos=strmov(pos,"sorted index pages,"); if (!(share->state.changed & STATE_NOT_ZEROFILLED)) pos=strmov(pos,"zerofilled,"); + if (test_all_bits(share->state.changed, (STATE_NOT_ZEROFILLED | STATE_HAS_LSN))) + pos=strmov(pos,"has_lsn,"); if (!(share->state.changed & STATE_NOT_MOVABLE)) pos=strmov(pos,"movable,"); if (have_control_file && (share->state.changed & STATE_MOVED)) diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index f470d3691c1..45d6df7a63a 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -3651,28 +3651,35 @@ err: int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name) { - my_bool error, reenable_logging, + my_bool error= 0, reenable_logging, zero_lsn= !(param->testflag & T_ZEROFILL_KEEP_LSN); MARIA_SHARE *share= info->s; DBUG_ENTER("maria_zerofill"); if ((reenable_logging= share->now_transactional)) _ma_tmp_disable_logging_for_table(info, 0); - if (!(error= (maria_zerofill_index(param, info, name) || - maria_zerofill_data(param, info, name) || - _ma_set_uuid(info->s, 0)))) + + if (share->state.changed & (STATE_NOT_ZEROFILLED | (zero_lsn ? STATE_HAS_LSN : 0))) + error= (maria_zerofill_index(param, info, name) || + maria_zerofill_data(param, info, name)); + if (!error) + error= _ma_set_uuid(info->s, 0); + + if (!error) { /* - Mark that we have done zerofill of data and index. If we zeroed pages' - LSN, table is movable. + Mark that we have done zerofill of data and index. If we zeroed the LSN + on the pages, table is movable. */ share->state.changed&= ~STATE_NOT_ZEROFILLED; if (zero_lsn) { - share->state.changed&= ~(STATE_NOT_MOVABLE | STATE_MOVED); + share->state.changed&= ~(STATE_NOT_MOVABLE | STATE_MOVED | STATE_HAS_LSN); /* Table should get new LSNs */ share->state.create_rename_lsn= share->state.is_of_horizon= share->state.skip_redo_lsn= LSN_NEEDS_NEW_STATE_LSNS; } + else + share->state.changed|= STATE_HAS_LSN; /* Ensure state is later flushed to disk, if within maria_chk */ info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index c7aef97072b..2ed4a3f502c 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -1063,6 +1063,7 @@ struct ha_table_option_struct #define STATE_IN_REPAIR 1024U /* We are running repair on table */ #define STATE_CRASHED_PRINTED 2048U #define STATE_DATA_FILE_FULL 4096U +#define STATE_HAS_LSN 8192U /* Some page still has LSN */ #define STATE_CRASHED_FLAGS (STATE_CRASHED | STATE_CRASHED_ON_REPAIR | STATE_CRASHED_PRINTED) From 0ba47126f1f28d4731b6774d8c526d9d8e55652f Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 10 Nov 2022 15:39:47 +0300 Subject: [PATCH 065/123] Added MARIADB_NEW_COST_MODEL for ColumnStore to detect new cost model --- sql/handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/handler.h b/sql/handler.h index 01998189921..8a16f8bbbea 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2777,7 +2777,7 @@ typedef struct st_range_seq_if typedef bool (*SKIP_INDEX_TUPLE_FUNC) (range_seq_t seq, range_id_t range_info); - +#define MARIADB_NEW_COST_MODEL 1 /* Separated costs for IO and CPU */ struct IO_AND_CPU_COST From 6418c24c9498a28b3320d26309964203327ae66e Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 9 Nov 2022 19:11:08 +0200 Subject: [PATCH 066/123] Set thd->query() for internal (startup) transactions This helps with debugging as 'Query: ' in DBUG traces will show something useful, for internal transactions, instead of just "". --- sql/ddl_log.cc | 2 ++ sql/events.cc | 2 ++ sql/sql_acl.cc | 5 +++++ sql/sql_plugin.cc | 3 +++ sql/sql_reload.cc | 2 ++ sql/sql_servers.cc | 2 ++ sql/sql_udf.cc | 2 ++ sql/tztime.cc | 2 ++ 8 files changed, 20 insertions(+) diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index 67c8a8bca4f..a7920ade939 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -2741,6 +2741,8 @@ int ddl_log_execute_recovery() thd->thread_stack= (char*) &thd; thd->store_globals(); thd->init(); // Needed for error messages + thd->set_query_inner((char*) STRING_WITH_LEN("intern:ddl_log_execute_recovery"), + default_charset_info); thd->log_all_errors= (global_system_variables.log_warnings >= 3); recovery_state.drop_table.free(); diff --git a/sql/events.cc b/sql/events.cc index 6ecdf975178..01a11461655 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -906,6 +906,8 @@ Events::init(THD *thd, bool opt_noacl_or_bootstrap) */ thd->thread_stack= (char*) &thd; thd->store_globals(); + thd->set_query_inner((char*) STRING_WITH_LEN("intern:Events::init"), + default_charset_info); /* Set current time for the thread that handles events. Current time is stored in data member start_time of THD class. diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1ba056ff89e..5ed1c344cd0 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2533,6 +2533,8 @@ bool acl_init(bool dont_read_acl_tables) DBUG_RETURN(1); /* purecov: inspected */ thd->thread_stack= (char*) &thd; thd->store_globals(); + thd->set_query_inner((char*) STRING_WITH_LEN("intern:acl_init"), + default_charset_info); /* It is safe to call acl_reload() since acl_* arrays and hashes which will be freed there are global static objects and thus are initialized @@ -8001,6 +8003,9 @@ bool grant_init() DBUG_RETURN(1); /* purecov: deadcode */ thd->thread_stack= (char*) &thd; thd->store_globals(); + thd->set_query_inner((char*) STRING_WITH_LEN("intern:grant_init"), + default_charset_info); + return_val= grant_reload(thd); delete thd; DBUG_RETURN(return_val); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index a47fefc13f6..f8b4948a3ac 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1830,6 +1830,7 @@ static bool register_builtin(struct st_maria_plugin *plugin, /* called only by plugin_init() */ + static void plugin_load(MEM_ROOT *tmp_root) { TABLE_LIST tables; @@ -1847,6 +1848,8 @@ static void plugin_load(MEM_ROOT *tmp_root) new_thd->thread_stack= (char*) &tables; new_thd->store_globals(); + new_thd->set_query_inner((char*) STRING_WITH_LEN("intern:plugin_load"), + default_charset_info); new_thd->db= MYSQL_SCHEMA_NAME; bzero((char*) &new_thd->net, sizeof(new_thd->net)); tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PLUGIN_NAME, 0, TL_READ); diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 8f0f15a982a..8104806af71 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -83,6 +83,8 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, { thd->thread_stack= (char*) &tmp_thd; thd->store_globals(); + thd->set_query_inner((char*) STRING_WITH_LEN("intern:reload_acl"), + default_charset_info); } if (likely(thd)) diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index d52d6071e89..10a32abe716 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -254,6 +254,8 @@ bool servers_init(bool dont_read_servers_table) DBUG_RETURN(TRUE); thd->thread_stack= (char*) &thd; thd->store_globals(); + thd->set_query_inner((char*) STRING_WITH_LEN("intern:servers_init"), + default_charset_info); /* It is safe to call servers_reload() since servers_* arrays and hashes which will be freed there are global static objects and thus are initialized diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 02f068e9bbc..785ba2adccc 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -181,6 +181,8 @@ void udf_init() initialized = 1; new_thd->thread_stack= (char*) &new_thd; new_thd->store_globals(); + new_thd->set_query_inner((char*) STRING_WITH_LEN("intern:udf_init"), + default_charset_info); new_thd->set_db(&MYSQL_SCHEMA_NAME); tables.init_one_table(&new_thd->db, &MYSQL_FUNC_NAME, 0, TL_READ); diff --git a/sql/tztime.cc b/sql/tztime.cc index 57f1ab872ee..4d94054541d 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1623,6 +1623,8 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) DBUG_RETURN(1); thd->thread_stack= (char*) &thd; thd->store_globals(); + thd->set_query_inner((char*) STRING_WITH_LEN("intern:my_tz_init"), + default_charset_info); /* Init all memory structures that require explicit destruction */ if (my_hash_init(key_memory_tz_storage, &tz_names, &my_charset_latin1, 20, 0, From 66dde8a54ecf91d97eb1ae4a6209e0e2dddcec97 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 16 Nov 2022 14:52:47 +0200 Subject: [PATCH 067/123] Added rowid_filter support to Aria This includes: - cleanup and optimization of filtering and pushdown engine code. - Adjusted costs for rowid filters (based on extensive testing and profiling). This made a small two changes to the handler_rowid_filter_is_active() API: - One should not call it with a zero pointer! - One does not need to call handler_rowid_filter_is_active() for every row anymore. It is enough to check if filter is active by calling it call it during index_init() or when handler::rowid_filter_changed() is called The changes was to avoid unnecessary function calls and checks if pushdown conditions and rowid_filter is not used. Updated costs for rowid_filter_lookup() to be closer to reality. The old cost was based only on rowid_compare_cost. This is now changed to take into account the overhead in checking the rowid. Changed the Range_rowid_filter class to use DYNAMIC_ARRAY directly instead of Dynamic_array<>. This was done to be able to use the new append_dynamic() functions which gives a notable speed improvment compared to the old code. Removing the abstraction also makes the code easier to understand. The cost of filtering is now slightly lower than before, which is reflected in some test cases that is now using rowid filters. --- include/my_compare.h | 1 - include/my_sys.h | 12 + mysql-test/main/opt_trace.result | 22 +- mysql-test/main/opt_trace_index_merge.result | 31 +- mysql-test/main/optimizer_costs.result | 4 +- mysql-test/main/range.result | 2 +- mysql-test/main/rowid_filter.result | 692 ------ mysql-test/main/rowid_filter.test | 408 ---- mysql-test/main/rowid_filter_aria.result | 2217 ++++++++++++++++++ mysql-test/main/rowid_filter_aria.test | 9 + mysql-test/main/rowid_filter_innodb.result | 692 ------ mysql-test/main/rowid_filter_myisam.result | 673 ++++++ mysql-test/main/rowid_filter_myisam.test | 404 ++++ mysql-test/suite/maria/icp.result | 2 +- mysys/array.c | 43 +- sql/handler.cc | 3 +- sql/handler.h | 19 +- sql/optimizer_defaults.h | 7 + sql/rowid_filter.cc | 59 +- sql/rowid_filter.h | 68 +- sql/sql_analyze_stmt.h | 3 +- sql/uniques.cc | 3 +- storage/innobase/row/row0sel.cc | 6 +- storage/maria/ha_maria.cc | 45 +- storage/maria/ha_maria.h | 2 + storage/maria/ma_extra.c | 9 + storage/maria/ma_info.c | 8 - storage/maria/ma_key.c | 40 +- storage/maria/ma_rkey.c | 1 + storage/maria/maria_def.h | 30 +- storage/myisam/ha_myisam.cc | 30 +- storage/myisam/ha_myisam.h | 5 +- storage/myisam/mi_extra.c | 4 +- storage/myisam/mi_key.c | 42 +- storage/myisam/mi_rkey.c | 2 +- storage/myisam/myisamdef.h | 13 +- 36 files changed, 3614 insertions(+), 1997 deletions(-) create mode 100644 mysql-test/main/rowid_filter_aria.result create mode 100644 mysql-test/main/rowid_filter_aria.test diff --git a/include/my_compare.h b/include/my_compare.h index c2cb9ae46b9..62bb6ac0ed4 100644 --- a/include/my_compare.h +++ b/include/my_compare.h @@ -154,6 +154,5 @@ typedef enum check_result { typedef check_result_t (*index_cond_func_t)(void *param); typedef check_result_t (*rowid_filter_func_t)(void *param); -typedef int (*rowid_filter_is_active_func_t)(void *param); #endif /* _my_compare_h */ diff --git a/include/my_sys.h b/include/my_sys.h index 58141fda9a9..f52510d629e 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -353,6 +353,14 @@ typedef struct st_dynamic_array myf malloc_flags; } DYNAMIC_ARRAY; + +typedef struct st_dynamic_array_append +{ + DYNAMIC_ARRAY *array; + uchar *pos, *end; +} DYNAMIC_ARRAY_APPEND; + + typedef struct st_my_tmpdir { DYNAMIC_ARRAY full_list; @@ -856,6 +864,10 @@ extern void freeze_size(DYNAMIC_ARRAY *array); #define push_dynamic(A,B) insert_dynamic((A),(B)) #define reset_dynamic(array) ((array)->elements= 0) #define sort_dynamic(A,cmp) my_qsort((A)->buffer, (A)->elements, (A)->size_of_element, (cmp)) +extern void init_append_dynamic(DYNAMIC_ARRAY_APPEND *append, + DYNAMIC_ARRAY *array); +extern my_bool append_dynamic(DYNAMIC_ARRAY_APPEND *append, + const void * element); extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, size_t init_alloc,size_t alloc_increment); diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 158df0b1e9a..70c59092dbd 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -12239,16 +12239,16 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "rowid_filter_index": "b", "index_only_cost": 0.001515222, "filter_startup_cost": 3.004222e-4, - "find_key_and_filter_lookup_cost": 6.445451e-4, + "find_key_and_filter_lookup_cost": 7.827422e-4, "filter_selectivity": 0.021, "original_rows": 9, "new_rows": 0.189, "original_access_cost": 0.011516778, - "with_filter_access_cost": 0.0023698, + "with_filter_access_cost": 0.002507997, "original_found_rows_cost": 0.010001556, "with_filter_found_rows_cost": 2.100327e-4, "org_cost": 0.011804778, - "filter_cost": 0.00267627, + "filter_cost": 0.002814467, "filter_used": true }, "access_type": "range", @@ -12256,7 +12256,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "rows": 9, "rows_after_filter": 0.189, "rows_out": 0.017766, - "cost": 0.00267627, + "cost": 0.002814467, "chosen": true } ], @@ -12264,7 +12264,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "type": "range", "rows_read": 0.189, "rows_out": 0.017766, - "cost": 0.00267627, + "cost": 0.002814467, "uses_join_buffering": false, "rowid_filter_index": "b" } @@ -12276,7 +12276,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "plan_prefix": "", "table": "t1", "rows_for_plan": 0.017766, - "cost_for_plan": 0.00267627, + "cost_for_plan": 0.002814467, "pushdown_cond_selectivity": 0.094, "filtered": 0.1974, "rows_out": 0.017766 @@ -12286,7 +12286,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { { "best_join_order": ["t1"], "rows": 0.017766, - "cost": 0.00267627 + "cost": 0.002814467 }, { "table": "t1", @@ -12674,20 +12674,20 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "rowid_filter_index": "b", "index_only_cost": 0.092006157, "filter_startup_cost": 0.149564727, - "find_key_and_filter_lookup_cost": 0.085742374, + "find_key_and_filter_lookup_cost": 0.129350121, "filter_selectivity": 0.4312, "original_rows": 1000, "new_rows": 431.2, "original_access_cost": 1.203290157, - "with_filter_access_cost": 0.656934192, + "with_filter_access_cost": 0.700541939, "original_found_rows_cost": 1.111284, "with_filter_found_rows_cost": 0.479185661, "org_cost": 3.705870471, - "filter_cost": 2.161762502, + "filter_cost": 2.292585745, "filter_used": true }, "rows": 431.2, - "cost": 2.161762502, + "cost": 2.292585745, "chosen": true }, { diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result index 7d2833f1bd2..1970511a401 100644 --- a/mysql-test/main/opt_trace_index_merge.result +++ b/mysql-test/main/opt_trace_index_merge.result @@ -329,7 +329,7 @@ set optimizer_trace='enabled=on'; # 3-way ROR-intersection explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter key1,key2,key3 key1|key2 5|5 const 2243 (3%) Using where; Using rowid filter +1 SIMPLE t1 index_merge key1,key2,key3 key1,key2 5,5 NULL 77 Using intersect(key1,key2); Using where select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) [ @@ -423,22 +423,6 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) }, "analyzing_index_merge_union": [] - }, - { - "range_scan_alternatives": - [ - { - "index": "key2", - "ranges": - ["(100) <= (key2) <= (100)"], - "rowid_ordered": true, - "using_mrr": false, - "index_only": true, - "rows": 2243, - "cost": 0.312832109, - "chosen": true - } - ] } ] select JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -473,19 +457,6 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) "rows_for_plan": 77, "cost_for_plan": 0.572490756, "chosen": true - }, - { - "range_access_plan": - { - "type": "range_scan", - "index": "key2", - "rows": 2243, - "ranges": - ["(100) <= (key2) <= (100)"] - }, - "rows_for_plan": 2243, - "cost_for_plan": 0.312832109, - "chosen": true } ] # ROR-union(ROR-intersection, ROR-range) diff --git a/mysql-test/main/optimizer_costs.result b/mysql-test/main/optimizer_costs.result index a00673df02c..fefc03ae411 100644 --- a/mysql-test/main/optimizer_costs.result +++ b/mysql-test/main/optimizer_costs.result @@ -31,8 +31,8 @@ OPTIMIZER_DISK_READ_RATIO 0.020000 OPTIMIZER_ROW_COPY_COST 0.060866 OPTIMIZER_ROW_LOOKUP_COST 0.130839 OPTIMIZER_ROW_NEXT_FIND_COST 0.045916 -OPTIMIZER_ROWID_COMPARE_COST 0.001000 -OPTIMIZER_ROWID_COPY_COST 0.001000 +OPTIMIZER_ROWID_COMPARE_COST 0.002653 +OPTIMIZER_ROWID_COPY_COST 0.002653 ENGINE default OPTIMIZER_DISK_READ_COST 10.240000 OPTIMIZER_INDEX_BLOCK_COPY_COST 0.035600 diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index 0bd56723d4b..34c0c27f897 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -1967,7 +1967,7 @@ select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 64 -1 SIMPLE t1 range|filter i1,i2 i1|i2 4|4 NULL 12 (89%) Using where; Using join buffer (flat, BNL join); Using rowid filter +1 SIMPLE t1 range i1,i2 i1 4 NULL 12 Using where; Using join buffer (flat, BNL join) select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000; count(*) diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index 48a01b31e64..0b79e5fff6a 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -2214,695 +2214,3 @@ ALTER TABLE orders DROP COLUMN o_totaldiscount; DROP VIEW v1; DROP DATABASE dbt3_s001; use test; -# -# MDEV-18816: potential range filter for one join table with -# impossible WHERE for another -# -create table t1 ( -pk int not null primary key, c2 varchar(10) , i1 int,key (c2) -) engine=myisam; -insert into t1 values (1,'a',-5),(2,'a',null); -create table t2 ( -pk int, i1 int, c1 varchar(30) , key c1 (c1(30)), key i1 (i1) -) engine=myisam; -insert into t2 values -(1,-5,'a'),(2,null,'a'),(3,null,'a'),(4,null,'a'),(5,5,'a'),(6,null,'a'), -(7,4,'a'),(8,55,'a'),(9,null,'a'),(10,null,'a'),(11,null,'a'),(12,-5,'a'), -(13,-5,'a'),(14,null,'a'),(15,null,'a'),(16,-5,'a'),(17,-5,'a'); -select 1 -from t1 -left join -t2 join t1 as t1_a on t2.i1 = t1_a.pk -on t1.c2 = t2.c1 -where t1_a.pk is null and t1_a.i1 != 3; -1 -explain extended select 1 -from t1 -left join -t2 join t1 as t1_a on t2.i1 = t1_a.pk -on t1.c2 = t2.c1 -where t1_a.pk is null and t1_a.i1 != 3; -id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` join `test`.`t2` join `test`.`t1` `t1_a` where 0 -drop table t1,t2; -# -# MDEV-18640: TABLE::prune_range_rowid_filters: Conditional jump or -# move depends on uninitialized value -# -CREATE TABLE t1 ( -pk INT, i INT, PRIMARY KEY (pk), KEY (pk,i) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES (1,10), (7,70), (2,20); -SELECT * FROM t1 WHERE pk < 5; -pk i -1 10 -2 20 -DROP TABLE t1; -# -# MDEV-18956: Possible rowid filter for subquery for which -# in_to_exists strategy has been chosen -# -CREATE TABLE t1 (pk int) engine=myisam ; -INSERT INTO t1 VALUES (1),(2); -CREATE TABLE t2 ( -pk int auto_increment PRIMARY KEY, -i1 int, i2 int, c2 varchar(1), -KEY (i1), KEY (i2) -) engine=myisam; -INSERT INTO t2 VALUES -(1,8,6,'t'),(2,5,7,'i'),(3,4,4,'h'),(4,207,38,'d'),(5,183,206,'b'), -(6,7,null,'o'),(7,1,2,'j'),(8,17,36,'s'),(9,4,5,'q'),(10,0,6,'l'), -(11,1,9,'j'),(12,5,6,'y'),(13,null,0,'i'),(14,7,7,'x'),(15,5,2,'u'); -SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); -pk -EXPLAIN EXTENDED -SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING -2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table -Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` having 0 -DROP TABLE t1,t2; -# -# MDEV-19255: rowid range filter built for range condition -# that uses in expensive subquery -# -CREATE TABLE t1 ( -pk1 INT PRIMARY KEY, a1 INT, b1 VARCHAR(1), KEY(a1), KEY(b1) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES -(10,0,'z'),(11,3,'j'),(12,8,'f'),(13,8,'p'),(14,6,'w'),(15,0,'c'),(16,1,'j'), -(17,1,'f'),(18,5,'v'),(19,3,'f'),(20,2,'q'),(21,8,'y'),(22,0,'a'),(23,9,'w'), -(24,3,'e'),(25,1,'b'),(26,9,'r'),(27,2,'k'),(28,5,'c'),(29,3,'k'),(30,9,'b'), -(31,8,'j'),(32,1,'t'),(33,8,'n'),(34,3,'z'),(35,0,'u'),(36,3,'a'),(37,3,'g'), -(38,1,'f'),(39,6,'p'),(40,6,'m'),(41,6,'t'),(42,7,'i'),(43,4,'h'),(44,3,'d'), -(45,2,'b'),(46,1,'o'),(47,2,'j'),(48,6,'s'),(49,5,'q'),(50,6,'l'),(51,9,'j'), -(52,6,'y'),(53,0,'i'),(54,7,'x'),(55,2,'u'),(56,6,'t'),(57,4,'b'),(58,5,'m'), -(59,4,'x'),(60,8,'x'),(61,6,'v'),(62,8,'m'),(63,4,'j'),(64,8,'z'),(65,2,'a'), -(66,9,'i'),(67,4,'g'),(68,8,'h'),(69,1,'p'),(70,8,'a'),(71,0,'x'),(72,2,'s'), -(73,6,'k'),(74,0,'m'),(75,6,'e'),(76,9,'y'),(77,7,'d'),(78,7,'w'),(79,6,'y'), -(80,9,'s'),(81,9,'x'),(82,6,'l'),(83,9,'f'),(84,8,'x'),(85,1,'p'),(86,7,'y'), -(87,6,'p'),(88,1,'g'),(89,3,'c'),(90,5,'h'),(91,3,'p'),(92,2,'b'),(93,1,NULL), -(94,3,NULL),(95,2,'y'),(96,7,'s'),(97,7,'x'),(98,6,'i'),(99,9,'t'),(100,5,'j'), -(101,0,'u'),(102,7,'r'),(103,2,'x'),(104,8,'e'),(105,8,'i'),(106,5,'q'), -(107,8,'z'),(108,3,'k'),(109,65,NULL); -CREATE TABLE t2 (pk2 INT PRIMARY KEY, a2 INT, b2 VARCHAR(1)) ENGINE=MyISAM; -INSERT INTO t2 VALUES (1,1,'i'); -INSERT INTO t2 SELECT * FROM t1; -INSERT INTO t1 SELECT pk1+200, a1, b1 FROM t1; -INSERT INTO t1 SELECT pk1+400, a1, b1 FROM t1; -ANALYZE TABLE t1,t2 PERSISTENT FOR ALL; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status OK -test.t2 analyze status Engine-independent statistics collected -test.t2 analyze status OK -SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) -WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); -pk1 a1 b1 pk2 a2 b2 -17 1 f 16 1 j -37 3 g 36 3 a -105 8 i 104 8 e -EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) -WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 -1 PRIMARY t1 ALL a1,b1 NULL NULL NULL 400 2.61 Using where; Using join buffer (flat, BNL join) -2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition -Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t1`.`pk1` + 1 = `test`.`t2`.`pk2` + 2 -set @@optimizer_where_cost=0.0356*4; -EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) -WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where -1 PRIMARY t1 ref|filter a1,b1 a1|b1 5|4 test.t2.a2 36 (29%) 28.75 Using where; Using rowid filter -2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition -Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t1`.`pk1` + 1 = `test`.`t2`.`pk2` + 2 -EXPLAIN FORMAT=JSON SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) -WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); -EXPLAIN -{ - "query_block": { - "select_id": 1, - "nested_loop": [ - { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 101, - "filtered": 100, - "attached_condition": "t2.a2 is not null" - } - }, - { - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["a1", "b1"], - "key": "a1", - "key_length": "5", - "used_key_parts": ["a1"], - "ref": ["test.t2.a2"], - "rowid_filter": { - "range": { - "key": "b1", - "used_key_parts": ["b1"] - }, - "rows": 115, - "selectivity_pct": 28.75 - }, - "rows": 36, - "filtered": 28.75, - "attached_condition": "t1.b1 <= (subquery#2) and t1.pk1 + 1 = t2.pk2 + 2" - } - } - ], - "subqueries": [ - { - "query_block": { - "select_id": 2, - "nested_loop": [ - { - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk2"], - "rows": 1, - "filtered": 100, - "index_condition": "t2.pk2 <= 1" - } - } - ] - } - } - ] - } -} -set @@optimizer_where_cost=default; -DROP TABLE t1,t2; -# -# MDEV-21794: Optimizer flag rowid_filter leads to long query -# -create table t10(a int); -insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t11(a int); -insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C; -CREATE TABLE t1 ( -el_id int(10) unsigned NOT NULL , -el_index blob NOT NULL, -el_index_60 varbinary(60) NOT NULL, -filler blob, -PRIMARY KEY (el_id), -KEY el_index (el_index(60)), -KEY el_index_60 (el_index_60,el_id) -); -insert into t1 -select -A.a+1000*B.a, -A.a+1000*B.a + 10000, -A.a+1000*B.a + 10000, -'filler-data-filler-data' -from -t11 A, t10 B; -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 'el_index' -test.t1 analyze Warning Engine-independent statistics are not collected for column 'filler' -test.t1 analyze status Table is already up to date -# This must not use rowid_filter with key=el_index|el_index_60: -explain -select * from t1 -where el_index like '10%' and (el_index_60 like '10%' or el_index_60 like '20%'); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range el_index,el_index_60 el_index 62 NULL 645 Using where -drop table t10, t11, t1; -# -# MDEV-22160: SIGSEGV in st_join_table::save_explain_data on SELECT -# -set @save_optimizer_switch= @@optimizer_switch; -SET @@optimizer_switch="index_merge_sort_union=OFF"; -CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)); -INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0); -explain -SELECT * FROM t1 WHERE a > 0 AND b=0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter a,b b|a 5|5 const 7 (47%) Using where; Using rowid filter -SELECT * FROM t1 WHERE a > 0 AND b=0; -a b -1 0 -1 0 -2 0 -drop table t1; -SET @@optimizer_switch=@save_optimizer_switch; -# -# MDEV-28846: Poor performance when rowid filter contains no elements -# -create table t1 ( -pk int primary key auto_increment, -nm varchar(32), -fl1 tinyint default 0, -fl2 tinyint default 0, -index idx1(nm, fl1), -index idx2(fl2) -) engine=myisam; -create table name ( -pk int primary key auto_increment, -nm bigint -) engine=myisam; -create table flag2 ( -pk int primary key auto_increment, -fl2 tinyint -) engine=myisam; -insert into name(nm) select seq from seq_1_to_1000 order by rand(17); -insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -select '500%' as a; -a -500% -set optimizer_switch='rowid_filter=on'; -explain -select * from t1 where nm like '500%' AND fl2 = 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where -analyze format=json -select * from t1 where nm like '500%' AND fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "35", - "used_key_parts": ["nm"], - "r_loops": 1, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 49.20000076, - "r_filtered": 100, - "index_condition": "t1.nm like '500%'", - "attached_condition": "t1.fl2 = 0" - } - } - ] - } -} -select * from t1 where nm like '500%' AND fl2 = 0; -pk nm fl1 fl2 -517 500 0 0 -truncate table name; -truncate table flag2; -truncate table t1; -insert into name(nm) select seq from seq_1_to_1000 order by rand(17); -insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -set optimizer_switch='rowid_filter=off'; -explain -select * from t1 where nm like '500%' AND fl2 = 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where -analyze format=json -select * from t1 where nm like '500%' AND fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "35", - "used_key_parts": ["nm"], - "r_loops": 1, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 49.20000076, - "r_filtered": 100, - "index_condition": "t1.nm like '500%'", - "attached_condition": "t1.fl2 = 0" - } - } - ] - } -} -select * from t1 where nm like '500%' AND fl2 = 0; -pk nm fl1 fl2 -517 500 0 0 -truncate table name; -truncate table flag2; -truncate table t1; -insert into name(nm) select seq from seq_1_to_1000 order by rand(17); -insert into flag2(fl2) select seq mod 10 from seq_1_to_1000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -select '607%' as a; -a -607% -set optimizer_switch='rowid_filter=on'; -explain -select * from t1 where nm like '607%' AND fl2 = 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where -select * from t1 where nm like '607%' AND fl2 = 0; -pk nm fl1 fl2 -721 607 0 0 -truncate table name; -truncate table flag2; -truncate table t1; -insert into name(nm) select seq from seq_1_to_10000 order by rand(17); -insert into flag2(fl2) select seq mod 100 from seq_1_to_10000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -select '75%' as a; -a -75% -set optimizer_switch='rowid_filter=on'; -explain -select * from t1 where nm like '75%' AND fl2 = 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 2|35 const 55 (1%) Using where; Using rowid filter -analyze format=json -select * from t1 where nm like '75%' AND fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "2", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 115, - "selectivity_pct": 1.15, - "r_rows": 111, - "r_lookups": 100, - "r_selectivity_pct": 2, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 55, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 1.149999976, - "r_filtered": 100, - "attached_condition": "t1.nm like '75%'" - } - } - ] - } -} -select * from t1 where nm like '75%' AND fl2 = 0; -pk nm fl1 fl2 -4543 7503 0 0 -7373 7518 0 0 -drop table name, flag2; -drop table t1; -create table t1 ( -pk int primary key auto_increment, -nm char(255), -fl1 tinyint default 0, -fl2 int default 0, -index idx1(nm, fl1), -index idx2(fl2) -) engine=myisam; -create table name ( -pk int primary key auto_increment, -nm bigint -) engine=myisam; -create table flag2 ( -pk int primary key auto_increment, -fl2 int -) engine=myisam; -insert into name(nm) select seq from seq_1_to_10000 order by rand(17); -insert into flag2(fl2) select seq mod 10 from seq_1_to_10000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -select * from t1 -where -( -nm like '3400%' or nm like '3402%' or nm like '3403%' or -nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or -nm like '3409%' or -nm like '3411%' or nm like '3412%' or nm like '3413%' or -nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or -nm like '3418%' or nm like '3419%' or -nm like '3421%' or nm like '3422%' or nm like '3423%' or -nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or -nm like '3428%' or nm like '3429%' or -nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or -nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or -nm like '3439%' or -nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or -nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or -nm like '3448%' -) and fl2 = 0; -pk nm fl1 fl2 -analyze format=json select * from t1 -where -( -nm like '3400%' or nm like '3402%' or nm like '3403%' or -nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or -nm like '3409%' or -nm like '3411%' or nm like '3412%' or nm like '3413%' or -nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or -nm like '3418%' or nm like '3419%' or -nm like '3421%' or nm like '3422%' or nm like '3423%' or -nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or -nm like '3428%' or nm like '3429%' or -nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or -nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or -nm like '3439%' or -nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or -nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or -nm like '3448%' -) and fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "256", - "used_key_parts": ["nm"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["fl2"] - }, - "rows": 863, - "selectivity_pct": 8.63, - "r_rows": 1000, - "r_lookups": 44, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 44, - "r_rows": 0, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 8.630000114, - "r_filtered": 100, - "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", - "attached_condition": "t1.fl2 = 0" - } - } - ] - } -} -create table t0 select * from t1 where nm like '34%'; -delete from t1 using t1,t0 where t1.nm=t0.nm; -analyze format=json select * from t1 -where -( -nm like '3400%' or nm like '3402%' or nm like '3403%' or -nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or -nm like '3409%' or -nm like '3411%' or nm like '3412%' or nm like '3413%' or -nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or -nm like '3418%' or nm like '3419%' or -nm like '3421%' or nm like '3422%' or nm like '3423%' or -nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or -nm like '3428%' or nm like '3429%' or -nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or -nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or -nm like '3439%' or -nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or -nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or -nm like '3448%' -) and fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "256", - "used_key_parts": ["nm"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["fl2"] - }, - "rows": 853, - "selectivity_pct": 8.53, - "r_rows": 987, - "r_lookups": 0, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 44, - "r_rows": 0, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 8.529999733, - "r_filtered": 100, - "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", - "attached_condition": "t1.fl2 = 0" - } - } - ] - } -} -drop table t0; -set optimizer_switch='rowid_filter=default'; -drop table name, flag2; -drop table t1; -set @@use_stat_tables=@save_use_stat_tables; -# -# MDEV-21633 -# Assertion `tmp >= 0' failed in best_access_path with rowid_filter=ON -# -set @save_optimizer_switch= @@optimizer_switch; -SET optimizer_switch='rowid_filter=on'; -CREATE TABLE t1 ( -pk INT AUTO_INCREMENT, -a INT, -b VARCHAR(8), -KEY(a), -PRIMARY KEY(pk), -KEY (a,pk) -) ENGINE=MyISAM; -INSERT INTO t1 (a,b) VALUES -(NULL,'d'),(9,'b'),(2,'x'),(5,'k'),(NULL,'d'),(3,'s'),(5,'k'),(1,'r'), -(8,'l'),(3,'z'),(1,'c'),(1,'q'),(NULL,'x'),(NULL,'p'),(NULL,'z'),(7,'a'), -(0,'i'),(3,'s'),(NULL,'h'),(4,'p'),(1,'i'),(4,'f'),(1,'c'),(NULL,'a'), -(NULL,'x'),(1,'b'),(NULL,'n'),(NULL,'h'),(5,'i'),(6,'e'),(NULL,'i'), -(7,'e'),(1,'r'),(NULL,'z'),(1,'i'),(14,'c'),(6,'u'),(3,'b'),(4,'z'), -(2,'c'),(70,'d'),(NULL,'p'),(21,'j'),(6,'e'),(5,'c'),(13,'i'),(42,'d'), -(80,'s'),(14,'t'),(9,'a'),(0,'2'),(0,NULL),(0,NULL),(0,NULL),(0,''), -(0,''),(0,'1'),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,''),(0,''), -(0,NULL),(0,''),(0,''),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,NULL), -(0,NULL),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,NULL), -(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''),(0,''),(0,''),(0,''), -(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''); -CREATE TABLE t2 (c INT) ENGINE=MyISAM; -INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6); -SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; -pk a b c -6 3 s 3 -4 5 k 5 -7 5 k 5 -explain SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range|filter PRIMARY,a,a_2 PRIMARY|a 4|5 NULL 4 (11%) Using index condition; Using where; Using rowid filter -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) -SET optimizer_switch='rowid_filter=off'; -SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; -pk a b c -6 3 s 3 -4 5 k 5 -7 5 k 5 -SET @@optimizer_switch=@save_optimizer_switch; -DROP TABLE t1, t2; diff --git a/mysql-test/main/rowid_filter.test b/mysql-test/main/rowid_filter.test index 519723b4f29..8ba4cc64845 100644 --- a/mysql-test/main/rowid_filter.test +++ b/mysql-test/main/rowid_filter.test @@ -250,411 +250,3 @@ DROP VIEW v1; DROP DATABASE dbt3_s001; use test; - ---echo # ---echo # MDEV-18816: potential range filter for one join table with ---echo # impossible WHERE for another ---echo # - -create table t1 ( - pk int not null primary key, c2 varchar(10) , i1 int,key (c2) -) engine=myisam; -insert into t1 values (1,'a',-5),(2,'a',null); - -create table t2 ( - pk int, i1 int, c1 varchar(30) , key c1 (c1(30)), key i1 (i1) -) engine=myisam; -insert into t2 values - (1,-5,'a'),(2,null,'a'),(3,null,'a'),(4,null,'a'),(5,5,'a'),(6,null,'a'), - (7,4,'a'),(8,55,'a'),(9,null,'a'),(10,null,'a'),(11,null,'a'),(12,-5,'a'), - (13,-5,'a'),(14,null,'a'),(15,null,'a'),(16,-5,'a'),(17,-5,'a'); - -let $q= -select 1 - from t1 - left join - t2 join t1 as t1_a on t2.i1 = t1_a.pk - on t1.c2 = t2.c1 -where t1_a.pk is null and t1_a.i1 != 3; - -eval $q; -eval explain extended $q; - -drop table t1,t2; - ---echo # ---echo # MDEV-18640: TABLE::prune_range_rowid_filters: Conditional jump or ---echo # move depends on uninitialized value ---echo # - -CREATE TABLE t1 ( - pk INT, i INT, PRIMARY KEY (pk), KEY (pk,i) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES (1,10), (7,70), (2,20); - -SELECT * FROM t1 WHERE pk < 5; - -DROP TABLE t1; - ---echo # ---echo # MDEV-18956: Possible rowid filter for subquery for which ---echo # in_to_exists strategy has been chosen ---echo # - -CREATE TABLE t1 (pk int) engine=myisam ; -INSERT INTO t1 VALUES (1),(2); - -CREATE TABLE t2 ( - pk int auto_increment PRIMARY KEY, - i1 int, i2 int, c2 varchar(1), - KEY (i1), KEY (i2) -) engine=myisam; - -INSERT INTO t2 VALUES - (1,8,6,'t'),(2,5,7,'i'),(3,4,4,'h'),(4,207,38,'d'),(5,183,206,'b'), - (6,7,null,'o'),(7,1,2,'j'),(8,17,36,'s'),(9,4,5,'q'),(10,0,6,'l'), - (11,1,9,'j'),(12,5,6,'y'),(13,null,0,'i'),(14,7,7,'x'),(15,5,2,'u'); - -SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); -EXPLAIN EXTENDED -SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); - -DROP TABLE t1,t2; - ---echo # ---echo # MDEV-19255: rowid range filter built for range condition ---echo # that uses in expensive subquery ---echo # - -CREATE TABLE t1 ( - pk1 INT PRIMARY KEY, a1 INT, b1 VARCHAR(1), KEY(a1), KEY(b1) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES -(10,0,'z'),(11,3,'j'),(12,8,'f'),(13,8,'p'),(14,6,'w'),(15,0,'c'),(16,1,'j'), -(17,1,'f'),(18,5,'v'),(19,3,'f'),(20,2,'q'),(21,8,'y'),(22,0,'a'),(23,9,'w'), -(24,3,'e'),(25,1,'b'),(26,9,'r'),(27,2,'k'),(28,5,'c'),(29,3,'k'),(30,9,'b'), -(31,8,'j'),(32,1,'t'),(33,8,'n'),(34,3,'z'),(35,0,'u'),(36,3,'a'),(37,3,'g'), -(38,1,'f'),(39,6,'p'),(40,6,'m'),(41,6,'t'),(42,7,'i'),(43,4,'h'),(44,3,'d'), -(45,2,'b'),(46,1,'o'),(47,2,'j'),(48,6,'s'),(49,5,'q'),(50,6,'l'),(51,9,'j'), -(52,6,'y'),(53,0,'i'),(54,7,'x'),(55,2,'u'),(56,6,'t'),(57,4,'b'),(58,5,'m'), -(59,4,'x'),(60,8,'x'),(61,6,'v'),(62,8,'m'),(63,4,'j'),(64,8,'z'),(65,2,'a'), -(66,9,'i'),(67,4,'g'),(68,8,'h'),(69,1,'p'),(70,8,'a'),(71,0,'x'),(72,2,'s'), -(73,6,'k'),(74,0,'m'),(75,6,'e'),(76,9,'y'),(77,7,'d'),(78,7,'w'),(79,6,'y'), -(80,9,'s'),(81,9,'x'),(82,6,'l'),(83,9,'f'),(84,8,'x'),(85,1,'p'),(86,7,'y'), -(87,6,'p'),(88,1,'g'),(89,3,'c'),(90,5,'h'),(91,3,'p'),(92,2,'b'),(93,1,NULL), -(94,3,NULL),(95,2,'y'),(96,7,'s'),(97,7,'x'),(98,6,'i'),(99,9,'t'),(100,5,'j'), -(101,0,'u'),(102,7,'r'),(103,2,'x'),(104,8,'e'),(105,8,'i'),(106,5,'q'), -(107,8,'z'),(108,3,'k'),(109,65,NULL); - -CREATE TABLE t2 (pk2 INT PRIMARY KEY, a2 INT, b2 VARCHAR(1)) ENGINE=MyISAM; -INSERT INTO t2 VALUES (1,1,'i'); -INSERT INTO t2 SELECT * FROM t1; - -INSERT INTO t1 SELECT pk1+200, a1, b1 FROM t1; -INSERT INTO t1 SELECT pk1+400, a1, b1 FROM t1; - -ANALYZE TABLE t1,t2 PERSISTENT FOR ALL; - -let $q= -SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) - WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); - -eval $q; -eval EXPLAIN EXTENDED $q; -set @@optimizer_where_cost=0.0356*4; -eval EXPLAIN EXTENDED $q; -eval EXPLAIN FORMAT=JSON $q; -set @@optimizer_where_cost=default; - -DROP TABLE t1,t2; - ---echo # ---echo # MDEV-21794: Optimizer flag rowid_filter leads to long query ---echo # -create table t10(a int); -insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - -create table t11(a int); -insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C; - -CREATE TABLE t1 ( - el_id int(10) unsigned NOT NULL , - el_index blob NOT NULL, - el_index_60 varbinary(60) NOT NULL, - filler blob, - - PRIMARY KEY (el_id), - KEY el_index (el_index(60)), - KEY el_index_60 (el_index_60,el_id) -); - -insert into t1 -select - A.a+1000*B.a, - A.a+1000*B.a + 10000, - A.a+1000*B.a + 10000, - 'filler-data-filler-data' -from - t11 A, t10 B; -analyze table t1 persistent for all; - ---echo # This must not use rowid_filter with key=el_index|el_index_60: -explain -select * from t1 -where el_index like '10%' and (el_index_60 like '10%' or el_index_60 like '20%'); - -drop table t10, t11, t1; - - ---echo # ---echo # MDEV-22160: SIGSEGV in st_join_table::save_explain_data on SELECT ---echo # - -set @save_optimizer_switch= @@optimizer_switch; -SET @@optimizer_switch="index_merge_sort_union=OFF"; -CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)); -INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0); -explain -SELECT * FROM t1 WHERE a > 0 AND b=0; -SELECT * FROM t1 WHERE a > 0 AND b=0; -drop table t1; -SET @@optimizer_switch=@save_optimizer_switch; - ---echo # ---echo # MDEV-28846: Poor performance when rowid filter contains no elements ---echo # - ---source include/have_sequence.inc - -create table t1 ( - pk int primary key auto_increment, - nm varchar(32), - fl1 tinyint default 0, - fl2 tinyint default 0, - index idx1(nm, fl1), - index idx2(fl2) -) engine=myisam; - -create table name ( - pk int primary key auto_increment, - nm bigint -) engine=myisam; - -create table flag2 ( - pk int primary key auto_increment, - fl2 tinyint -) engine=myisam; - -insert into name(nm) select seq from seq_1_to_1000 order by rand(17); -insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); - -insert into t1(nm,fl2) - select nm, fl2 from name, flag2 where name.pk = flag2.pk; - -analyze table t1 persistent for all; - -let $a= -`select concat((select nm from t1 where fl2=0 order by RAND(13) limit 1),'%')`; -eval select '$a' as a; - -set optimizer_switch='rowid_filter=on'; -eval -explain -select * from t1 where nm like '$a' AND fl2 = 0; ---source include/analyze-format.inc -eval -analyze format=json -select * from t1 where nm like '$a' AND fl2 = 0; -eval -select * from t1 where nm like '$a' AND fl2 = 0; - -truncate table name; -truncate table flag2; -truncate table t1; - -insert into name(nm) select seq from seq_1_to_1000 order by rand(17); -insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); - -insert into t1(nm,fl2) - select nm, fl2 from name, flag2 where name.pk = flag2.pk; - -analyze table t1 persistent for all; - -set optimizer_switch='rowid_filter=off'; -eval -explain -select * from t1 where nm like '$a' AND fl2 = 0; ---source include/analyze-format.inc -eval -analyze format=json -select * from t1 where nm like '$a' AND fl2 = 0; -eval -select * from t1 where nm like '$a' AND fl2 = 0; - -truncate table name; -truncate table flag2; -truncate table t1; - -insert into name(nm) select seq from seq_1_to_1000 order by rand(17); -insert into flag2(fl2) select seq mod 10 from seq_1_to_1000 order by rand(19); - -insert into t1(nm,fl2) - select nm, fl2 from name, flag2 where name.pk = flag2.pk; - -analyze table t1 persistent for all; - -let $a= -`select concat((select nm from t1 where fl2=0 order by RAND(13) limit 1),'%')`; -eval select '$a' as a; - -set optimizer_switch='rowid_filter=on'; -eval -explain -select * from t1 where nm like '$a' AND fl2 = 0; -eval -select * from t1 where nm like '$a' AND fl2 = 0; - -truncate table name; -truncate table flag2; -truncate table t1; - -insert into name(nm) select seq from seq_1_to_10000 order by rand(17); -insert into flag2(fl2) select seq mod 100 from seq_1_to_10000 order by rand(19); - -insert into t1(nm,fl2) - select nm, fl2 from name, flag2 where name.pk = flag2.pk; - -analyze table t1 persistent for all; - -let $a= -`select concat(left((select nm from t1 where fl2=0 order by RAND(13) limit 1),2),'%')`; -eval select '$a' as a; - -set optimizer_switch='rowid_filter=on'; -eval -explain -select * from t1 where nm like '$a' AND fl2 = 0; ---source include/analyze-format.inc -eval -analyze format=json -select * from t1 where nm like '$a' AND fl2 = 0; -eval -select * from t1 where nm like '$a' AND fl2 = 0; - -drop table name, flag2; -drop table t1; - -# This test shows that if the container is empty there are no lookups into it - -create table t1 ( - pk int primary key auto_increment, - nm char(255), - fl1 tinyint default 0, - fl2 int default 0, - index idx1(nm, fl1), - index idx2(fl2) -) engine=myisam; - -create table name ( - pk int primary key auto_increment, - nm bigint -) engine=myisam; - -create table flag2 ( - pk int primary key auto_increment, - fl2 int -) engine=myisam; - -insert into name(nm) select seq from seq_1_to_10000 order by rand(17); -insert into flag2(fl2) select seq mod 10 from seq_1_to_10000 order by rand(19); - -insert into t1(nm,fl2) - select nm, fl2 from name, flag2 where name.pk = flag2.pk; - -analyze table t1 persistent for all; - -let $q= -select * from t1 -where -( - nm like '3400%' or nm like '3402%' or nm like '3403%' or - nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or - nm like '3409%' or - nm like '3411%' or nm like '3412%' or nm like '3413%' or - nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or - nm like '3418%' or nm like '3419%' or - nm like '3421%' or nm like '3422%' or nm like '3423%' or - nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or - nm like '3428%' or nm like '3429%' or - nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or - nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or - nm like '3439%' or - nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or - nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or - nm like '3448%' -) and fl2 = 0; - -eval $q; ---source include/analyze-format.inc -eval analyze format=json $q; - -create table t0 select * from t1 where nm like '34%'; -delete from t1 using t1,t0 where t1.nm=t0.nm; ---source include/analyze-format.inc -eval analyze format=json $q; - -drop table t0; - -set optimizer_switch='rowid_filter=default'; - -drop table name, flag2; -drop table t1; - -set @@use_stat_tables=@save_use_stat_tables; - ---echo # ---echo # MDEV-21633 ---echo # Assertion `tmp >= 0' failed in best_access_path with rowid_filter=ON ---echo # - -set @save_optimizer_switch= @@optimizer_switch; -SET optimizer_switch='rowid_filter=on'; - -CREATE TABLE t1 ( - pk INT AUTO_INCREMENT, - a INT, - b VARCHAR(8), - KEY(a), - PRIMARY KEY(pk), - KEY (a,pk) -) ENGINE=MyISAM; - -INSERT INTO t1 (a,b) VALUES - (NULL,'d'),(9,'b'),(2,'x'),(5,'k'),(NULL,'d'),(3,'s'),(5,'k'),(1,'r'), - (8,'l'),(3,'z'),(1,'c'),(1,'q'),(NULL,'x'),(NULL,'p'),(NULL,'z'),(7,'a'), - (0,'i'),(3,'s'),(NULL,'h'),(4,'p'),(1,'i'),(4,'f'),(1,'c'),(NULL,'a'), - (NULL,'x'),(1,'b'),(NULL,'n'),(NULL,'h'),(5,'i'),(6,'e'),(NULL,'i'), - (7,'e'),(1,'r'),(NULL,'z'),(1,'i'),(14,'c'),(6,'u'),(3,'b'),(4,'z'), - (2,'c'),(70,'d'),(NULL,'p'),(21,'j'),(6,'e'),(5,'c'),(13,'i'),(42,'d'), - (80,'s'),(14,'t'),(9,'a'),(0,'2'),(0,NULL),(0,NULL),(0,NULL),(0,''), - (0,''),(0,'1'),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,''),(0,''), - (0,NULL),(0,''),(0,''),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,NULL), - (0,NULL),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,NULL), - (0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''),(0,''),(0,''),(0,''), - (0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''); - -CREATE TABLE t2 (c INT) ENGINE=MyISAM; -INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6); - -SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; - -explain SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; - -SET optimizer_switch='rowid_filter=off'; - -SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; - -SET @@optimizer_switch=@save_optimizer_switch; - -# Cleanup -DROP TABLE t1, t2; diff --git a/mysql-test/main/rowid_filter_aria.result b/mysql-test/main/rowid_filter_aria.result new file mode 100644 index 00000000000..8cc3d3be008 --- /dev/null +++ b/mysql-test/main/rowid_filter_aria.result @@ -0,0 +1,2217 @@ +SET SESSION DEFAULT_STORAGE_ENGINE='Aria'; +DROP DATABASE IF EXISTS dbt3_s001; +CREATE DATABASE dbt3_s001; +use dbt3_s001; +CREATE INDEX i_l_quantity ON lineitem(l_quantity); +CREATE INDEX i_o_totalprice ON orders(o_totalprice); +set @save_use_stat_tables= @@use_stat_tables; +set @@use_stat_tables=preferably; +ANALYZE TABLE lineitem, orders; +show create table lineitem; +Table Create Table +lineitem CREATE TABLE `lineitem` ( + `l_orderkey` int(11) NOT NULL DEFAULT 0, + `l_partkey` int(11) DEFAULT NULL, + `l_suppkey` int(11) DEFAULT NULL, + `l_linenumber` int(11) NOT NULL DEFAULT 0, + `l_quantity` double DEFAULT NULL, + `l_extendedprice` double DEFAULT NULL, + `l_discount` double DEFAULT NULL, + `l_tax` double DEFAULT NULL, + `l_returnflag` char(1) DEFAULT NULL, + `l_linestatus` char(1) DEFAULT NULL, + `l_shipDATE` date DEFAULT NULL, + `l_commitDATE` date DEFAULT NULL, + `l_receiptDATE` date DEFAULT NULL, + `l_shipinstruct` char(25) DEFAULT NULL, + `l_shipmode` char(10) DEFAULT NULL, + `l_comment` varchar(44) DEFAULT NULL, + PRIMARY KEY (`l_orderkey`,`l_linenumber`), + KEY `i_l_shipdate` (`l_shipDATE`), + KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`), + KEY `i_l_partkey` (`l_partkey`), + KEY `i_l_suppkey` (`l_suppkey`), + KEY `i_l_receiptdate` (`l_receiptDATE`), + KEY `i_l_orderkey` (`l_orderkey`), + KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`), + KEY `i_l_commitdate` (`l_commitDATE`), + KEY `i_l_quantity` (`l_quantity`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +show create table orders; +Table Create Table +orders CREATE TABLE `orders` ( + `o_orderkey` int(11) NOT NULL, + `o_custkey` int(11) DEFAULT NULL, + `o_orderstatus` char(1) DEFAULT NULL, + `o_totalprice` double DEFAULT NULL, + `o_orderDATE` date DEFAULT NULL, + `o_orderpriority` char(15) DEFAULT NULL, + `o_clerk` char(15) DEFAULT NULL, + `o_shippriority` int(11) DEFAULT NULL, + `o_comment` varchar(79) DEFAULT NULL, + PRIMARY KEY (`o_orderkey`), + KEY `i_o_orderdate` (`o_orderDATE`), + KEY `i_o_custkey` (`o_custkey`), + KEY `i_o_totalprice` (`o_totalprice`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +set optimizer_use_condition_selectivity=2; +select +100 * +(select count(*) from lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 +) +/ +(select count(*) from lineitem +where l_shipdate BETWEEN '1997-01-01' AND '1997-06-30') +as correct_r_filtered_when_using_l_shipdate; +correct_r_filtered_when_using_l_shipdate +11.7647 +set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) Using index condition; Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 949, + "selectivity_pct": 15.80349709 + }, + "rows": 482, + "filtered": 15.80349731, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) 60.00 (11%) 15.80 100.00 Using index condition; Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 949, + "selectivity_pct": 15.80349709, + "r_rows": 605, + "r_lookups": 510, + "r_selectivity_pct": 11.76470588, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 482, + "r_rows": 60, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 15.80349731, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +l_orderkey l_linenumber l_shipdate l_quantity +1121 5 1997-04-27 47 +1121 6 1997-04-21 50 +1441 7 1997-06-07 50 +1443 1 1997-02-05 47 +1473 1 1997-05-05 50 +1568 2 1997-04-06 46 +1632 1 1997-01-25 47 +1632 3 1997-01-29 47 +1954 7 1997-06-04 49 +1959 1 1997-05-05 46 +2151 3 1997-01-20 49 +2177 5 1997-05-10 46 +2369 2 1997-01-02 47 +2469 3 1997-01-11 48 +2469 6 1997-03-03 49 +2470 2 1997-06-02 50 +260 1 1997-03-24 50 +288 2 1997-04-19 49 +289 4 1997-03-14 48 +3009 1 1997-03-19 48 +3105 3 1997-02-28 48 +3106 2 1997-02-27 49 +3429 1 1997-04-08 48 +3490 2 1997-06-27 50 +3619 1 1997-01-22 49 +3619 3 1997-01-31 46 +3969 3 1997-05-29 46 +4005 4 1997-01-31 49 +4036 1 1997-06-21 46 +4066 4 1997-02-17 49 +4098 1 1997-01-26 46 +422 3 1997-06-21 46 +4258 3 1997-01-02 46 +4421 2 1997-04-21 46 +4421 3 1997-05-25 46 +4453 3 1997-05-29 48 +4484 7 1997-03-17 50 +4609 3 1997-02-11 46 +484 1 1997-03-06 49 +484 3 1997-01-24 50 +484 5 1997-03-05 48 +485 1 1997-03-28 50 +4868 1 1997-04-29 47 +4868 3 1997-04-23 49 +4934 1 1997-05-20 48 +4967 1 1997-05-27 50 +5090 2 1997-04-05 46 +5152 2 1997-03-10 50 +5158 4 1997-04-10 49 +5606 3 1997-03-11 46 +5606 7 1997-02-01 46 +5762 4 1997-03-02 47 +581 3 1997-02-27 49 +5829 5 1997-01-31 49 +5831 4 1997-02-24 46 +5895 2 1997-04-27 47 +5895 3 1997-03-15 49 +5952 1 1997-06-30 49 +705 1 1997-04-18 46 +836 3 1997-03-21 46 +set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 482 Using index condition; Using where +set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 482, + "filtered": 15.80349731, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 482 510.00 15.80 11.76 Using index condition; Using where +set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 482, + "r_rows": 510, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 15.80349731, + "r_filtered": 11.76470588, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45; +l_orderkey l_linenumber l_shipdate l_quantity +1121 5 1997-04-27 47 +1121 6 1997-04-21 50 +1441 7 1997-06-07 50 +1443 1 1997-02-05 47 +1473 1 1997-05-05 50 +1568 2 1997-04-06 46 +1632 1 1997-01-25 47 +1632 3 1997-01-29 47 +1954 7 1997-06-04 49 +1959 1 1997-05-05 46 +2151 3 1997-01-20 49 +2177 5 1997-05-10 46 +2369 2 1997-01-02 47 +2469 3 1997-01-11 48 +2469 6 1997-03-03 49 +2470 2 1997-06-02 50 +260 1 1997-03-24 50 +288 2 1997-04-19 49 +289 4 1997-03-14 48 +3009 1 1997-03-19 48 +3105 3 1997-02-28 48 +3106 2 1997-02-27 49 +3429 1 1997-04-08 48 +3490 2 1997-06-27 50 +3619 1 1997-01-22 49 +3619 3 1997-01-31 46 +3969 3 1997-05-29 46 +4005 4 1997-01-31 49 +4036 1 1997-06-21 46 +4066 4 1997-02-17 49 +4098 1 1997-01-26 46 +422 3 1997-06-21 46 +4258 3 1997-01-02 46 +4421 2 1997-04-21 46 +4421 3 1997-05-25 46 +4453 3 1997-05-29 48 +4484 7 1997-03-17 50 +4609 3 1997-02-11 46 +484 1 1997-03-06 49 +484 3 1997-01-24 50 +484 5 1997-03-05 48 +485 1 1997-03-28 50 +4868 1 1997-04-29 47 +4868 3 1997-04-23 49 +4934 1 1997-05-20 48 +4967 1 1997-05-27 50 +5090 2 1997-04-05 46 +5152 2 1997-03-10 50 +5158 4 1997-04-10 49 +5606 3 1997-03-11 46 +5606 7 1997-02-01 46 +5762 4 1997-03-02 47 +581 3 1997-02-27 49 +5829 5 1997-01-31 49 +5831 4 1997-02-24 46 +5895 2 1997-04-27 47 +5895 3 1997-03-15 49 +5952 1 1997-06-30 49 +705 1 1997-04-18 46 +836 3 1997-03-21 46 +set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 92 Using index condition +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (7%) Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 92, + "filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 106, + "selectivity_pct": 7.066666667 + }, + "rows": 1, + "filtered": 7.066666603, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 92 98.00 100.00 100.00 Using index condition +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (7%) 0.11 (10%) 7.07 100.00 Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 92, + "r_rows": 98, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 106, + "selectivity_pct": 7.066666667, + "r_rows": 71, + "r_lookups": 96, + "r_selectivity_pct": 10.41666667, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 98, + "rows": 1, + "r_rows": 0.112244898, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 7.066666603, + "r_filtered": 100, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +o_orderkey l_linenumber l_shipdate o_totalprice +1156 3 1997-01-24 217682.81 +1156 4 1997-01-18 217682.81 +1156 6 1997-01-27 217682.81 +1156 7 1997-01-01 217682.81 +2180 2 1997-01-03 208481.57 +2180 3 1997-01-03 208481.57 +3619 1 1997-01-22 222274.54 +3619 3 1997-01-31 222274.54 +3619 6 1997-01-25 222274.54 +484 3 1997-01-24 219920.62 +5606 6 1997-01-11 219959.08 +set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 92 Using index condition +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where +set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 92, + "filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 7.066666603, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 92 98.00 100.00 100.00 Using index condition +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 7.07 11.22 Using where +set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 92, + "r_rows": 98, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 98, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 7.066666603, + "r_filtered": 11.2244898, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND +o_totalprice between 200000 and 230000; +o_orderkey l_linenumber l_shipdate o_totalprice +1156 3 1997-01-24 217682.81 +1156 4 1997-01-18 217682.81 +1156 6 1997-01-27 217682.81 +1156 7 1997-01-01 217682.81 +2180 2 1997-01-03 208481.57 +2180 3 1997-01-03 208481.57 +3619 1 1997-01-22 222274.54 +3619 3 1997-01-31 222274.54 +3619 6 1997-01-25 222274.54 +484 3 1997-01-24 219920.62 +5606 6 1997-01-11 219959.08 +set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (14%) Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 949, + "selectivity_pct": 15.80349709 + }, + "rows": 482, + "filtered": 15.80349731, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 216, + "selectivity_pct": 14.4 + }, + "rows": 1, + "filtered": 14.39999962, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) 60.00 (11%) 15.80 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (14%) 0.27 (25%) 14.40 100.00 Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 949, + "selectivity_pct": 15.80349709, + "r_rows": 605, + "r_lookups": 510, + "r_selectivity_pct": 11.76470588, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 482, + "r_rows": 60, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 15.80349731, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 216, + "selectivity_pct": 14.4, + "r_rows": 144, + "r_lookups": 59, + "r_selectivity_pct": 25.42372881, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 60, + "rows": 1, + "r_rows": 0.266666667, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 14.39999962, + "r_filtered": 100, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +o_orderkey l_linenumber l_shipdate l_quantity o_totalprice +1632 1 1997-01-25 47 183286.33 +1632 3 1997-01-29 47 183286.33 +2177 5 1997-05-10 46 183493.42 +2469 3 1997-01-11 48 192074.23 +2469 6 1997-03-03 49 192074.23 +3619 1 1997-01-22 49 222274.54 +3619 3 1997-01-31 46 222274.54 +484 1 1997-03-06 49 219920.62 +484 3 1997-01-24 50 219920.62 +484 5 1997-03-05 48 219920.62 +4934 1 1997-05-20 48 180478.16 +5606 3 1997-03-11 46 219959.08 +5606 7 1997-02-01 46 219959.08 +5829 5 1997-01-31 49 183734.56 +5895 2 1997-04-27 47 201419.83 +5895 3 1997-03-15 49 201419.83 +set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 482 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where +set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 482, + "filtered": 15.80349731, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 14.39999962, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 482 510.00 15.80 11.76 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 14.40 26.67 Using where +set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 482, + "r_rows": 510, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 15.80349731, + "r_filtered": 11.76470588, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 60, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 14.39999962, + "r_filtered": 26.66666667, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +o_orderkey l_linenumber l_shipdate l_quantity o_totalprice +1632 1 1997-01-25 47 183286.33 +1632 3 1997-01-29 47 183286.33 +2177 5 1997-05-10 46 183493.42 +2469 3 1997-01-11 48 192074.23 +2469 6 1997-03-03 49 192074.23 +3619 1 1997-01-22 49 222274.54 +3619 3 1997-01-31 46 222274.54 +484 1 1997-03-06 49 219920.62 +484 3 1997-01-24 50 219920.62 +484 5 1997-03-05 48 219920.62 +4934 1 1997-05-20 48 180478.16 +5606 3 1997-03-11 46 219959.08 +5606 7 1997-02-01 46 219959.08 +5829 5 1997-01-31 49 183734.56 +5895 2 1997-04-27 47 201419.83 +5895 3 1997-03-15 49 201419.83 +set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT STRAIGHT_JOIN o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice +FROM lineitem JOIN orders ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +l_quantity > 45 AND +o_totalprice between 180000 and 230000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (14%) Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 106 Using index condition +1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "rows": 106, + "filtered": 100, + "index_condition": "orders.o_totalprice between 200000 and 230000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rowid_filter": { + "range": { + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] + }, + "rows": 482, + "selectivity_pct": 8.026644463 + }, + "rows": 4, + "filtered": 8.026644707, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 106 71.00 100.00 100.00 Using index condition +1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) 0.52 (7%) 8.03 100.00 Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "r_loops": 1, + "rows": 106, + "r_rows": 71, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "index_condition": "orders.o_totalprice between 200000 and 230000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rowid_filter": { + "range": { + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] + }, + "rows": 482, + "selectivity_pct": 8.026644463, + "r_rows": 510, + "r_lookups": 476, + "r_selectivity_pct": 7.773109244, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 71, + "rows": 4, + "r_rows": 0.521126761, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.026644707, + "r_filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +o_orderkey l_linenumber l_shipdate o_totalprice +1156 3 1997-01-24 217682.81 +1156 4 1997-01-18 217682.81 +1156 6 1997-01-27 217682.81 +1156 7 1997-01-01 217682.81 +1890 1 1997-04-02 202364.58 +1890 3 1997-02-09 202364.58 +1890 4 1997-04-08 202364.58 +1890 5 1997-04-15 202364.58 +1890 6 1997-02-13 202364.58 +2180 2 1997-01-03 208481.57 +2180 3 1997-01-03 208481.57 +3619 1 1997-01-22 222274.54 +3619 3 1997-01-31 222274.54 +3619 4 1997-03-18 222274.54 +3619 6 1997-01-25 222274.54 +453 1 1997-06-30 216826.73 +453 2 1997-06-30 216826.73 +484 1 1997-03-06 219920.62 +484 2 1997-04-09 219920.62 +484 3 1997-01-24 219920.62 +484 4 1997-04-29 219920.62 +484 5 1997-03-05 219920.62 +484 6 1997-04-06 219920.62 +5606 2 1997-02-23 219959.08 +5606 3 1997-03-11 219959.08 +5606 4 1997-02-06 219959.08 +5606 6 1997-01-11 219959.08 +5606 7 1997-02-01 219959.08 +5859 2 1997-05-15 210643.96 +5859 5 1997-05-28 210643.96 +5859 6 1997-06-15 210643.96 +5895 1 1997-04-05 201419.83 +5895 2 1997-04-27 201419.83 +5895 3 1997-03-15 201419.83 +5895 4 1997-03-03 201419.83 +5895 5 1997-04-30 201419.83 +5895 6 1997-04-19 201419.83 +set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 106 Using index condition +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where +set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "rows": 106, + "filtered": 100, + "index_condition": "orders.o_totalprice between 200000 and 230000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 8.026644707, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 106 71.00 100.00 100.00 Using index condition +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.70 8.03 7.77 Using where +set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "r_loops": 1, + "rows": 106, + "r_rows": 71, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "index_condition": "orders.o_totalprice between 200000 and 230000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 71, + "rows": 4, + "r_rows": 6.704225352, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.026644707, + "r_filtered": 7.773109244, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice +FROM orders JOIN lineitem ON o_orderkey=l_orderkey +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND +o_totalprice between 200000 and 230000; +o_orderkey l_linenumber l_shipdate o_totalprice +1156 3 1997-01-24 217682.81 +1156 4 1997-01-18 217682.81 +1156 6 1997-01-27 217682.81 +1156 7 1997-01-01 217682.81 +1890 1 1997-04-02 202364.58 +1890 3 1997-02-09 202364.58 +1890 4 1997-04-08 202364.58 +1890 5 1997-04-15 202364.58 +1890 6 1997-02-13 202364.58 +2180 2 1997-01-03 208481.57 +2180 3 1997-01-03 208481.57 +3619 1 1997-01-22 222274.54 +3619 3 1997-01-31 222274.54 +3619 4 1997-03-18 222274.54 +3619 6 1997-01-25 222274.54 +453 1 1997-06-30 216826.73 +453 2 1997-06-30 216826.73 +484 1 1997-03-06 219920.62 +484 2 1997-04-09 219920.62 +484 3 1997-01-24 219920.62 +484 4 1997-04-29 219920.62 +484 5 1997-03-05 219920.62 +484 6 1997-04-06 219920.62 +5606 2 1997-02-23 219959.08 +5606 3 1997-03-11 219959.08 +5606 4 1997-02-06 219959.08 +5606 6 1997-01-11 219959.08 +5606 7 1997-02-01 219959.08 +5859 2 1997-05-15 210643.96 +5859 5 1997-05-28 210643.96 +5859 6 1997-06-15 210643.96 +5895 1 1997-04-05 201419.83 +5895 2 1997-04-27 201419.83 +5895 3 1997-03-15 201419.83 +5895 4 1997-03-03 201419.83 +5895 5 1997-04-30 201419.83 +5895 6 1997-04-19 201419.83 +# +# MDEV-18413: find constraint correlated indexes +# +ALTER TABLE lineitem ADD CONSTRAINT l_date CHECK(l_shipdate < l_receiptdate); +# Filter on l_shipdate is not used because it participates in +# the same constraint as l_receiptdate. +# Access is made on l_receiptdate. +set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 17 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where +set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "rows": 17, + "filtered": 0.532889247, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 8.466666222, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 17 18.00 0.53 38.89 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 8.47 14.29 Using where +set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "r_loops": 1, + "rows": 17, + "r_rows": 18, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.532889247, + "r_filtered": 38.88888889, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 7, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.466666222, + "r_filtered": 14.28571429, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +l_shipdate l_receiptdate o_totalprice +1996-10-07 1996-10-08 202623.92 +set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 17 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where +set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "rows": 17, + "filtered": 0.532889247, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 8.466666222, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 17 18.00 0.53 38.89 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 8.47 14.29 Using where +set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "r_loops": 1, + "rows": 17, + "r_rows": 18, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.532889247, + "r_filtered": 38.88888889, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 7, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.466666222, + "r_filtered": 14.28571429, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for SELECT l_shipdate, l_receiptdate, o_totalprice +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND +l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND +o_totalprice BETWEEN 200000 AND 250000; +l_shipdate l_receiptdate o_totalprice +1996-10-07 1996-10-08 202623.92 +ALTER TABLE orders ADD COLUMN o_totaldiscount double; +UPDATE orders SET o_totaldiscount = o_totalprice*(o_custkey/1000); +CREATE INDEX i_o_totaldiscount on orders(o_totaldiscount); +ALTER TABLE orders ADD CONSTRAINT o_price CHECK(o_totalprice > o_totaldiscount); +# Filter on o_totalprice is not used because it participates in +# the same constraint as o_discount. +# Access is made on o_discount. +set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 Using index condition; Using where +1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 61, + "filtered": 5, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rowid_filter": { + "range": { + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] + }, + "rows": 174, + "selectivity_pct": 2.897585346 + }, + "rows": 4, + "filtered": 2.897585392, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 41.00 5.00 2.44 Using index condition; Using where +1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) 4.00 (66%) 2.90 100.00 Using where; Using rowid filter +set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 61, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 5, + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rowid_filter": { + "range": { + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] + }, + "rows": 174, + "selectivity_pct": 2.897585346, + "r_rows": 183, + "r_lookups": 6, + "r_selectivity_pct": 66.66666667, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 2.897585392, + "r_filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +o_totaldiscount o_totalprice l_shipdate +18016.04288 219707.84 1996-10-02 +18016.04288 219707.84 1996-10-17 +18016.04288 219707.84 1996-11-04 +18016.04288 219707.84 1996-11-14 +set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 Using index condition; Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 61, + "filtered": 5, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 2.897585392, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 41.00 5.00 2.44 Using index condition; Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 2.90 66.67 Using where +set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 61, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 5, + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 2.897585392, + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM orders, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +o_totaldiscount o_totalprice l_shipdate +18016.04288 219707.84 1996-10-02 +18016.04288 219707.84 1996-10-17 +18016.04288 219707.84 1996-11-04 +18016.04288 219707.84 1996-11-14 +CREATE VIEW v1 AS +SELECT * FROM orders +WHERE o_orderdate BETWEEN '1992-12-01' AND '1997-01-01'; +set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 Using index condition; Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 61, + "filtered": "REPLACED", + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": "REPLACED", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 41.00 # 2.44 Using index condition; Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where +set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 61, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +o_totaldiscount o_totalprice l_shipdate +18016.04288 219707.84 1996-10-02 +18016.04288 219707.84 1996-10-17 +18016.04288 219707.84 1996-11-04 +18016.04288 219707.84 1996-11-14 +set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 Using index condition; Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where +set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 61, + "filtered": "REPLACED", + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": "REPLACED", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 41.00 # 2.44 Using index condition; Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where +set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 61, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] + } +} +set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate +FROM v1, lineitem +WHERE o_orderkey=l_orderkey AND +o_totaldiscount BETWEEN 18000 AND 20000 AND +o_totalprice BETWEEN 200000 AND 220000 AND +l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; +o_totaldiscount o_totalprice l_shipdate +18016.04288 219707.84 1996-10-02 +18016.04288 219707.84 1996-10-17 +18016.04288 219707.84 1996-11-04 +18016.04288 219707.84 1996-11-14 +ALTER TABLE lineitem DROP CONSTRAINT l_date; +ALTER TABLE orders DROP CONSTRAINT o_price; +ALTER TABLE orders DROP COLUMN o_totaldiscount; +DROP VIEW v1; +DROP DATABASE dbt3_s001; +use test; diff --git a/mysql-test/main/rowid_filter_aria.test b/mysql-test/main/rowid_filter_aria.test new file mode 100644 index 00000000000..869d398f791 --- /dev/null +++ b/mysql-test/main/rowid_filter_aria.test @@ -0,0 +1,9 @@ +# +# Test rowid filters with Aria +# + +SET SESSION DEFAULT_STORAGE_ENGINE='Aria'; + +#set global aria.optimizer_rowid_compare_cost=0.00001; +#set global aria.optimizer_rowid_copy_cost=0.00001; +--source rowid_filter.test diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index 56a7061ddf7..db2e4052a21 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -2141,698 +2141,6 @@ ALTER TABLE orders DROP COLUMN o_totaldiscount; DROP VIEW v1; DROP DATABASE dbt3_s001; use test; -# -# MDEV-18816: potential range filter for one join table with -# impossible WHERE for another -# -create table t1 ( -pk int not null primary key, c2 varchar(10) , i1 int,key (c2) -) engine=myisam; -insert into t1 values (1,'a',-5),(2,'a',null); -create table t2 ( -pk int, i1 int, c1 varchar(30) , key c1 (c1(30)), key i1 (i1) -) engine=myisam; -insert into t2 values -(1,-5,'a'),(2,null,'a'),(3,null,'a'),(4,null,'a'),(5,5,'a'),(6,null,'a'), -(7,4,'a'),(8,55,'a'),(9,null,'a'),(10,null,'a'),(11,null,'a'),(12,-5,'a'), -(13,-5,'a'),(14,null,'a'),(15,null,'a'),(16,-5,'a'),(17,-5,'a'); -select 1 -from t1 -left join -t2 join t1 as t1_a on t2.i1 = t1_a.pk -on t1.c2 = t2.c1 -where t1_a.pk is null and t1_a.i1 != 3; -1 -explain extended select 1 -from t1 -left join -t2 join t1 as t1_a on t2.i1 = t1_a.pk -on t1.c2 = t2.c1 -where t1_a.pk is null and t1_a.i1 != 3; -id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` join `test`.`t2` join `test`.`t1` `t1_a` where 0 -drop table t1,t2; -# -# MDEV-18640: TABLE::prune_range_rowid_filters: Conditional jump or -# move depends on uninitialized value -# -CREATE TABLE t1 ( -pk INT, i INT, PRIMARY KEY (pk), KEY (pk,i) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES (1,10), (7,70), (2,20); -SELECT * FROM t1 WHERE pk < 5; -pk i -1 10 -2 20 -DROP TABLE t1; -# -# MDEV-18956: Possible rowid filter for subquery for which -# in_to_exists strategy has been chosen -# -CREATE TABLE t1 (pk int) engine=myisam ; -INSERT INTO t1 VALUES (1),(2); -CREATE TABLE t2 ( -pk int auto_increment PRIMARY KEY, -i1 int, i2 int, c2 varchar(1), -KEY (i1), KEY (i2) -) engine=myisam; -INSERT INTO t2 VALUES -(1,8,6,'t'),(2,5,7,'i'),(3,4,4,'h'),(4,207,38,'d'),(5,183,206,'b'), -(6,7,null,'o'),(7,1,2,'j'),(8,17,36,'s'),(9,4,5,'q'),(10,0,6,'l'), -(11,1,9,'j'),(12,5,6,'y'),(13,null,0,'i'),(14,7,7,'x'),(15,5,2,'u'); -SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); -pk -EXPLAIN EXTENDED -SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING -2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table -Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` having 0 -DROP TABLE t1,t2; -# -# MDEV-19255: rowid range filter built for range condition -# that uses in expensive subquery -# -CREATE TABLE t1 ( -pk1 INT PRIMARY KEY, a1 INT, b1 VARCHAR(1), KEY(a1), KEY(b1) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES -(10,0,'z'),(11,3,'j'),(12,8,'f'),(13,8,'p'),(14,6,'w'),(15,0,'c'),(16,1,'j'), -(17,1,'f'),(18,5,'v'),(19,3,'f'),(20,2,'q'),(21,8,'y'),(22,0,'a'),(23,9,'w'), -(24,3,'e'),(25,1,'b'),(26,9,'r'),(27,2,'k'),(28,5,'c'),(29,3,'k'),(30,9,'b'), -(31,8,'j'),(32,1,'t'),(33,8,'n'),(34,3,'z'),(35,0,'u'),(36,3,'a'),(37,3,'g'), -(38,1,'f'),(39,6,'p'),(40,6,'m'),(41,6,'t'),(42,7,'i'),(43,4,'h'),(44,3,'d'), -(45,2,'b'),(46,1,'o'),(47,2,'j'),(48,6,'s'),(49,5,'q'),(50,6,'l'),(51,9,'j'), -(52,6,'y'),(53,0,'i'),(54,7,'x'),(55,2,'u'),(56,6,'t'),(57,4,'b'),(58,5,'m'), -(59,4,'x'),(60,8,'x'),(61,6,'v'),(62,8,'m'),(63,4,'j'),(64,8,'z'),(65,2,'a'), -(66,9,'i'),(67,4,'g'),(68,8,'h'),(69,1,'p'),(70,8,'a'),(71,0,'x'),(72,2,'s'), -(73,6,'k'),(74,0,'m'),(75,6,'e'),(76,9,'y'),(77,7,'d'),(78,7,'w'),(79,6,'y'), -(80,9,'s'),(81,9,'x'),(82,6,'l'),(83,9,'f'),(84,8,'x'),(85,1,'p'),(86,7,'y'), -(87,6,'p'),(88,1,'g'),(89,3,'c'),(90,5,'h'),(91,3,'p'),(92,2,'b'),(93,1,NULL), -(94,3,NULL),(95,2,'y'),(96,7,'s'),(97,7,'x'),(98,6,'i'),(99,9,'t'),(100,5,'j'), -(101,0,'u'),(102,7,'r'),(103,2,'x'),(104,8,'e'),(105,8,'i'),(106,5,'q'), -(107,8,'z'),(108,3,'k'),(109,65,NULL); -CREATE TABLE t2 (pk2 INT PRIMARY KEY, a2 INT, b2 VARCHAR(1)) ENGINE=MyISAM; -INSERT INTO t2 VALUES (1,1,'i'); -INSERT INTO t2 SELECT * FROM t1; -INSERT INTO t1 SELECT pk1+200, a1, b1 FROM t1; -INSERT INTO t1 SELECT pk1+400, a1, b1 FROM t1; -ANALYZE TABLE t1,t2 PERSISTENT FOR ALL; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status OK -test.t2 analyze status Engine-independent statistics collected -test.t2 analyze status OK -SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) -WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); -pk1 a1 b1 pk2 a2 b2 -17 1 f 16 1 j -37 3 g 36 3 a -105 8 i 104 8 e -EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) -WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 -1 PRIMARY t1 ALL a1,b1 NULL NULL NULL 400 2.61 Using where; Using join buffer (flat, BNL join) -2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition -Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t1`.`pk1` + 1 = `test`.`t2`.`pk2` + 2 -set @@optimizer_where_cost=0.0356*4; -EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) -WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where -1 PRIMARY t1 ref|filter a1,b1 a1|b1 5|4 test.t2.a2 36 (29%) 28.75 Using where; Using rowid filter -2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition -Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t1`.`pk1` + 1 = `test`.`t2`.`pk2` + 2 -EXPLAIN FORMAT=JSON SELECT * FROM t1 INNER JOIN t2 ON ( pk1+1 = pk2+2 AND a1 = a2 ) -WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); -EXPLAIN -{ - "query_block": { - "select_id": 1, - "nested_loop": [ - { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 101, - "filtered": 100, - "attached_condition": "t2.a2 is not null" - } - }, - { - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["a1", "b1"], - "key": "a1", - "key_length": "5", - "used_key_parts": ["a1"], - "ref": ["test.t2.a2"], - "rowid_filter": { - "range": { - "key": "b1", - "used_key_parts": ["b1"] - }, - "rows": 115, - "selectivity_pct": 28.75 - }, - "rows": 36, - "filtered": 28.75, - "attached_condition": "t1.b1 <= (subquery#2) and t1.pk1 + 1 = t2.pk2 + 2" - } - } - ], - "subqueries": [ - { - "query_block": { - "select_id": 2, - "nested_loop": [ - { - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk2"], - "rows": 1, - "filtered": 100, - "index_condition": "t2.pk2 <= 1" - } - } - ] - } - } - ] - } -} -set @@optimizer_where_cost=default; -DROP TABLE t1,t2; -# -# MDEV-21794: Optimizer flag rowid_filter leads to long query -# -create table t10(a int); -insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t11(a int); -insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C; -CREATE TABLE t1 ( -el_id int(10) unsigned NOT NULL , -el_index blob NOT NULL, -el_index_60 varbinary(60) NOT NULL, -filler blob, -PRIMARY KEY (el_id), -KEY el_index (el_index(60)), -KEY el_index_60 (el_index_60,el_id) -); -insert into t1 -select -A.a+1000*B.a, -A.a+1000*B.a + 10000, -A.a+1000*B.a + 10000, -'filler-data-filler-data' -from -t11 A, t10 B; -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 'el_index' -test.t1 analyze Warning Engine-independent statistics are not collected for column 'filler' -test.t1 analyze status OK -# This must not use rowid_filter with key=el_index|el_index_60: -explain -select * from t1 -where el_index like '10%' and (el_index_60 like '10%' or el_index_60 like '20%'); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range el_index,el_index_60 el_index 62 NULL 1000 Using where -drop table t10, t11, t1; -# -# MDEV-22160: SIGSEGV in st_join_table::save_explain_data on SELECT -# -set @save_optimizer_switch= @@optimizer_switch; -SET @@optimizer_switch="index_merge_sort_union=OFF"; -CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)); -INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0); -explain -SELECT * FROM t1 WHERE a > 0 AND b=0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter a,b b|a 5|5 const 7 (47%) Using where; Using rowid filter -SELECT * FROM t1 WHERE a > 0 AND b=0; -a b -1 0 -1 0 -2 0 -drop table t1; -SET @@optimizer_switch=@save_optimizer_switch; -# -# MDEV-28846: Poor performance when rowid filter contains no elements -# -create table t1 ( -pk int primary key auto_increment, -nm varchar(32), -fl1 tinyint default 0, -fl2 tinyint default 0, -index idx1(nm, fl1), -index idx2(fl2) -) engine=myisam; -create table name ( -pk int primary key auto_increment, -nm bigint -) engine=myisam; -create table flag2 ( -pk int primary key auto_increment, -fl2 tinyint -) engine=myisam; -insert into name(nm) select seq from seq_1_to_1000 order by rand(17); -insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -select '500%' as a; -a -500% -set optimizer_switch='rowid_filter=on'; -explain -select * from t1 where nm like '500%' AND fl2 = 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where -analyze format=json -select * from t1 where nm like '500%' AND fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "35", - "used_key_parts": ["nm"], - "r_loops": 1, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 49.20000076, - "r_filtered": 100, - "index_condition": "t1.nm like '500%'", - "attached_condition": "t1.fl2 = 0" - } - } - ] - } -} -select * from t1 where nm like '500%' AND fl2 = 0; -pk nm fl1 fl2 -517 500 0 0 -truncate table name; -truncate table flag2; -truncate table t1; -insert into name(nm) select seq from seq_1_to_1000 order by rand(17); -insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -set optimizer_switch='rowid_filter=off'; -explain -select * from t1 where nm like '500%' AND fl2 = 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where -analyze format=json -select * from t1 where nm like '500%' AND fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "35", - "used_key_parts": ["nm"], - "r_loops": 1, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 49.20000076, - "r_filtered": 100, - "index_condition": "t1.nm like '500%'", - "attached_condition": "t1.fl2 = 0" - } - } - ] - } -} -select * from t1 where nm like '500%' AND fl2 = 0; -pk nm fl1 fl2 -517 500 0 0 -truncate table name; -truncate table flag2; -truncate table t1; -insert into name(nm) select seq from seq_1_to_1000 order by rand(17); -insert into flag2(fl2) select seq mod 10 from seq_1_to_1000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -select '607%' as a; -a -607% -set optimizer_switch='rowid_filter=on'; -explain -select * from t1 where nm like '607%' AND fl2 = 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where -select * from t1 where nm like '607%' AND fl2 = 0; -pk nm fl1 fl2 -721 607 0 0 -truncate table name; -truncate table flag2; -truncate table t1; -insert into name(nm) select seq from seq_1_to_10000 order by rand(17); -insert into flag2(fl2) select seq mod 100 from seq_1_to_10000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -select '75%' as a; -a -75% -set optimizer_switch='rowid_filter=on'; -explain -select * from t1 where nm like '75%' AND fl2 = 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 2|35 const 55 (1%) Using where; Using rowid filter -analyze format=json -select * from t1 where nm like '75%' AND fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "2", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 115, - "selectivity_pct": 1.15, - "r_rows": 111, - "r_lookups": 100, - "r_selectivity_pct": 2, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 55, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 1.149999976, - "r_filtered": 100, - "attached_condition": "t1.nm like '75%'" - } - } - ] - } -} -select * from t1 where nm like '75%' AND fl2 = 0; -pk nm fl1 fl2 -4543 7503 0 0 -7373 7518 0 0 -drop table name, flag2; -drop table t1; -create table t1 ( -pk int primary key auto_increment, -nm char(255), -fl1 tinyint default 0, -fl2 int default 0, -index idx1(nm, fl1), -index idx2(fl2) -) engine=myisam; -create table name ( -pk int primary key auto_increment, -nm bigint -) engine=myisam; -create table flag2 ( -pk int primary key auto_increment, -fl2 int -) engine=myisam; -insert into name(nm) select seq from seq_1_to_10000 order by rand(17); -insert into flag2(fl2) select seq mod 10 from seq_1_to_10000 order by rand(19); -insert into t1(nm,fl2) -select nm, fl2 from name, flag2 where name.pk = flag2.pk; -analyze table t1 persistent for all; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -select * from t1 -where -( -nm like '3400%' or nm like '3402%' or nm like '3403%' or -nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or -nm like '3409%' or -nm like '3411%' or nm like '3412%' or nm like '3413%' or -nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or -nm like '3418%' or nm like '3419%' or -nm like '3421%' or nm like '3422%' or nm like '3423%' or -nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or -nm like '3428%' or nm like '3429%' or -nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or -nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or -nm like '3439%' or -nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or -nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or -nm like '3448%' -) and fl2 = 0; -pk nm fl1 fl2 -analyze format=json select * from t1 -where -( -nm like '3400%' or nm like '3402%' or nm like '3403%' or -nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or -nm like '3409%' or -nm like '3411%' or nm like '3412%' or nm like '3413%' or -nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or -nm like '3418%' or nm like '3419%' or -nm like '3421%' or nm like '3422%' or nm like '3423%' or -nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or -nm like '3428%' or nm like '3429%' or -nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or -nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or -nm like '3439%' or -nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or -nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or -nm like '3448%' -) and fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "256", - "used_key_parts": ["nm"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["fl2"] - }, - "rows": 863, - "selectivity_pct": 8.63, - "r_rows": 1000, - "r_lookups": 44, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 44, - "r_rows": 0, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 8.630000114, - "r_filtered": 100, - "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", - "attached_condition": "t1.fl2 = 0" - } - } - ] - } -} -create table t0 select * from t1 where nm like '34%'; -delete from t1 using t1,t0 where t1.nm=t0.nm; -analyze format=json select * from t1 -where -( -nm like '3400%' or nm like '3402%' or nm like '3403%' or -nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or -nm like '3409%' or -nm like '3411%' or nm like '3412%' or nm like '3413%' or -nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or -nm like '3418%' or nm like '3419%' or -nm like '3421%' or nm like '3422%' or nm like '3423%' or -nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or -nm like '3428%' or nm like '3429%' or -nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or -nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or -nm like '3439%' or -nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or -nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or -nm like '3448%' -) and fl2 = 0; -ANALYZE -{ - "query_optimization": { - "r_total_time_ms": "REPLACED" - }, - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "256", - "used_key_parts": ["nm"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["fl2"] - }, - "rows": 853, - "selectivity_pct": 8.53, - "r_rows": 987, - "r_lookups": 0, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 44, - "r_rows": 0, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 8.529999733, - "r_filtered": 100, - "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", - "attached_condition": "t1.fl2 = 0" - } - } - ] - } -} -drop table t0; -set optimizer_switch='rowid_filter=default'; -drop table name, flag2; -drop table t1; -set @@use_stat_tables=@save_use_stat_tables; -# -# MDEV-21633 -# Assertion `tmp >= 0' failed in best_access_path with rowid_filter=ON -# -set @save_optimizer_switch= @@optimizer_switch; -SET optimizer_switch='rowid_filter=on'; -CREATE TABLE t1 ( -pk INT AUTO_INCREMENT, -a INT, -b VARCHAR(8), -KEY(a), -PRIMARY KEY(pk), -KEY (a,pk) -) ENGINE=MyISAM; -INSERT INTO t1 (a,b) VALUES -(NULL,'d'),(9,'b'),(2,'x'),(5,'k'),(NULL,'d'),(3,'s'),(5,'k'),(1,'r'), -(8,'l'),(3,'z'),(1,'c'),(1,'q'),(NULL,'x'),(NULL,'p'),(NULL,'z'),(7,'a'), -(0,'i'),(3,'s'),(NULL,'h'),(4,'p'),(1,'i'),(4,'f'),(1,'c'),(NULL,'a'), -(NULL,'x'),(1,'b'),(NULL,'n'),(NULL,'h'),(5,'i'),(6,'e'),(NULL,'i'), -(7,'e'),(1,'r'),(NULL,'z'),(1,'i'),(14,'c'),(6,'u'),(3,'b'),(4,'z'), -(2,'c'),(70,'d'),(NULL,'p'),(21,'j'),(6,'e'),(5,'c'),(13,'i'),(42,'d'), -(80,'s'),(14,'t'),(9,'a'),(0,'2'),(0,NULL),(0,NULL),(0,NULL),(0,''), -(0,''),(0,'1'),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,''),(0,''), -(0,NULL),(0,''),(0,''),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,NULL), -(0,NULL),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,NULL), -(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''),(0,''),(0,''),(0,''), -(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''); -CREATE TABLE t2 (c INT) ENGINE=MyISAM; -INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6); -SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; -pk a b c -6 3 s 3 -4 5 k 5 -7 5 k 5 -explain SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range|filter PRIMARY,a,a_2 PRIMARY|a 4|5 NULL 4 (11%) Using index condition; Using where; Using rowid filter -1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) -SET optimizer_switch='rowid_filter=off'; -SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; -pk a b c -6 3 s 3 -4 5 k 5 -7 5 k 5 -SET @@optimizer_switch=@save_optimizer_switch; -DROP TABLE t1, t2; SET GLOBAL innodb_stats_persistent=@save_stats_persistent; # # MDEV-18755: possible RORI-plan and possible plan with range filter diff --git a/mysql-test/main/rowid_filter_myisam.result b/mysql-test/main/rowid_filter_myisam.result index 927257d2cc7..a09f3b75d3d 100644 --- a/mysql-test/main/rowid_filter_myisam.result +++ b/mysql-test/main/rowid_filter_myisam.result @@ -1,3 +1,4 @@ +SET optimizer_switch='rowid_filter=on'; # # MDEV-22553: Assertion `info->lastpos == (~ (my_off_t) 0)' failed in mi_rkey with rowid_filer=on # @@ -19,3 +20,675 @@ ALTER TABLE t1 ENABLE KEYS; SELECT * FROM t1 WHERE ( a BETWEEN 255 AND 270 OR f = 200 ) AND f IN ( 1, 4, 112, 143 ) AND d IN ('Montana', 'South Dakota'); a b c d e f DROP TABLE t1; +use test; +# +# MDEV-18816: potential range filter for one join table with +# impossible WHERE for another +# +create table t1 ( +pk int not null primary key, c2 varchar(10) , i1 int,key (c2) +) engine=myisam; +insert into t1 values (1,'a',-5),(2,'a',null); +create table t2 ( +pk int, i1 int, c1 varchar(30) , key c1 (c1(30)), key i1 (i1) +) engine=myisam; +insert into t2 values +(1,-5,'a'),(2,null,'a'),(3,null,'a'),(4,null,'a'),(5,5,'a'),(6,null,'a'), +(7,4,'a'),(8,55,'a'),(9,null,'a'),(10,null,'a'),(11,null,'a'),(12,-5,'a'), +(13,-5,'a'),(14,null,'a'),(15,null,'a'),(16,-5,'a'),(17,-5,'a'); +select 1 +from t1 +left join +t2 join t1 as t1_a on t2.i1 = t1_a.pk +on t1.c2 = t2.c1 +where t1_a.pk is null and t1_a.i1 != 3; +1 +explain extended select 1 +from t1 +left join +t2 join t1 as t1_a on t2.i1 = t1_a.pk +on t1.c2 = t2.c1 +where t1_a.pk is null and t1_a.i1 != 3; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1003 select 1 AS `1` from `test`.`t1` join `test`.`t2` join `test`.`t1` `t1_a` where 0 +drop table t1,t2; +# +# MDEV-18640: TABLE::prune_range_rowid_filters: Conditional jump or +# move depends on uninitialized value +# +CREATE TABLE t1 ( +pk INT, i INT, PRIMARY KEY (pk), KEY (pk,i) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,10), (7,70), (2,20); +SELECT * FROM t1 WHERE pk < 5; +pk i +1 10 +2 20 +DROP TABLE t1; +# +# MDEV-18956: Possible rowid filter for subquery for which +# in_to_exists strategy has been chosen +# +CREATE TABLE t1 (pk int) engine=myisam ; +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 ( +pk int auto_increment PRIMARY KEY, +i1 int, i2 int, c2 varchar(1), +KEY (i1), KEY (i2) +) engine=myisam; +INSERT INTO t2 VALUES +(1,8,6,'t'),(2,5,7,'i'),(3,4,4,'h'),(4,207,38,'d'),(5,183,206,'b'), +(6,7,null,'o'),(7,1,2,'j'),(8,17,36,'s'),(9,4,5,'q'),(10,0,6,'l'), +(11,1,9,'j'),(12,5,6,'y'),(13,null,0,'i'),(14,7,7,'x'),(15,5,2,'u'); +SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); +pk +EXPLAIN EXTENDED +SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` having 0 +DROP TABLE t1,t2; +# +# MDEV-19255: rowid range filter built for range condition +# that uses in expensive subquery +# +CREATE TABLE t1 ( +pk1 INT PRIMARY KEY, a1 INT, b1 VARCHAR(1), KEY(b1) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(10,0,'z'),(11,3,'j'),(12,8,'f'),(13,8,'p'),(14,6,'w'),(15,0,'c'),(16,1,'j'), +(17,1,'f'),(18,5,'v'),(19,3,'f'),(20,2,'q'),(21,8,'y'),(22,0,'a'),(23,9,'w'), +(24,3,'e'),(25,1,'b'),(26,9,'r'),(27,2,'k'),(28,5,'c'),(29,3,'k'),(30,9,'b'), +(31,8,'j'),(32,1,'t'),(33,8,'n'),(34,3,'z'),(35,0,'u'),(36,3,'a'),(37,3,'g'), +(38,1,'f'),(39,6,'p'),(40,6,'m'),(41,6,'t'),(42,7,'i'),(43,4,'h'),(44,3,'d'), +(45,2,'b'),(46,1,'o'),(47,2,'j'),(48,6,'s'),(49,5,'q'),(50,6,'l'),(51,9,'j'), +(52,6,'y'),(53,0,'i'),(54,7,'x'),(55,2,'u'),(56,6,'t'),(57,4,'b'),(58,5,'m'), +(59,4,'x'),(60,8,'x'),(61,6,'v'),(62,8,'m'),(63,4,'j'),(64,8,'z'),(65,2,'a'), +(66,9,'i'),(67,4,'g'),(68,8,'h'),(69,1,'p'),(70,8,'a'),(71,0,'x'),(72,2,'s'), +(73,6,'k'),(74,0,'m'),(75,6,'e'),(76,9,'y'),(77,7,'d'),(78,7,'w'),(79,6,'y'), +(80,9,'s'),(81,9,'x'),(82,6,'l'),(83,9,'f'),(84,8,'x'),(85,1,'p'),(86,7,'y'), +(87,6,'p'),(88,1,'g'),(89,3,'c'),(90,5,'h'),(91,3,'p'),(92,2,'b'),(93,1,NULL), +(94,3,NULL),(95,2,'y'),(96,7,'s'),(97,7,'x'),(98,6,'i'),(99,9,'t'),(100,5,'j'), +(101,0,'u'),(102,7,'r'),(103,2,'x'),(104,8,'e'),(105,8,'i'),(106,5,'q'), +(107,8,'z'),(108,3,'k'),(109,65,NULL); +CREATE TABLE t2 (pk2 INT PRIMARY KEY, a2 INT, b2 VARCHAR(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,1,'x'); +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 INNER JOIN t2 ON ( pk1 <> pk2 AND pk1 = a2 ) +WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); +pk1 a1 b1 pk2 a2 b2 +65 2 a 109 65 NULL +EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1 <> pk2 AND pk1 = a2 ) +WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where +1 PRIMARY t1 eq_ref|filter PRIMARY,b1 PRIMARY|b1 4|4 test.t2.a2 1 (87%) 87.00 Using where; Using rowid filter +2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`pk1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t2`.`a2` <> `test`.`t2`.`pk2` +EXPLAIN FORMAT=JSON SELECT * FROM t1 INNER JOIN t2 ON ( pk1 <> pk2 AND pk1 = a2 ) +WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 101, + "filtered": 100, + "attached_condition": "t2.a2 <> t2.pk2 and t2.a2 is not null" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "b1"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk1"], + "ref": ["test.t2.a2"], + "rowid_filter": { + "range": { + "key": "b1", + "used_key_parts": ["b1"] + }, + "rows": 87, + "selectivity_pct": 87 + }, + "rows": 1, + "filtered": 87, + "attached_condition": "t1.b1 <= (subquery#2)" + } + } + ], + "subqueries": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk2"], + "rows": 1, + "filtered": 100, + "index_condition": "t2.pk2 <= 1" + } + } + ] + } + } + ] + } +} +DROP TABLE t1,t2; +# +# MDEV-21794: Optimizer flag rowid_filter leads to long query +# +create table t10(a int); +insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t11(a int); +insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C; +CREATE TABLE t1 ( +el_id int(10) unsigned NOT NULL , +el_index blob NOT NULL, +el_index_60 varbinary(60) NOT NULL, +filler blob, +PRIMARY KEY (el_id), +KEY el_index (el_index(60)), +KEY el_index_60 (el_index_60,el_id) +); +insert into t1 +select +A.a+1000*B.a, +A.a+1000*B.a + 10000, +A.a+1000*B.a + 10000, +'filler-data-filler-data' +from +t11 A, t10 B; +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 'el_index' +test.t1 analyze Warning Engine-independent statistics are not collected for column 'filler' +test.t1 analyze status Table is already up to date +# This must not use rowid_filter with key=el_index|el_index_60: +explain +select * from t1 +where el_index like '10%' and (el_index_60 like '10%' or el_index_60 like '20%'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range el_index,el_index_60 el_index 62 NULL 645 Using where +drop table t10, t11, t1; +# +# MDEV-22160: SIGSEGV in st_join_table::save_explain_data on SELECT +# +set @save_optimizer_switch= @@optimizer_switch; +SET @@optimizer_switch="index_merge_sort_union=OFF"; +CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)); +INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0); +explain +SELECT * FROM t1 WHERE a > 0 AND b=0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref|filter a,b b|a 5|5 const 7 (47%) Using where; Using rowid filter +SELECT * FROM t1 WHERE a > 0 AND b=0; +a b +1 0 +1 0 +2 0 +drop table t1; +SET @@optimizer_switch=@save_optimizer_switch; +# +# MDEV-21633 +# Assertion `tmp >= 0' failed in best_access_path with rowid_filter=ON +# +set @save_optimizer_switch= @@optimizer_switch; +SET optimizer_switch='rowid_filter=on'; +CREATE TABLE t1 ( +pk INT AUTO_INCREMENT, +a INT, +b VARCHAR(8), +KEY(a), +PRIMARY KEY(pk), +KEY (a,pk) +) ENGINE=MyISAM; +INSERT INTO t1 (a,b) VALUES +(NULL,'d'),(9,'b'),(2,'x'),(5,'k'),(NULL,'d'),(3,'s'),(5,'k'),(1,'r'), +(8,'l'),(3,'z'),(1,'c'),(1,'q'),(NULL,'x'),(NULL,'p'),(NULL,'z'),(7,'a'), +(0,'i'),(3,'s'),(NULL,'h'),(4,'p'),(1,'i'),(4,'f'),(1,'c'),(NULL,'a'), +(NULL,'x'),(1,'b'),(NULL,'n'),(NULL,'h'),(5,'i'),(6,'e'),(NULL,'i'), +(7,'e'),(1,'r'),(NULL,'z'),(1,'i'),(14,'c'),(6,'u'),(3,'b'),(4,'z'), +(2,'c'),(70,'d'),(NULL,'p'),(21,'j'),(6,'e'),(5,'c'),(13,'i'),(42,'d'), +(80,'s'),(14,'t'),(9,'a'),(0,'2'),(0,NULL),(0,NULL),(0,NULL),(0,''), +(0,''),(0,'1'),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,''),(0,''), +(0,NULL),(0,''),(0,''),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,NULL), +(0,NULL),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,NULL), +(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''),(0,''),(0,''),(0,''), +(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''); +CREATE TABLE t2 (c INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6); +SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; +pk a b c +6 3 s 3 +4 5 k 5 +7 5 k 5 +explain SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range|filter PRIMARY,a,a_2 PRIMARY|a 4|5 NULL 4 (11%) Using index condition; Using where; Using rowid filter +1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +SET optimizer_switch='rowid_filter=off'; +SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; +pk a b c +6 3 s 3 +4 5 k 5 +7 5 k 5 +SET @@optimizer_switch=@save_optimizer_switch; +DROP TABLE t1, t2; +# +# MDEV-28846: Poor performance when rowid filter contains no elements +# +create table t1 ( +pk int primary key auto_increment, +nm varchar(32), +fl1 tinyint default 0, +fl2 tinyint default 0, +index idx1(nm, fl1), +index idx2(fl2) +) engine=myisam; +create table name ( +pk int primary key auto_increment, +nm bigint +) engine=myisam; +create table flag2 ( +pk int primary key auto_increment, +fl2 tinyint +) engine=myisam; +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); +insert into t1(nm,fl2) +select nm, fl2 from name, flag2 where name.pk = flag2.pk; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +select '500%' as a; +a +500% +set optimizer_switch='rowid_filter=on'; +explain +select * from t1 where nm like '500%' AND fl2 = 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where +analyze format=json +select * from t1 where nm like '500%' AND fl2 = 0; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "35", + "used_key_parts": ["nm"], + "r_loops": 1, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 49.20000076, + "r_filtered": 100, + "index_condition": "t1.nm like '500%'", + "attached_condition": "t1.fl2 = 0" + } + } + ] + } +} +select * from t1 where nm like '500%' AND fl2 = 0; +pk nm fl1 fl2 +517 500 0 0 +truncate table name; +truncate table flag2; +truncate table t1; +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); +insert into t1(nm,fl2) +select nm, fl2 from name, flag2 where name.pk = flag2.pk; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +set optimizer_switch='rowid_filter=off'; +explain +select * from t1 where nm like '500%' AND fl2 = 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where +analyze format=json +select * from t1 where nm like '500%' AND fl2 = 0; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "35", + "used_key_parts": ["nm"], + "r_loops": 1, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 49.20000076, + "r_filtered": 100, + "index_condition": "t1.nm like '500%'", + "attached_condition": "t1.fl2 = 0" + } + } + ] + } +} +select * from t1 where nm like '500%' AND fl2 = 0; +pk nm fl1 fl2 +517 500 0 0 +truncate table name; +truncate table flag2; +truncate table t1; +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 10 from seq_1_to_1000 order by rand(19); +insert into t1(nm,fl2) +select nm, fl2 from name, flag2 where name.pk = flag2.pk; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +select '607%' as a; +a +607% +set optimizer_switch='rowid_filter=on'; +explain +select * from t1 where nm like '607%' AND fl2 = 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where +select * from t1 where nm like '607%' AND fl2 = 0; +pk nm fl1 fl2 +721 607 0 0 +truncate table name; +truncate table flag2; +truncate table t1; +insert into name(nm) select seq from seq_1_to_10000 order by rand(17); +insert into flag2(fl2) select seq mod 100 from seq_1_to_10000 order by rand(19); +insert into t1(nm,fl2) +select nm, fl2 from name, flag2 where name.pk = flag2.pk; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +select '75%' as a; +a +75% +set optimizer_switch='rowid_filter=on'; +explain +select * from t1 where nm like '75%' AND fl2 = 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 2|35 const 55 (1%) Using where; Using rowid filter +analyze format=json +select * from t1 where nm like '75%' AND fl2 = 0; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx1", "idx2"], + "key": "idx2", + "key_length": "2", + "used_key_parts": ["fl2"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "idx1", + "used_key_parts": ["nm"] + }, + "rows": 115, + "selectivity_pct": 1.15, + "r_rows": 111, + "r_lookups": 100, + "r_selectivity_pct": 2, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 55, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 1.149999976, + "r_filtered": 100, + "attached_condition": "t1.nm like '75%'" + } + } + ] + } +} +select * from t1 where nm like '75%' AND fl2 = 0; +pk nm fl1 fl2 +4543 7503 0 0 +7373 7518 0 0 +drop table name, flag2; +drop table t1; +create table t1 ( +pk int primary key auto_increment, +nm char(255), +fl1 tinyint default 0, +fl2 int default 0, +index idx1(nm, fl1), +index idx2(fl2) +) engine=myisam; +create table name ( +pk int primary key auto_increment, +nm bigint +) engine=myisam; +create table flag2 ( +pk int primary key auto_increment, +fl2 int +) engine=myisam; +insert into name(nm) select seq from seq_1_to_10000 order by rand(17); +insert into flag2(fl2) select seq mod 10 from seq_1_to_10000 order by rand(19); +insert into t1(nm,fl2) +select nm, fl2 from name, flag2 where name.pk = flag2.pk; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +select * from t1 +where +( +nm like '3400%' or nm like '3402%' or nm like '3403%' or +nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or +nm like '3409%' or +nm like '3411%' or nm like '3412%' or nm like '3413%' or +nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or +nm like '3418%' or nm like '3419%' or +nm like '3421%' or nm like '3422%' or nm like '3423%' or +nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or +nm like '3428%' or nm like '3429%' or +nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or +nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or +nm like '3439%' or +nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or +nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or +nm like '3448%' +) and fl2 = 0; +pk nm fl1 fl2 +analyze format=json select * from t1 +where +( +nm like '3400%' or nm like '3402%' or nm like '3403%' or +nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or +nm like '3409%' or +nm like '3411%' or nm like '3412%' or nm like '3413%' or +nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or +nm like '3418%' or nm like '3419%' or +nm like '3421%' or nm like '3422%' or nm like '3423%' or +nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or +nm like '3428%' or nm like '3429%' or +nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or +nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or +nm like '3439%' or +nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or +nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or +nm like '3448%' +) and fl2 = 0; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "256", + "used_key_parts": ["nm"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["fl2"] + }, + "rows": 863, + "selectivity_pct": 8.63, + "r_rows": 1000, + "r_lookups": 44, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 44, + "r_rows": 0, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.630000114, + "r_filtered": 100, + "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", + "attached_condition": "t1.fl2 = 0" + } + } + ] + } +} +create table t0 select * from t1 where nm like '34%'; +delete from t1 using t1,t0 where t1.nm=t0.nm; +analyze format=json select * from t1 +where +( +nm like '3400%' or nm like '3402%' or nm like '3403%' or +nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or +nm like '3409%' or +nm like '3411%' or nm like '3412%' or nm like '3413%' or +nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or +nm like '3418%' or nm like '3419%' or +nm like '3421%' or nm like '3422%' or nm like '3423%' or +nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or +nm like '3428%' or nm like '3429%' or +nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or +nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or +nm like '3439%' or +nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or +nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or +nm like '3448%' +) and fl2 = 0; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "256", + "used_key_parts": ["nm"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["fl2"] + }, + "rows": 853, + "selectivity_pct": 8.53, + "r_rows": 987, + "r_lookups": 0, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 44, + "r_rows": 0, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.529999733, + "r_filtered": 100, + "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", + "attached_condition": "t1.fl2 = 0" + } + } + ] + } +} +drop table t0; +set optimizer_switch='rowid_filter=default'; +drop table name, flag2; +drop table t1; diff --git a/mysql-test/main/rowid_filter_myisam.test b/mysql-test/main/rowid_filter_myisam.test index 3ea4dc26ea0..c340b50d9fd 100644 --- a/mysql-test/main/rowid_filter_myisam.test +++ b/mysql-test/main/rowid_filter_myisam.test @@ -1,3 +1,5 @@ +SET optimizer_switch='rowid_filter=on'; + --echo # --echo # MDEV-22553: Assertion `info->lastpos == (~ (my_off_t) 0)' failed in mi_rkey with rowid_filer=on --echo # @@ -1623,3 +1625,405 @@ ALTER TABLE t1 ENABLE KEYS; --echo # Must not crash: SELECT * FROM t1 WHERE ( a BETWEEN 255 AND 270 OR f = 200 ) AND f IN ( 1, 4, 112, 143 ) AND d IN ('Montana', 'South Dakota'); DROP TABLE t1; + + + +use test; + +--echo # +--echo # MDEV-18816: potential range filter for one join table with +--echo # impossible WHERE for another +--echo # + +create table t1 ( + pk int not null primary key, c2 varchar(10) , i1 int,key (c2) +) engine=myisam; +insert into t1 values (1,'a',-5),(2,'a',null); + +create table t2 ( + pk int, i1 int, c1 varchar(30) , key c1 (c1(30)), key i1 (i1) +) engine=myisam; +insert into t2 values + (1,-5,'a'),(2,null,'a'),(3,null,'a'),(4,null,'a'),(5,5,'a'),(6,null,'a'), + (7,4,'a'),(8,55,'a'),(9,null,'a'),(10,null,'a'),(11,null,'a'),(12,-5,'a'), + (13,-5,'a'),(14,null,'a'),(15,null,'a'),(16,-5,'a'),(17,-5,'a'); + +let $q= +select 1 + from t1 + left join + t2 join t1 as t1_a on t2.i1 = t1_a.pk + on t1.c2 = t2.c1 +where t1_a.pk is null and t1_a.i1 != 3; + +eval $q; +eval explain extended $q; + +drop table t1,t2; + +--echo # +--echo # MDEV-18640: TABLE::prune_range_rowid_filters: Conditional jump or +--echo # move depends on uninitialized value +--echo # + +CREATE TABLE t1 ( + pk INT, i INT, PRIMARY KEY (pk), KEY (pk,i) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,10), (7,70), (2,20); + +SELECT * FROM t1 WHERE pk < 5; + +DROP TABLE t1; + +--echo # +--echo # MDEV-18956: Possible rowid filter for subquery for which +--echo # in_to_exists strategy has been chosen +--echo # + +CREATE TABLE t1 (pk int) engine=myisam ; +INSERT INTO t1 VALUES (1),(2); + +CREATE TABLE t2 ( + pk int auto_increment PRIMARY KEY, + i1 int, i2 int, c2 varchar(1), + KEY (i1), KEY (i2) +) engine=myisam; + +INSERT INTO t2 VALUES + (1,8,6,'t'),(2,5,7,'i'),(3,4,4,'h'),(4,207,38,'d'),(5,183,206,'b'), + (6,7,null,'o'),(7,1,2,'j'),(8,17,36,'s'),(9,4,5,'q'),(10,0,6,'l'), + (11,1,9,'j'),(12,5,6,'y'),(13,null,0,'i'),(14,7,7,'x'),(15,5,2,'u'); + +SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); +EXPLAIN EXTENDED +SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3); + +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-19255: rowid range filter built for range condition +--echo # that uses in expensive subquery +--echo # + +CREATE TABLE t1 ( + pk1 INT PRIMARY KEY, a1 INT, b1 VARCHAR(1), KEY(b1) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(10,0,'z'),(11,3,'j'),(12,8,'f'),(13,8,'p'),(14,6,'w'),(15,0,'c'),(16,1,'j'), +(17,1,'f'),(18,5,'v'),(19,3,'f'),(20,2,'q'),(21,8,'y'),(22,0,'a'),(23,9,'w'), +(24,3,'e'),(25,1,'b'),(26,9,'r'),(27,2,'k'),(28,5,'c'),(29,3,'k'),(30,9,'b'), +(31,8,'j'),(32,1,'t'),(33,8,'n'),(34,3,'z'),(35,0,'u'),(36,3,'a'),(37,3,'g'), +(38,1,'f'),(39,6,'p'),(40,6,'m'),(41,6,'t'),(42,7,'i'),(43,4,'h'),(44,3,'d'), +(45,2,'b'),(46,1,'o'),(47,2,'j'),(48,6,'s'),(49,5,'q'),(50,6,'l'),(51,9,'j'), +(52,6,'y'),(53,0,'i'),(54,7,'x'),(55,2,'u'),(56,6,'t'),(57,4,'b'),(58,5,'m'), +(59,4,'x'),(60,8,'x'),(61,6,'v'),(62,8,'m'),(63,4,'j'),(64,8,'z'),(65,2,'a'), +(66,9,'i'),(67,4,'g'),(68,8,'h'),(69,1,'p'),(70,8,'a'),(71,0,'x'),(72,2,'s'), +(73,6,'k'),(74,0,'m'),(75,6,'e'),(76,9,'y'),(77,7,'d'),(78,7,'w'),(79,6,'y'), +(80,9,'s'),(81,9,'x'),(82,6,'l'),(83,9,'f'),(84,8,'x'),(85,1,'p'),(86,7,'y'), +(87,6,'p'),(88,1,'g'),(89,3,'c'),(90,5,'h'),(91,3,'p'),(92,2,'b'),(93,1,NULL), +(94,3,NULL),(95,2,'y'),(96,7,'s'),(97,7,'x'),(98,6,'i'),(99,9,'t'),(100,5,'j'), +(101,0,'u'),(102,7,'r'),(103,2,'x'),(104,8,'e'),(105,8,'i'),(106,5,'q'), +(107,8,'z'),(108,3,'k'),(109,65,NULL); + +CREATE TABLE t2 (pk2 INT PRIMARY KEY, a2 INT, b2 VARCHAR(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,1,'x'); +INSERT INTO t2 SELECT * FROM t1; + +let $q= +SELECT * FROM t1 INNER JOIN t2 ON ( pk1 <> pk2 AND pk1 = a2 ) + WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); + +eval $q; +eval EXPLAIN EXTENDED $q; +eval EXPLAIN FORMAT=JSON $q; + +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-21794: Optimizer flag rowid_filter leads to long query +--echo # +create table t10(a int); +insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t11(a int); +insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C; + +CREATE TABLE t1 ( + el_id int(10) unsigned NOT NULL , + el_index blob NOT NULL, + el_index_60 varbinary(60) NOT NULL, + filler blob, + + PRIMARY KEY (el_id), + KEY el_index (el_index(60)), + KEY el_index_60 (el_index_60,el_id) +); + +insert into t1 +select + A.a+1000*B.a, + A.a+1000*B.a + 10000, + A.a+1000*B.a + 10000, + 'filler-data-filler-data' +from + t11 A, t10 B; +analyze table t1 persistent for all; + +--echo # This must not use rowid_filter with key=el_index|el_index_60: +explain +select * from t1 +where el_index like '10%' and (el_index_60 like '10%' or el_index_60 like '20%'); + +drop table t10, t11, t1; + + +--echo # +--echo # MDEV-22160: SIGSEGV in st_join_table::save_explain_data on SELECT +--echo # + +set @save_optimizer_switch= @@optimizer_switch; +SET @@optimizer_switch="index_merge_sort_union=OFF"; +CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)); +INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0); +explain +SELECT * FROM t1 WHERE a > 0 AND b=0; +SELECT * FROM t1 WHERE a > 0 AND b=0; +drop table t1; +SET @@optimizer_switch=@save_optimizer_switch; + +--echo # +--echo # MDEV-21633 +--echo # Assertion `tmp >= 0' failed in best_access_path with rowid_filter=ON +--echo # + +set @save_optimizer_switch= @@optimizer_switch; +SET optimizer_switch='rowid_filter=on'; + +CREATE TABLE t1 ( + pk INT AUTO_INCREMENT, + a INT, + b VARCHAR(8), + KEY(a), + PRIMARY KEY(pk), + KEY (a,pk) +) ENGINE=MyISAM; + +INSERT INTO t1 (a,b) VALUES + (NULL,'d'),(9,'b'),(2,'x'),(5,'k'),(NULL,'d'),(3,'s'),(5,'k'),(1,'r'), + (8,'l'),(3,'z'),(1,'c'),(1,'q'),(NULL,'x'),(NULL,'p'),(NULL,'z'),(7,'a'), + (0,'i'),(3,'s'),(NULL,'h'),(4,'p'),(1,'i'),(4,'f'),(1,'c'),(NULL,'a'), + (NULL,'x'),(1,'b'),(NULL,'n'),(NULL,'h'),(5,'i'),(6,'e'),(NULL,'i'), + (7,'e'),(1,'r'),(NULL,'z'),(1,'i'),(14,'c'),(6,'u'),(3,'b'),(4,'z'), + (2,'c'),(70,'d'),(NULL,'p'),(21,'j'),(6,'e'),(5,'c'),(13,'i'),(42,'d'), + (80,'s'),(14,'t'),(9,'a'),(0,'2'),(0,NULL),(0,NULL),(0,NULL),(0,''), + (0,''),(0,'1'),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,''),(0,''), + (0,NULL),(0,''),(0,''),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,NULL), + (0,NULL),(0,''),(0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,NULL), + (0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''),(0,''),(0,''),(0,''), + (0,''),(0,''),(0,''),(0,NULL),(0,''),(0,NULL),(0,''); + +CREATE TABLE t2 (c INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6); + +SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; + +explain SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; + +SET optimizer_switch='rowid_filter=off'; + +SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo'; + +SET @@optimizer_switch=@save_optimizer_switch; + +# Cleanup +DROP TABLE t1, t2; + +--echo # +--echo # MDEV-28846: Poor performance when rowid filter contains no elements +--echo # + +--source include/have_sequence.inc + +create table t1 ( + pk int primary key auto_increment, + nm varchar(32), + fl1 tinyint default 0, + fl2 tinyint default 0, + index idx1(nm, fl1), + index idx2(fl2) +) engine=myisam; + +create table name ( + pk int primary key auto_increment, + nm bigint +) engine=myisam; + +create table flag2 ( + pk int primary key auto_increment, + fl2 tinyint +) engine=myisam; + +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); + +insert into t1(nm,fl2) + select nm, fl2 from name, flag2 where name.pk = flag2.pk; + +analyze table t1 persistent for all; + +let $a= +`select concat((select nm from t1 where fl2=0 order by RAND(13) limit 1),'%')`; +eval select '$a' as a; + +set optimizer_switch='rowid_filter=on'; +eval +explain +select * from t1 where nm like '$a' AND fl2 = 0; +--source include/analyze-format.inc +eval +analyze format=json +select * from t1 where nm like '$a' AND fl2 = 0; +eval +select * from t1 where nm like '$a' AND fl2 = 0; + +truncate table name; +truncate table flag2; +truncate table t1; + +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); + +insert into t1(nm,fl2) + select nm, fl2 from name, flag2 where name.pk = flag2.pk; + +analyze table t1 persistent for all; + +set optimizer_switch='rowid_filter=off'; +eval +explain +select * from t1 where nm like '$a' AND fl2 = 0; +--source include/analyze-format.inc +eval +analyze format=json +select * from t1 where nm like '$a' AND fl2 = 0; +eval +select * from t1 where nm like '$a' AND fl2 = 0; + +truncate table name; +truncate table flag2; +truncate table t1; + +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 10 from seq_1_to_1000 order by rand(19); + +insert into t1(nm,fl2) + select nm, fl2 from name, flag2 where name.pk = flag2.pk; + +analyze table t1 persistent for all; + +let $a= +`select concat((select nm from t1 where fl2=0 order by RAND(13) limit 1),'%')`; +eval select '$a' as a; + +set optimizer_switch='rowid_filter=on'; +eval +explain +select * from t1 where nm like '$a' AND fl2 = 0; +eval +select * from t1 where nm like '$a' AND fl2 = 0; + +truncate table name; +truncate table flag2; +truncate table t1; + +insert into name(nm) select seq from seq_1_to_10000 order by rand(17); +insert into flag2(fl2) select seq mod 100 from seq_1_to_10000 order by rand(19); + +insert into t1(nm,fl2) + select nm, fl2 from name, flag2 where name.pk = flag2.pk; + +analyze table t1 persistent for all; + +let $a= +`select concat(left((select nm from t1 where fl2=0 order by RAND(13) limit 1),2),'%')`; +eval select '$a' as a; + +set optimizer_switch='rowid_filter=on'; +eval +explain +select * from t1 where nm like '$a' AND fl2 = 0; +--source include/analyze-format.inc +eval +analyze format=json +select * from t1 where nm like '$a' AND fl2 = 0; +eval +select * from t1 where nm like '$a' AND fl2 = 0; + +drop table name, flag2; +drop table t1; + +# This test shows that if the container is empty there are no lookups into it + +create table t1 ( + pk int primary key auto_increment, + nm char(255), + fl1 tinyint default 0, + fl2 int default 0, + index idx1(nm, fl1), + index idx2(fl2) +) engine=myisam; + +create table name ( + pk int primary key auto_increment, + nm bigint +) engine=myisam; + +create table flag2 ( + pk int primary key auto_increment, + fl2 int +) engine=myisam; + +insert into name(nm) select seq from seq_1_to_10000 order by rand(17); +insert into flag2(fl2) select seq mod 10 from seq_1_to_10000 order by rand(19); + +insert into t1(nm,fl2) + select nm, fl2 from name, flag2 where name.pk = flag2.pk; + +analyze table t1 persistent for all; + +let $q= +select * from t1 +where +( + nm like '3400%' or nm like '3402%' or nm like '3403%' or + nm like '3404%' or nm like '3405%' or nm like '3406%' or nm like '3407%' or + nm like '3409%' or + nm like '3411%' or nm like '3412%' or nm like '3413%' or + nm like '3414%' or nm like '3415%' or nm like '3416%' or nm like '3417%' or + nm like '3418%' or nm like '3419%' or + nm like '3421%' or nm like '3422%' or nm like '3423%' or + nm like '3424%' or nm like '3425%' or nm like '3426%' or nm like '3427%' or + nm like '3428%' or nm like '3429%' or + nm like '3430%' or nm like '3431%' or nm like '3432%' or nm like '3433%' or + nm like '3434%' or nm like '3435%' or nm like '3436%' or nm like '3437%' or + nm like '3439%' or + nm like '3440%' or nm like '3441%' or nm like '3442%' or nm like '3443%' or + nm like '3444%' or nm like '3445%' or nm like '3446%' or nm like '3447%' or + nm like '3448%' +) and fl2 = 0; + +eval $q; +--source include/analyze-format.inc +eval analyze format=json $q; + +create table t0 select * from t1 where nm like '34%'; +delete from t1 using t1,t0 where t1.nm=t0.nm; +--source include/analyze-format.inc +eval analyze format=json $q; + +drop table t0; + +set optimizer_switch='rowid_filter=default'; + +drop table name, flag2; +drop table t1; diff --git a/mysql-test/suite/maria/icp.result b/mysql-test/suite/maria/icp.result index a421ba6d3ea..d990d8b0855 100644 --- a/mysql-test/suite/maria/icp.result +++ b/mysql-test/suite/maria/icp.result @@ -409,7 +409,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 ORDER BY c1 LIMIT 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,k1 k1 5 NULL 4 Using index condition; Using where +1 SIMPLE t1 range|filter PRIMARY,k1 k1|PRIMARY 5|4 NULL 4 (38%) Using index condition; Using where; Using rowid filter DROP TABLE t1; # # diff --git a/mysys/array.c b/mysys/array.c index 6e871ee6343..02a54d44656 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -92,7 +92,7 @@ my_bool init_dynamic_array2(PSI_memory_key psi_key, DYNAMIC_ARRAY *array, my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void * element) { void *buffer; - if (array->elements == array->max_element) + if (unlikely(array->elements == array->max_element)) { /* Call only when necessary */ if (!(buffer=alloc_dynamic(array))) return TRUE; @@ -102,7 +102,42 @@ my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void * element) buffer=array->buffer+(array->elements * array->size_of_element); array->elements++; } - memcpy(buffer,element,(size_t) array->size_of_element); + memcpy(buffer, element, array->size_of_element); + return FALSE; +} + + +/* Fast version of appending to dynamic array */ + +void init_append_dynamic(DYNAMIC_ARRAY_APPEND *append, + DYNAMIC_ARRAY *array) +{ + append->array= array; + append->pos= array->buffer + array->elements * array->size_of_element; + append->end= array->buffer + array->max_element * array->size_of_element; +} + + +my_bool append_dynamic(DYNAMIC_ARRAY_APPEND *append, + const void *element) +{ + DYNAMIC_ARRAY *array= append->array; + size_t size_of_element= array->size_of_element; + if (unlikely(append->pos == append->end)) + { + void *buffer; + if (!(buffer=alloc_dynamic(array))) + return TRUE; + append->pos= (uchar*)buffer + size_of_element; + append->end= array->buffer + array->max_element * size_of_element; + memcpy(buffer, element, size_of_element); + } + else + { + array->elements++; + memcpy(append->pos, element, size_of_element); + append->pos+= size_of_element; + } return FALSE; } @@ -281,7 +316,7 @@ my_bool allocate_dynamic(DYNAMIC_ARRAY *array, size_t max_elements) void get_dynamic(DYNAMIC_ARRAY *array, void *element, size_t idx) { - if (idx >= array->elements) + if (unlikely(idx >= array->elements)) { DBUG_PRINT("warning",("To big array idx: %d, array size is %d", idx,array->elements)); @@ -306,7 +341,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array) /* Just mark as empty if we are using a static buffer */ - if (!(array->malloc_flags & MY_INIT_BUFFER_USED) && array->buffer) + if (array->buffer && !(array->malloc_flags & MY_INIT_BUFFER_USED)) my_free(array->buffer); array->buffer= 0; diff --git a/sql/handler.cc b/sql/handler.cc index d409de8f298..0d66da589f2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6964,8 +6964,7 @@ check_result_t handler_rowid_filter_check(void *h_arg) extern "C" int handler_rowid_filter_is_active(void *h_arg) { - if (!h_arg) - return false; + DBUG_ASSERT(h_arg); handler *h= (handler*) h_arg; return h->rowid_filter_is_active; } diff --git a/sql/handler.h b/sql/handler.h index 8a16f8bbbea..0166c2526e1 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -4665,10 +4665,14 @@ public: DBUG_ASSERT(pushed_rowid_filter != NULL && save_pushed_rowid_filter == NULL); save_pushed_rowid_filter= pushed_rowid_filter; - if (rowid_filter_is_active) - save_rowid_filter_is_active= rowid_filter_is_active; + save_rowid_filter_is_active= rowid_filter_is_active; pushed_rowid_filter= NULL; - rowid_filter_is_active= false; + + if (rowid_filter_is_active) + { + rowid_filter_is_active= false; + rowid_filter_changed(); + } } virtual void enable_pushed_rowid_filter() @@ -4676,12 +4680,17 @@ public: DBUG_ASSERT(save_pushed_rowid_filter != NULL && pushed_rowid_filter == NULL); pushed_rowid_filter= save_pushed_rowid_filter; - if (save_rowid_filter_is_active) - rowid_filter_is_active= true; save_pushed_rowid_filter= NULL; + if (save_rowid_filter_is_active) + { + rowid_filter_is_active= true; + rowid_filter_changed(); + } } virtual bool rowid_filter_push(Rowid_filter *rowid_filter) { return true; } + /* Signal that rowid filter may have been enabled / disabled */ + virtual void rowid_filter_changed() {} /* Needed for partition / spider */ virtual TABLE_LIST *get_next_global_for_child() { return NULL; } diff --git a/sql/optimizer_defaults.h b/sql/optimizer_defaults.h index 26c54464219..a3c22d898cf 100644 --- a/sql/optimizer_defaults.h +++ b/sql/optimizer_defaults.h @@ -86,6 +86,13 @@ /* Rowid copy is usually just a single memcpy of a short string */ #define DEFAULT_ROWID_COPY_COST 0.000002653 +/* + Cost modifiers rowid_filter. These takes into account the overhead of + using and calling Rowid_filter_sorted_array::check() from the engine +*/ +#define ROWID_FILTER_PER_CHECK_MODIFIER 4 /* times key_copy_cost */ +#define ROWID_FILTER_PER_ELEMENT_MODIFIER 3 /* times rowid_compare_cost */ + /* Average disk seek time on a hard disk is 8-10 ms, which is also about the time to read a IO_SIZE (8192) block. diff --git a/sql/rowid_filter.cc b/sql/rowid_filter.cc index 4d6bf4ea98c..bf768218cff 100644 --- a/sql/rowid_filter.cc +++ b/sql/rowid_filter.cc @@ -19,6 +19,7 @@ #include "sql_class.h" #include "opt_range.h" #include "rowid_filter.h" +#include "optimizer_defaults.h" #include "sql_select.h" #include "opt_trace.h" @@ -127,8 +128,10 @@ void Range_rowid_filter_cost_info::init(Rowid_filter_container_type cont_type, cost_of_building_range_filter= build_cost(container_type); where_cost= tab->in_use->variables.optimizer_where_cost; - base_lookup_cost= tab->file->ROW_NEXT_FIND_COST; - rowid_compare_cost= tab->file->ROWID_COMPARE_COST; + base_lookup_cost= (ROWID_FILTER_PER_CHECK_MODIFIER * + tab->file->KEY_COPY_COST); + rowid_compare_cost= (ROWID_FILTER_PER_ELEMENT_MODIFIER * + tab->file->ROWID_COMPARE_COST); selectivity= est_elements/((double) table->stat_records()); gain= avg_access_and_eval_gain_per_row(container_type, tab->file->ROW_LOOKUP_COST); @@ -589,41 +592,40 @@ bool Range_rowid_filter::fill() file->pushed_idx_cond_keyno= MAX_KEY; file->in_range_check_pushed_down= false; - /* We're going to just read rowids / primary keys */ + /* We're going to just read rowids / clustered primary keys */ table->prepare_for_position(); - table->file->ha_start_keyread(quick->index); + file->ha_start_keyread(quick->index); if (quick->init() || quick->reset()) - rc= 1; + goto end; - while (!rc) + while (!(rc= quick->get_next())) { - rc= quick->get_next(); - if (thd->killed) - rc= 1; - if (!rc) + file->position(quick->record); + if (container->add(NULL, (char*) file->ref) || thd->killed) { - file->position(quick->record); - if (container->add(NULL, (char*) file->ref)) - rc= 1; - else - tracker->increment_container_elements_count(); + rc= 1; + break; } } +end: quick->range_end(); - table->file->ha_end_keyread(); + file->ha_end_keyread(); table->status= table_status_save; file->pushed_idx_cond= pushed_idx_cond_save; file->pushed_idx_cond_keyno= pushed_idx_cond_keyno_save; file->in_range_check_pushed_down= in_range_check_pushed_down_save; - tracker->report_container_buff_size(table->file->ref_length); + + tracker->set_container_elements_count(container->elements()); + tracker->report_container_buff_size(file->ref_length); if (rc != HA_ERR_END_OF_FILE) return 1; - table->file->rowid_filter_is_active= true; + container->sort(refpos_order_cmp, (void *) file); + file->rowid_filter_is_active= container->elements() != 0; return 0; } @@ -647,18 +649,13 @@ bool Range_rowid_filter::fill() bool Rowid_filter_sorted_array::check(void *ctxt, char *elem) { - TABLE *table= (TABLE *) ctxt; - if (!is_checked) - { - refpos_container.sort(refpos_order_cmp, (void *) (table->file)); - is_checked= true; - } + handler *file= ((TABLE *) ctxt)->file; int l= 0; int r= refpos_container.elements()-1; while (l <= r) { int m= (l + r) / 2; - int cmp= refpos_order_cmp((void *) (table->file), + int cmp= refpos_order_cmp((void *) file, refpos_container.get_pos(m), elem); if (cmp == 0) return true; @@ -675,14 +672,6 @@ Range_rowid_filter::~Range_rowid_filter() { delete container; container= 0; - if (select) - { - if (select->quick) - { - delete select->quick; - select->quick= 0; - } - delete select; - select= 0; - } + delete select; + select= 0; } diff --git a/sql/rowid_filter.h b/sql/rowid_filter.h index f761e1220aa..7c5b561107a 100644 --- a/sql/rowid_filter.h +++ b/sql/rowid_filter.h @@ -186,7 +186,10 @@ public: virtual bool check(void *ctxt, char *elem) = 0; /* True if the container does not contain any element */ - virtual bool is_empty() = 0; + bool is_empty() { return elements() == 0; } + virtual uint elements() = 0; + virtual void sort (int (*cmp) (void *ctxt, const void *el1, const void *el2), + void *cmp_arg) = 0; virtual ~Rowid_filter_container() {} }; @@ -264,7 +267,7 @@ public: bool build() { return fill(); } - bool check(char *elem) + bool check(char *elem) override { if (container->is_empty()) return false; @@ -296,52 +299,49 @@ class Refpos_container_sorted_array : public Sql_alloc /* Number of bytes allocated for an element */ uint elem_size; /* The dynamic array over which the wrapper is built */ - Dynamic_array *array; + DYNAMIC_ARRAY array; + DYNAMIC_ARRAY_APPEND append; public: Refpos_container_sorted_array(uint max_elems, uint elem_sz) - : max_elements(max_elems), elem_size(elem_sz), array(0) {} + :max_elements(max_elems), elem_size(elem_sz) + { + bzero(&array, sizeof(array)); + } ~Refpos_container_sorted_array() { - delete array; - array= 0; + delete_dynamic(&array); } bool alloc() { - array= new Dynamic_array (PSI_INSTRUMENT_MEM, - elem_size * max_elements, - elem_size * max_elements/sizeof(char) + 1); - return array == NULL; + /* This can never fail as things will be allocated on demand */ + init_dynamic_array2(PSI_INSTRUMENT_MEM, &array, elem_size, 0, + max_elements, 512, MYF(0)); + init_append_dynamic(&append, &array); + return 0; } - bool add(char *elem) + bool add(const char *elem) { - for (uint i= 0; i < elem_size; i++) - { - if (array->append(elem[i])) - return true; - } - return false; + return append_dynamic(&append, elem); } - char *get_pos(uint n) + inline uchar *get_pos(uint n) const { - return array->get_pos(n * elem_size); + return dynamic_array_ptr(&array, n); } - uint elements() { return (uint) (array->elements() / elem_size); } + inline uint elements() const { return (uint) array.elements; } void sort (int (*cmp) (void *ctxt, const void *el1, const void *el2), void *cmp_arg) { - my_qsort2(array->front(), array->elements()/elem_size, + my_qsort2(array.buffer, array.elements, elem_size, (qsort2_cmp) cmp, cmp_arg); } - - bool is_empty() { return elements() == 0; } }; @@ -356,23 +356,29 @@ class Rowid_filter_sorted_array: public Rowid_filter_container { /* The dynamic array to store rowids / primary keys */ Refpos_container_sorted_array refpos_container; - /* Initially false, becomes true after the first call of (check() */ - bool is_checked; public: Rowid_filter_sorted_array(uint elems, uint elem_size) - : refpos_container(elems, elem_size), is_checked(false) {} + : refpos_container(elems, elem_size) {} - Rowid_filter_container_type get_type() + Rowid_filter_container_type get_type() override { return SORTED_ARRAY_CONTAINER; } - bool alloc() { return refpos_container.alloc(); } + bool alloc() override { return refpos_container.alloc(); } - bool add(void *ctxt, char *elem) { return refpos_container.add(elem); } + bool add(void *ctxt, char *elem) override + { return refpos_container.add(elem); } - bool check(void *ctxt, char *elem); + bool check(void *ctxt, char *elem) override; + + uint elements() override { return refpos_container.elements(); } + + void sort (int (*cmp) (void *ctxt, const void *el1, const void *el2), + void *cmp_arg) + { + return refpos_container.sort(cmp, cmp_arg); + } - bool is_empty() { return refpos_container.is_empty(); } }; /** diff --git a/sql/sql_analyze_stmt.h b/sql/sql_analyze_stmt.h index 4136dff1e0c..8f60d4b523a 100644 --- a/sql/sql_analyze_stmt.h +++ b/sql/sql_analyze_stmt.h @@ -414,7 +414,8 @@ public: n_positive_checks++; } - inline void increment_container_elements_count() { container_elements++; } + inline void set_container_elements_count(uint elements) + { container_elements= elements; } uint get_container_elements() const { return container_elements; } diff --git a/sql/uniques.cc b/sql/uniques.cc index 1886ad278da..36725e80a6b 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -170,10 +170,9 @@ static double get_merge_buffers_cost(THD *thd, uint *buff_elems, uint elem_size, size_t n_buffers= last - first + 1; - /* Using log2(n)=log(n)/log(2) formula */ return (2*((double)total_buf_elems*elem_size) / IO_SIZE * default_optimizer_costs.disk_read_cost + - total_buf_elems*log((double) n_buffers) * compare_factor / M_LN2); + total_buf_elems*log2((double) n_buffers) * compare_factor); } diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 13af09361be..fa7e129752a 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -4040,7 +4040,8 @@ row_search_idx_cond_check( ut_ad(rec_offs_validate(rec, prebuilt->index, offsets)); if (!prebuilt->idx_cond) { - if (!handler_rowid_filter_is_active(prebuilt->pk_filter)) { + if (!prebuilt->pk_filter || + !handler_rowid_filter_is_active(prebuilt->pk_filter)) { return(CHECK_POS); } } else { @@ -4082,7 +4083,8 @@ row_search_idx_cond_check( switch (result) { case CHECK_POS: - if (handler_rowid_filter_is_active(prebuilt->pk_filter)) { + if (prebuilt->pk_filter && + handler_rowid_filter_is_active(prebuilt->pk_filter)) { ut_ad(!prebuilt->index->is_primary()); if (prebuilt->clust_index_was_generated) { ulint len; diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index f8b72bf85d3..691edba8d55 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1094,8 +1094,9 @@ ulong ha_maria::index_flags(uint inx, uint part, bool all_parts) const } else { - flags= HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | - HA_READ_ORDER | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN; + flags= (HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | + HA_READ_ORDER | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN | + HA_DO_RANGE_FILTER_PUSHDOWN); } return flags; } @@ -2535,10 +2536,12 @@ int ha_maria::index_read_idx_map(uchar * buf, uint index, const uchar * key, end_range= NULL; if (index == pushed_idx_cond_keyno) ma_set_index_cond_func(file, handler_index_cond_check, this); + if (pushed_rowid_filter && handler_rowid_filter_is_active(this)) + ma_set_rowid_filter_func(file, handler_rowid_filter_check, this); error= maria_rkey(file, buf, index, key, keypart_map, find_flag); - ma_set_index_cond_func(file, NULL, 0); + ma_reset_index_filter_functions(file); return error; } @@ -2612,18 +2615,22 @@ int ha_maria::index_next_same(uchar * buf, int ha_maria::index_init(uint idx, bool sorted) { - active_index=idx; + active_index= idx; if (pushed_idx_cond_keyno == idx) ma_set_index_cond_func(file, handler_index_cond_check, this); + if (pushed_rowid_filter && handler_rowid_filter_is_active(this)) + ma_set_rowid_filter_func(file, handler_rowid_filter_check, this); return 0; } - int ha_maria::index_end() { + /* + in_range_check_pushed_down and index_id_cond_keyno are reset in + handler::cancel_pushed_idx_cond() + */ active_index=MAX_KEY; - ma_set_index_cond_func(file, NULL, 0); - in_range_check_pushed_down= FALSE; + ma_reset_index_filter_functions(file); ds_mrr.dsmrr_close(); return 0; } @@ -2811,7 +2818,7 @@ int ha_maria::extra(enum ha_extra_function operation) int ha_maria::reset(void) { - ma_set_index_cond_func(file, NULL, 0); + ma_reset_index_filter_functions(file); ds_mrr.dsmrr_close(); if (file->trn) { @@ -3871,8 +3878,6 @@ bool ha_maria::is_changed() const static void aria_update_optimizer_costs(OPTIMIZER_COSTS *costs) { - costs->rowid_copy_cost= 0.000001; // Just a short memcopy - costs->rowid_cmp_cost= 0.000001; // Just a short memcmp } @@ -4269,6 +4274,26 @@ Item *ha_maria::idx_cond_push(uint keyno_arg, Item* idx_cond_arg) return NULL; } +bool ha_maria::rowid_filter_push(Rowid_filter* rowid_filter) +{ + /* This will be used in index_init() */ + pushed_rowid_filter= rowid_filter; + return false; +} + + +/* Enable / disable rowid filter depending if it's active or not */ + +void ha_maria::rowid_filter_changed() +{ + if (pushed_rowid_filter && handler_rowid_filter_is_active(this)) + ma_set_rowid_filter_func(file, handler_rowid_filter_check, this); + else + ma_set_rowid_filter_func(file, NULL, this); +} + + + /** Find record by unique constrain (used in temporary tables) diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h index 1486c2d7904..bea913e424f 100644 --- a/storage/maria/ha_maria.h +++ b/storage/maria/ha_maria.h @@ -184,6 +184,8 @@ public: /* Index condition pushdown implementation */ Item *idx_cond_push(uint keyno, Item* idx_cond) override final; + bool rowid_filter_push(Rowid_filter* rowid_filter) override; + void rowid_filter_changed() override; int find_unique_row(uchar *record, uint unique_idx) override final; diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c index 425cb421e22..087100e3d8c 100644 --- a/storage/maria/ma_extra.c +++ b/storage/maria/ma_extra.c @@ -510,8 +510,17 @@ void ma_set_index_cond_func(MARIA_HA *info, index_cond_func_t func, { info->index_cond_func= func; info->index_cond_func_arg= func_arg; + info->has_cond_pushdown= (info->index_cond_func || info->rowid_filter_func); } +void ma_set_rowid_filter_func(MARIA_HA *info, + rowid_filter_func_t check_func, + void *func_arg) +{ + info->rowid_filter_func= check_func; + info->rowid_filter_func_arg= func_arg; + info->has_cond_pushdown= (info->index_cond_func || info->rowid_filter_func); +} /* Start/Stop Inserting Duplicates Into a Table, WL#1648. diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c index ddf92654be0..3de6b8b74c5 100644 --- a/storage/maria/ma_info.c +++ b/storage/maria/ma_info.c @@ -20,14 +20,6 @@ #include #endif - /* Get position to last record */ - -MARIA_RECORD_POS maria_position(MARIA_HA *info) -{ - return info->cur_row.lastpos; -} - - uint maria_max_key_length() { uint tmp= (_ma_max_key_length() - 8 - HA_MAX_KEY_SEG*3); diff --git a/storage/maria/ma_key.c b/storage/maria/ma_key.c index d47e8cf715a..1b58c1c12c8 100644 --- a/storage/maria/ma_key.c +++ b/storage/maria/ma_key.c @@ -678,22 +678,44 @@ int _ma_read_key_record(MARIA_HA *info, uchar *buf, MARIA_RECORD_POS filepos) CHECK_OUT_OF_RANGE to indicate that we don't have any active row. */ -check_result_t ma_check_index_cond(register MARIA_HA *info, uint keynr, - uchar *record) +check_result_t ma_check_index_cond_real(register MARIA_HA *info, uint keynr, + uchar *record) { check_result_t res= CHECK_POS; + DBUG_ASSERT(info->index_cond_func || info->rowid_filter_func); + + if (_ma_put_key_in_record(info, keynr, FALSE, record)) + { + /* Impossible case; Can only happen if bug in code */ + _ma_print_error(info, HA_ERR_CRASHED, 0); + info->cur_row.lastpos= HA_OFFSET_ERROR; /* No active record */ + my_errno= HA_ERR_CRASHED; + return CHECK_ERROR; + } + if (info->index_cond_func) { - if (_ma_put_key_in_record(info, keynr, FALSE, record)) + if ((res= info->index_cond_func(info->index_cond_func_arg)) == + CHECK_OUT_OF_RANGE) { - /* Impossible case; Can only happen if bug in code */ - _ma_print_error(info, HA_ERR_CRASHED, 0); + /* We got beyond the end of scanned range */ info->cur_row.lastpos= HA_OFFSET_ERROR; /* No active record */ - my_errno= HA_ERR_CRASHED; - res= CHECK_ERROR; + my_errno= HA_ERR_END_OF_FILE; + return res; } - else if ((res= info->index_cond_func(info->index_cond_func_arg)) == - CHECK_OUT_OF_RANGE) + /* + If we got an error, out-of-range condition, or ICP condition computed to + FALSE - we don't need to check the Rowid Filter. + */ + if (res != CHECK_POS) + return res; + } + + /* Check the Rowid Filter, if present */ + if (info->rowid_filter_func) + { + if ((res= info->rowid_filter_func(info->rowid_filter_func_arg)) == + CHECK_OUT_OF_RANGE) { /* We got beyond the end of scanned range */ info->cur_row.lastpos= HA_OFFSET_ERROR; /* No active record */ diff --git a/storage/maria/ma_rkey.c b/storage/maria/ma_rkey.c index 8cd82e1c6fc..7e43ed4befa 100644 --- a/storage/maria/ma_rkey.c +++ b/storage/maria/ma_rkey.c @@ -120,6 +120,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data, /* The key references a concurrently inserted record. */ if (search_flag == HA_READ_KEY_EXACT && + (keyinfo->flag & HA_NOSAME) && last_used_keyseg == keyinfo->seg + keyinfo->keysegs) { /* Simply ignore the key if it matches exactly. (Bug #29838) */ diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 2ed4a3f502c..f17edfe0657 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -213,7 +213,6 @@ extern int maria_rsame_with_pos(MARIA_HA *file, uchar *record, extern int maria_update(MARIA_HA *file, const uchar *old, const uchar *new_record); extern int maria_write(MARIA_HA *file, const uchar *buff); -extern MARIA_RECORD_POS maria_position(MARIA_HA *file); extern int maria_status(MARIA_HA *info, MARIA_INFO *x, uint flag); extern int maria_lock_database(MARIA_HA *file, int lock_type); extern int maria_delete_table(const char *name); @@ -1011,6 +1010,7 @@ struct st_maria_handler my_bool switched_transactional; /* If transaction will autocommit */ my_bool autocommit; + my_bool has_cond_pushdown; #ifdef _WIN32 my_bool owned_by_merge; /* This Maria table is part of a merge union */ #endif @@ -1022,6 +1022,8 @@ struct st_maria_handler my_bool create_unique_index_by_sort; index_cond_func_t index_cond_func; /* Index condition function */ void *index_cond_func_arg; /* parameter for the func */ + rowid_filter_func_t rowid_filter_func; /* rowid filter check function */ + void *rowid_filter_func_arg; /* parameter for the func */ }; /* Table options for the Aria and S3 storage engine */ @@ -1347,7 +1349,11 @@ extern int _ma_read_rnd_no_record(MARIA_HA *info, uchar *buf, MARIA_RECORD_POS filepos, my_bool skip_deleted_blocks); my_off_t _ma_no_keypos_to_recpos(MARIA_SHARE *share, my_off_t pos); - +/* Get position to last record */ +static inline MARIA_RECORD_POS maria_position(MARIA_HA *info) +{ + return info->cur_row.lastpos; +} extern my_bool _ma_ck_write(MARIA_HA *info, MARIA_KEY *key); extern my_bool _ma_enlarge_root(MARIA_HA *info, MARIA_KEY *key, MARIA_RECORD_POS *root); @@ -1734,7 +1740,25 @@ extern my_bool maria_flush_log_for_page_none(PAGECACHE_IO_HOOK_ARGS *args); extern PAGECACHE *maria_log_pagecache; extern void ma_set_index_cond_func(MARIA_HA *info, index_cond_func_t func, void *func_arg); -check_result_t ma_check_index_cond(MARIA_HA *info, uint keynr, uchar *record); +extern void ma_set_rowid_filter_func(MARIA_HA *info, + rowid_filter_func_t check_func, + void *func_arg); +static inline void ma_reset_index_filter_functions(MARIA_HA *info) +{ + info->index_cond_func= NULL; + info->rowid_filter_func= NULL; + info->has_cond_pushdown= 0; +} +check_result_t ma_check_index_cond_real(MARIA_HA *info, uint keynr, + uchar *record); +static inline check_result_t ma_check_index_cond(MARIA_HA *info, uint keynr, + uchar *record) +{ + if (!info->has_cond_pushdown) + return CHECK_POS; + return ma_check_index_cond_real(info, keynr, record); +} + extern my_bool ma_yield_and_check_if_killed(MARIA_HA *info, int inx); extern my_bool ma_killed_standalone(MARIA_HA *); diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index df47bda9c86..bd6cfe0c3bc 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1971,9 +1971,8 @@ int ha_myisam::index_init(uint idx, bool sorted) active_index=idx; if (pushed_idx_cond_keyno == idx) mi_set_index_cond_func(file, handler_index_cond_check, this); - if (pushed_rowid_filter) - mi_set_rowid_filter_func(file, handler_rowid_filter_check, - handler_rowid_filter_is_active, this); + if (pushed_rowid_filter && handler_rowid_filter_is_active(this)) + mi_set_rowid_filter_func(file, handler_rowid_filter_check, this); return 0; } @@ -1981,11 +1980,10 @@ int ha_myisam::index_init(uint idx, bool sorted) int ha_myisam::index_end() { DBUG_ENTER("ha_myisam::index_end"); - active_index=MAX_KEY; - //pushed_idx_cond_keyno= MAX_KEY; + active_index= MAX_KEY; mi_set_index_cond_func(file, NULL, 0); in_range_check_pushed_down= FALSE; - mi_set_rowid_filter_func(file, NULL, NULL, 0); + mi_set_rowid_filter_func(file, NULL, 0); ds_mrr.dsmrr_close(); #if !defined(DBUG_OFF) && defined(SQL_SELECT_FIXED_FOR_UPDATE) file->update&= ~HA_STATE_AKTIV; // Forget active row @@ -2021,9 +2019,8 @@ int ha_myisam::index_read_idx_map(uchar *buf, uint index, const uchar *key, end_range= NULL; if (index == pushed_idx_cond_keyno) mi_set_index_cond_func(file, handler_index_cond_check, this); - if (pushed_rowid_filter) - mi_set_rowid_filter_func(file, handler_rowid_filter_check, - handler_rowid_filter_is_active, this); + if (pushed_rowid_filter && handler_rowid_filter_is_active(this)) + mi_set_rowid_filter_func(file, handler_rowid_filter_check, this); res= mi_rkey(file, buf, index, key, keypart_map, find_flag); mi_set_index_cond_func(file, NULL, 0); return res; @@ -2728,12 +2725,23 @@ Item *ha_myisam::idx_cond_push(uint keyno_arg, Item* idx_cond_arg) bool ha_myisam::rowid_filter_push(Rowid_filter* rowid_filter) { + /* This will be used in index_init() */ pushed_rowid_filter= rowid_filter; - mi_set_rowid_filter_func(file, handler_rowid_filter_check, - handler_rowid_filter_is_active, this); return false; } + +/* Enable / disable rowid filter depending if it's active or not */ + +void ha_myisam::rowid_filter_changed() +{ + if (pushed_rowid_filter && handler_rowid_filter_is_active(this)) + mi_set_rowid_filter_func(file, handler_rowid_filter_check, this); + else + mi_set_rowid_filter_func(file, NULL, this); +} + + struct st_mysql_storage_engine myisam_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index d6ae007a446..0bea4938eb5 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -173,8 +173,9 @@ public: int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size); /* Index condition pushdown implementation */ - Item *idx_cond_push(uint keyno, Item* idx_cond); - bool rowid_filter_push(Rowid_filter* rowid_filter); + Item *idx_cond_push(uint keyno, Item* idx_cond) override; + bool rowid_filter_push(Rowid_filter* rowid_filter) override; + void rowid_filter_changed() override; private: DsMrr_impl ds_mrr; diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 66238745a04..e7e64edd926 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -376,16 +376,16 @@ void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t func, { info->index_cond_func= func; info->index_cond_func_arg= func_arg; + info->has_cond_pushdown= (info->index_cond_func || info->rowid_filter_func); } void mi_set_rowid_filter_func(MI_INFO *info, rowid_filter_func_t check_func, - rowid_filter_is_active_func_t is_active_func, void *func_arg) { info->rowid_filter_func= check_func; - info->rowid_filter_is_active_func= is_active_func; info->rowid_filter_func_arg= func_arg; + info->has_cond_pushdown= (info->index_cond_func || info->rowid_filter_func); } /* diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index 087eb59c7c0..bde3ee19e2c 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -510,14 +510,6 @@ int mi_unpack_index_tuple(MI_INFO *info, uint keynr, uchar *record) } -static int mi_check_rowid_filter_is_active(MI_INFO *info) -{ - if (info->rowid_filter_is_active_func == NULL) - return 0; - return info->rowid_filter_is_active_func(info->rowid_filter_func_arg); -} - - /* Check the current index tuple: Check ICP condition and/or Rowid Filter @@ -532,21 +524,23 @@ static int mi_check_rowid_filter_is_active(MI_INFO *info) Check result according to check_result_t definition */ -check_result_t mi_check_index_tuple(MI_INFO *info, uint keynr, uchar *record) +check_result_t mi_check_index_tuple_real(MI_INFO *info, uint keynr, uchar *record) { - int need_unpack= TRUE; check_result_t res= CHECK_POS; + DBUG_ASSERT(info->index_cond_func || info->rowid_filter_func); + + if (mi_unpack_index_tuple(info, keynr, record)) + return CHECK_ERROR; if (info->index_cond_func) { - if (mi_unpack_index_tuple(info, keynr, record)) - res= CHECK_ERROR; - else if ((res= info->index_cond_func(info->index_cond_func_arg)) == - CHECK_OUT_OF_RANGE) + if ((res= info->index_cond_func(info->index_cond_func_arg)) == + CHECK_OUT_OF_RANGE) { /* We got beyond the end of scanned range */ info->lastpos= HA_OFFSET_ERROR; /* No active record */ my_errno= HA_ERR_END_OF_FILE; + return res; } /* @@ -555,25 +549,17 @@ check_result_t mi_check_index_tuple(MI_INFO *info, uint keynr, uchar *record) */ if (res != CHECK_POS) return res; - - need_unpack= FALSE; } /* Check the Rowid Filter, if present */ - if (mi_check_rowid_filter_is_active(info)) + if (info->rowid_filter_func) { - /* Unpack the index tuple if we haven't done it already */ - if (need_unpack && mi_unpack_index_tuple(info, keynr, record)) - res= CHECK_ERROR; - else + if ((res= info->rowid_filter_func(info->rowid_filter_func_arg)) == + CHECK_OUT_OF_RANGE) { - if ((res= info->rowid_filter_func(info->rowid_filter_func_arg)) == - CHECK_OUT_OF_RANGE) - { - /* We got beyond the end of scanned range */ - info->lastpos= HA_OFFSET_ERROR; /* No active record */ - my_errno= HA_ERR_END_OF_FILE; - } + /* We got beyond the end of scanned range */ + info->lastpos= HA_OFFSET_ERROR; /* No active record */ + my_errno= HA_ERR_END_OF_FILE; } } return res; diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c index bf6f3ef852c..590981fb790 100644 --- a/storage/myisam/mi_rkey.c +++ b/storage/myisam/mi_rkey.c @@ -119,7 +119,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, while ((info->lastpos >= info->state->data_file_length && (search_flag != HA_READ_KEY_EXACT || last_used_keyseg != keyinfo->seg + keyinfo->keysegs)) || - (res= mi_check_index_tuple(info, inx, buf)) == CHECK_NEG) + (res= mi_check_index_tuple(info, inx, buf)) == CHECK_NEG) { uint not_used[2]; /* diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index c90d989c975..5ede6a6159c 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -304,10 +304,10 @@ struct st_myisam_info /* If info->buff has to be reread for rnext */ my_bool buff_used; my_bool create_unique_index_by_sort; + my_bool has_cond_pushdown; index_cond_func_t index_cond_func; /* Index condition function */ void *index_cond_func_arg; /* parameter for the func */ rowid_filter_func_t rowid_filter_func; /* rowid filter check function */ - rowid_filter_is_active_func_t rowid_filter_is_active_func; /* is activefunction */ void *rowid_filter_func_arg; /* parameter for the func */ THR_LOCK_DATA lock; uchar *rtree_recursion_state; /* For RTREE */ @@ -742,7 +742,15 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size); int mi_munmap_file(MI_INFO *info); void mi_remap_file(MI_INFO *info, my_off_t size); -check_result_t mi_check_index_tuple(MI_INFO *info, uint keynr, uchar *record); +check_result_t mi_check_index_tuple_real(MI_INFO *info, uint keynr, + uchar *record); +static inline check_result_t mi_check_index_tuple(MI_INFO *info, uint keynr, + uchar *record) +{ + if (!info->has_cond_pushdown && ! info->rowid_filter_func) + return CHECK_POS; + return mi_check_index_tuple_real(info, keynr, record); +} /* Functions needed by mi_check */ int killed_ptr(HA_CHECK *param); @@ -754,7 +762,6 @@ extern void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t check_func, void *func_arg); extern void mi_set_rowid_filter_func(MI_INFO *info, rowid_filter_func_t check_func, - rowid_filter_is_active_func_t is_active_func, void *func_arg); int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file, ulonglong *dirty_part_map); From cbf60dba7404edfa73ddf9b29c4488a4b3ea5684 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 9 Nov 2022 19:44:11 +0200 Subject: [PATCH 068/123] Small improvements to aria recovery I spent 4 hours on work and 12 hours of testing to try to find the reason for aria crashing in recovery when starting a new test, in which case the 'data directory' should be a copy of "install.db", but aria_log.00000001 content was not correct. The following changes are mostly done to make it a bit easier to find out more in case of future similar crashes: - Mark last_checkpoint_lsn volatile (safety). - Write checkpoint message to aria_recovery.trace - When compling with DBUG and with HAVE_DBUG_TRANSLOG_SRC, use checksum's for Aria log pages. We cannot have it on by default for DBUG servers yet as there is bugs when changing CRC between restarts. - Added a message to mtr --verbose when copying the data directory. - Removed extra linefeed in Aria recovery message (cleanup) --- mysql-test/mariadb-test-run.pl | 1 + storage/maria/ma_control_file.c | 2 +- storage/maria/ma_control_file.h | 2 +- storage/maria/ma_loghandler.h | 4 ++++ storage/maria/ma_recovery.c | 12 +++++++----- storage/maria/ma_recovery_util.c | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index b7e83261298..b75278e9a6d 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -2713,6 +2713,7 @@ sub mysql_server_start($) { # Copy datadir from installed system db my $path= ($opt_parallel == 1) ? "$opt_vardir" : "$opt_vardir/.."; my $install_db= "$path/install.db"; + mtr_verbose("copying $install_db to $datadir"); copytree($install_db, $datadir) if -d $install_db; mtr_error("Failed to copy system db to '$datadir'") unless -d $datadir; } diff --git a/storage/maria/ma_control_file.c b/storage/maria/ma_control_file.c index 21befb70bd9..237b75b99b7 100644 --- a/storage/maria/ma_control_file.c +++ b/storage/maria/ma_control_file.c @@ -104,7 +104,7 @@ one should increment the control file version number. This LSN serves for the two-checkpoint rule, and also to find the checkpoint record when doing a recovery. */ -LSN last_checkpoint_lsn= LSN_IMPOSSIBLE; +volatile LSN last_checkpoint_lsn= LSN_IMPOSSIBLE; uint32 last_logno= FILENO_IMPOSSIBLE; /** The maximum transaction id given to a transaction. It is only updated at diff --git a/storage/maria/ma_control_file.h b/storage/maria/ma_control_file.h index 40428f665f4..c74957b8322 100644 --- a/storage/maria/ma_control_file.h +++ b/storage/maria/ma_control_file.h @@ -37,7 +37,7 @@ C_MODE_START LSN of the last checkoint (if last_checkpoint_lsn == LSN_IMPOSSIBLE then there was never a checkpoint) */ -extern LSN last_checkpoint_lsn; +extern volatile LSN last_checkpoint_lsn; /* Last log number (if last_logno == FILENO_IMPOSSIBLE then there is no log file yet) diff --git a/storage/maria/ma_loghandler.h b/storage/maria/ma_loghandler.h index 3e5c58a8053..abe85a12727 100644 --- a/storage/maria/ma_loghandler.h +++ b/storage/maria/ma_loghandler.h @@ -25,7 +25,11 @@ /* minimum possible transaction log size */ #define TRANSLOG_MIN_FILE_SIZE (8*MB) /* transaction log default flags (TODO: make it global variable) */ +#ifdef HAVE_DBUG_TRANSLOG_CRC +#define TRANSLOG_DEFAULT_FLAGS IF_DBUG(TRANSLOG_PAGE_CRC,0) +#else #define TRANSLOG_DEFAULT_FLAGS 0 +#endif /* Transaction log flags. diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 006c8bef672..90d0ed3c708 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -133,7 +133,7 @@ static void new_transaction(uint16 sid, TrID long_id, LSN undo_lsn, static int new_table(uint16 sid, const char *name, LSN lsn_of_file_id); static int new_page(uint32 fileid, pgcache_page_no_t pageid, LSN rec_lsn, struct st_dirty_page *dirty_page); -static int close_all_tables(void); +static int close_all_tables(my_bool force_end_newline); static my_bool close_one_table(const char *name, TRANSLOG_ADDRESS addr); static void print_redo_phase_progress(TRANSLOG_ADDRESS addr); static void delete_all_transactions(); @@ -467,7 +467,7 @@ int maria_apply_log(LSN from_lsn, LSN end_redo_lsn, LSN end_undo_lsn, we don't use maria_panic() because it would maria_end(), and Recovery does not want that (we want to keep some modules initialized for runtime). */ - if (close_all_tables()) + if (close_all_tables(0)) { ma_message_no_user(0, "closing of tables failed"); goto err; @@ -495,6 +495,8 @@ int maria_apply_log(LSN from_lsn, LSN end_redo_lsn, LSN end_undo_lsn, /* No dirty pages, all tables are closed, no active transactions, save: */ if (ma_checkpoint_execute(CHECKPOINT_FULL, FALSE)) goto err; + tprint(tracef, "checkpoint done at " LSN_FMT "\n", + LSN_IN_PARTS(last_checkpoint_lsn)); } goto end; @@ -505,7 +507,7 @@ err2: delete_all_transactions(); if (!abort_message_printed) error= 1; - if (close_all_tables()) + if (close_all_tables(1)) { ma_message_no_user(0, "closing of tables failed"); } @@ -3472,7 +3474,7 @@ static int new_page(uint32 fileid, pgcache_page_no_t pageid, LSN rec_lsn, } -static int close_all_tables(void) +static int close_all_tables(my_bool force_end_newline) { int error= 0; uint count= 0; @@ -3537,7 +3539,7 @@ static int close_all_tables(void) } } end: - if (recovery_message_printed == REC_MSG_FLUSH) + if (recovery_message_printed == REC_MSG_FLUSH && (force_end_newline || error)) { fputc('\n', stderr); fflush(stderr); diff --git a/storage/maria/ma_recovery_util.c b/storage/maria/ma_recovery_util.c index fe43d812600..b8123c422c1 100644 --- a/storage/maria/ma_recovery_util.c +++ b/storage/maria/ma_recovery_util.c @@ -87,7 +87,7 @@ void eprint(FILE *trace_file __attribute__ ((unused)), if (!trace_file) trace_file= stderr; - if (procent_printed) + if (procent_printed && trace_file == stderr) { procent_printed= 0; /* In silent mode, print on another line than the 0% 10% 20% line */ From dd1a4131ef4df1bd72f5bd4352d9f93f6ba595e9 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 14 Nov 2022 17:08:09 +0200 Subject: [PATCH 069/123] Fixed bug in Aria with aria_log files that are exactly 8K In the case one has an old Aria log file that ands with a Aria checkpoint and the server restarts after next recovery, just after created a new Aria log file (of 8K), the Aria recovery code would abort. If one would try to delete all Aria log files after this (but not the aria_control_file), the server would crash during recovery. The problem was that translog_get_last_page_addr() would regard a log file of exactly 8K as illegal and the rest of the code could not handle this case. Another issue was that if there was a crash directly after the log file head was written to the next page, the code in translog_get_next_chunk() would crash. This patch fixes most of the issues, but not all. For Sanja to look at! Things fixed: - Added code to ignore 8K log files. - Removed ASSERT in translog_get_next_chunk() that checks if page only contains the log page header. --- storage/maria/aria_read_log.c | 13 +++- storage/maria/ma_loghandler.c | 133 +++++++++++++++++++++------------- storage/maria/ma_pagecache.c | 2 +- 3 files changed, 93 insertions(+), 55 deletions(-) diff --git a/storage/maria/aria_read_log.c b/storage/maria/aria_read_log.c index c0c76ed5590..85a6f4a5e97 100644 --- a/storage/maria/aria_read_log.c +++ b/storage/maria/aria_read_log.c @@ -139,6 +139,12 @@ int main(int argc, char **argv) if (opt_display_only) printf("You are using --display-only, NOTHING will be written to disk\n"); + if (translog_get_horizon() == LSN_IMPOSSIBLE) + { + fprintf(stdout, "The transaction log is empty\n"); + goto end; + } + lsn= translog_first_lsn_in_log(); if (lsn == LSN_ERROR) { @@ -147,7 +153,8 @@ int main(int argc, char **argv) } if (lsn == LSN_IMPOSSIBLE) { - fprintf(stdout, "The transaction log is empty\n"); + fprintf(stdout, "The transaction log is empty\n"); + goto end; } if (opt_start_from_checkpoint && !opt_start_from_lsn && last_checkpoint_lsn != LSN_IMPOSSIBLE) @@ -300,7 +307,7 @@ static struct my_option my_long_options[] = static void print_version(void) { - printf("%s Ver 1.5 for %s on %s\n", + printf("%s Ver 1.6 for %s on %s\n", my_progname_short, SYSTEM_TYPE, MACHINE_TYPE); } @@ -308,7 +315,7 @@ static void print_version(void) static void usage(void) { print_version(); - puts("Copyright (C) 2007 MySQL AB, 2009-2011 Monty Program Ab, 2020 MariaDB Corporation"); + puts("Copyright (C) 2007 MySQL AB, 2009-2011 Monty Program Ab, 2022 MariaDB Corporation"); puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,"); puts("and you are welcome to modify and redistribute it under the GPL license\n"); diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 8e6426e3aa4..c3615e5271c 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -478,7 +478,7 @@ static my_bool translog_page_validator(int res, PAGECACHE_IO_HOOK_ARGS *args); static my_bool translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner); static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected); LSN translog_next_LSN(TRANSLOG_ADDRESS addr, TRANSLOG_ADDRESS horizon); - +static void translog_free_link(PAGECACHE_BLOCK_LINK *direct_link); /* Initialize log_record_type_descriptors @@ -3116,7 +3116,10 @@ restart: PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_LEFT_UNLOCKED, NULL))) + { + translog_unlock(); DBUG_RETURN(NULL); + } } else skipped_data= 0; /* Read after skipped in buffer data */ @@ -3217,6 +3220,11 @@ restart: PAGECACHE_LOCK_READ : PAGECACHE_LOCK_LEFT_UNLOCKED), direct_link); + if (!buffer && direct_link) + { + translog_free_link(*direct_link); + *direct_link= 0; + } DBUG_PRINT("info", ("Direct link is assigned to : %p * %p", direct_link, (direct_link ? *direct_link : NULL))); @@ -3786,16 +3794,26 @@ my_bool translog_init_with_table(const char *directory, } else if (LSN_OFFSET(last_page) == 0) { - if (LSN_FILE_NO(last_page) == 1) + if (LSN_FILE_NO(last_page) == 1 || + !translog_is_file(LSN_FILE_NO(last_page-1))) { logs_found= 0; /* file #1 has no pages */ DBUG_PRINT("info", ("log found. But is is empty => no log assumed")); } else { - last_page-= LSN_ONE_FILE; - if (translog_get_last_page_addr(&last_page, &pageok, 0)) - goto err; + do + { + last_page-= LSN_ONE_FILE; + if (translog_get_last_page_addr(&last_page, &pageok, 0)) + goto err; + } + while (LSN_OFFSET(last_page) == 0 && LSN_FILE_NO(last_page) >= 1); + if (LSN_OFFSET(last_page) == 0) + { + /* All files have a size less than TRANSLOG_PAGE_SIZE */ + logs_found= 0; + } } } if (logs_found) @@ -3893,36 +3911,38 @@ my_bool translog_init_with_table(const char *directory, old_log_was_recovered= 1; /* This file is not written till the end so it should be last */ last_page= current_file_last_page; - /* TODO: issue warning */ } - do + if (LSN_OFFSET(current_file_last_page) >= TRANSLOG_PAGE_SIZE) { - TRANSLOG_VALIDATOR_DATA data; - TRANSLOG_PAGE_SIZE_BUFF psize_buff; - uchar *page; - data.addr= ¤t_page; - if ((page= translog_get_page(&data, psize_buff.buffer, NULL)) == NULL) - goto err; - if (data.was_recovered) + do { - DBUG_PRINT("error", ("file no: %lu (%d) " - "rec_offset: 0x%lx (%lu) (%d)", - (ulong) LSN_FILE_NO(current_page), - (uint3korr(page + 3) != - LSN_FILE_NO(current_page)), - (ulong) LSN_OFFSET(current_page), - (ulong) (LSN_OFFSET(current_page) / - TRANSLOG_PAGE_SIZE), - (uint3korr(page) != - LSN_OFFSET(current_page) / - TRANSLOG_PAGE_SIZE))); - old_log_was_recovered= 1; - break; - } - old_flags= page[TRANSLOG_PAGE_FLAGS]; - last_valid_page= current_page; - current_page+= TRANSLOG_PAGE_SIZE; /* increase offset */ - } while (current_page <= current_file_last_page); + TRANSLOG_VALIDATOR_DATA data; + TRANSLOG_PAGE_SIZE_BUFF psize_buff; + uchar *page; + data.addr= ¤t_page; + if ((page= translog_get_page(&data, psize_buff.buffer, NULL)) == NULL) + goto err; + if (data.was_recovered) + { + DBUG_PRINT("error", ("file no: %lu (%d) " + "rec_offset: 0x%lx (%lu) (%d)", + (ulong) LSN_FILE_NO(current_page), + (uint3korr(page + 3) != + LSN_FILE_NO(current_page)), + (ulong) LSN_OFFSET(current_page), + (ulong) (LSN_OFFSET(current_page) / + TRANSLOG_PAGE_SIZE), + (uint3korr(page) != + LSN_OFFSET(current_page) / + TRANSLOG_PAGE_SIZE))); + old_log_was_recovered= 1; + break; + } + old_flags= page[TRANSLOG_PAGE_FLAGS]; + last_valid_page= current_page; + current_page+= TRANSLOG_PAGE_SIZE; /* increase offset */ + } while (current_page <= current_file_last_page); + } current_page+= LSN_ONE_FILE; current_page= LSN_REPLACE_OFFSET(current_page, TRANSLOG_PAGE_SIZE); } while (LSN_FILE_NO(current_page) <= LSN_FILE_NO(last_page) && @@ -4014,7 +4034,7 @@ my_bool translog_init_with_table(const char *directory, } DBUG_PRINT("info", ("Logs found: %d was recovered: %d", logs_found, old_log_was_recovered)); - if (!logs_found) + if (!logs_found && !readonly) { TRANSLOG_FILE *file= (TRANSLOG_FILE*)my_malloc(PSI_INSTRUMENT_ME, sizeof(TRANSLOG_FILE), MYF(MY_WME)); @@ -4064,6 +4084,10 @@ my_bool translog_init_with_table(const char *directory, translog_start_buffer(log_descriptor.buffers, &log_descriptor.bc, 0); translog_new_page_header(&log_descriptor.horizon, &log_descriptor.bc); } + else if (readonly && !logs_found) + { + log_descriptor.horizon= LSN_IMPOSSIBLE; + } /* all LSNs that are on disk are flushed */ log_descriptor.log_start= log_descriptor.sent_to_disk= @@ -4145,21 +4169,24 @@ my_bool translog_init_with_table(const char *directory, uint32 file_no= LSN_FILE_NO(page_addr); my_bool last_page_ok; /* it is beginning of the current file */ - if (unlikely(file_no == 1)) + do { - /* - It is beginning of the log => there is no LSNs in the log => - There is no harm in leaving it "as-is". + if (unlikely(file_no == 1)) + { + /* + It is beginning of the log => there is no LSNs in the log => + There is no harm in leaving it "as-is". */ - log_descriptor.previous_flush_horizon= log_descriptor.horizon; - DBUG_PRINT("info", ("previous_flush_horizon: " LSN_FMT, - LSN_IN_PARTS(log_descriptor. + log_descriptor.previous_flush_horizon= log_descriptor.horizon; + DBUG_PRINT("info", ("previous_flush_horizon: " LSN_FMT, + LSN_IN_PARTS(log_descriptor. previous_flush_horizon))); - DBUG_RETURN(0); - } - file_no--; - page_addr= MAKE_LSN(file_no, TRANSLOG_PAGE_SIZE); - translog_get_last_page_addr(&page_addr, &last_page_ok, 0); + DBUG_RETURN(0); + } + file_no--; + page_addr= MAKE_LSN(file_no, TRANSLOG_PAGE_SIZE); + translog_get_last_page_addr(&page_addr, &last_page_ok, 0); + } while (LSN_OFFSET(page_addr) == 0); /* page should be OK as it is not the last file */ DBUG_ASSERT(last_page_ok); } @@ -6905,17 +6932,19 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner) /* if it is log end it have to be caught before */ DBUG_ASSERT(LSN_FILE_NO(scanner->horizon) > LSN_FILE_NO(scanner->page_addr)); - scanner->page_addr+= LSN_ONE_FILE; - scanner->page_addr= LSN_REPLACE_OFFSET(scanner->page_addr, - TRANSLOG_PAGE_SIZE); - if (translog_scanner_set_last_page(scanner)) - DBUG_RETURN(1); + do + { + scanner->page_addr+= LSN_ONE_FILE; + scanner->page_addr= LSN_REPLACE_OFFSET(scanner->page_addr, + TRANSLOG_PAGE_SIZE); + if (translog_scanner_set_last_page(scanner)) + DBUG_RETURN(1); + } while (!LSN_OFFSET(scanner->last_file_page)); } else { scanner->page_addr+= TRANSLOG_PAGE_SIZE; /* offset increased */ } - if (translog_scanner_get_page(scanner)) DBUG_RETURN(1); @@ -6926,7 +6955,9 @@ translog_get_next_chunk(TRANSLOG_SCANNER_DATA *scanner) scanner->page_offset= 0; DBUG_RETURN(0); } +#ifdef CHECK_EMPTY_PAGE DBUG_ASSERT(scanner->page[scanner->page_offset] != TRANSLOG_FILLER); +#endif } DBUG_RETURN(0); } diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index 2f187090f53..c4c85d0bdd0 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -5227,7 +5227,7 @@ int flush_pagecache_blocks_with_filter(PAGECACHE *pagecache, { int res; DBUG_ENTER("flush_pagecache_blocks_with_filter"); - DBUG_PRINT("enter", ("pagecache: %p", pagecache)); + DBUG_PRINT("enter", ("pagecache: %p fd: %di", pagecache, file->file)); if (pagecache->disk_blocks <= 0) DBUG_RETURN(0); From 98879f8d43e0adc322acf2b3db10c4c57324ef9a Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 18 Nov 2022 13:51:15 +0200 Subject: [PATCH 070/123] Version change to 11.0 --- VERSION | 2 +- mysql-test/main/comments.result | 6 ++++++ mysql-test/main/comments.test | 2 ++ mysql-test/main/mysql_upgrade.test | 12 +++++++++++- .../create_and_drop_role_invalid_user_table.test | 4 +--- mysql-test/suite/sys_vars/r/sysvars_star.result | 2 +- storage/spider/spd_init_query.h | 14 +++----------- 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/VERSION b/VERSION index 2b0eac3dbce..c1aee6d461c 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=11 MYSQL_VERSION_MINOR=0 MYSQL_VERSION_PATCH=1 -SERVER_MATURITY=gamma +SERVER_MATURITY=alpha diff --git a/mysql-test/main/comments.result b/mysql-test/main/comments.result index 8b3f9fba382..506c31b07b6 100644 --- a/mysql-test/main/comments.result +++ b/mysql-test/main/comments.result @@ -67,6 +67,9 @@ SELECT 1 /*!100000 +1*/; SELECT 1 /*!210000 +1*/; 1 1 +SELECT 1 /*!190000 +1*/; +1 +1 # # Tesing that versions >= 5.7.x and < 10.0.0 are not ignored # when used with the MariaDB executable comment syntax. @@ -89,6 +92,9 @@ SELECT 1 /*M!100000 +1*/; SELECT 1 /*M!210000 +1*/; 1 1 +SELECT 1 /*M!190000 +1*/; +1 +1 select 1/*!2*/; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '2*/' at line 1 select 1/*!0000002*/; diff --git a/mysql-test/main/comments.test b/mysql-test/main/comments.test index 87125890780..42cdc4255fd 100644 --- a/mysql-test/main/comments.test +++ b/mysql-test/main/comments.test @@ -42,6 +42,7 @@ SELECT 1 /*!50999 +1*/; SELECT 1 /*!99999 +1*/; SELECT 1 /*!100000 +1*/; SELECT 1 /*!210000 +1*/; +SELECT 1 /*!190000 +1*/; --echo # --echo # Tesing that versions >= 5.7.x and < 10.0.0 are not ignored @@ -53,6 +54,7 @@ SELECT 1 /*M!50999 +1*/; SELECT 1 /*M!99999 +1*/; SELECT 1 /*M!100000 +1*/; SELECT 1 /*M!210000 +1*/; +SELECT 1 /*M!190000 +1*/; # # Bug#25411 (trigger code truncated) diff --git a/mysql-test/main/mysql_upgrade.test b/mysql-test/main/mysql_upgrade.test index b149038067d..4ebfd7c7187 100644 --- a/mysql-test/main/mysql_upgrade.test +++ b/mysql-test/main/mysql_upgrade.test @@ -337,12 +337,22 @@ EOF --echo # MDEV-27279: mariadb_upgrade check-if-upgrade with major version change --echo # +# take 2rd number of version and change to 0. If the 2rd number is already 0, +# change the first number let DATADIR= $MYSQLD_DATADIR; perl; my $ver= $ENV{'MYSQL_SERVER_VERSION'} or die "MYSQL_SERVER_VERSION not set"; my $file= $ENV{'DATADIR'} or die "MYSQLD_DATADIR not set"; - $ver =~ s/^(\d*)\.(\d*).(\d*)(.*)/10.11.2$4/; + if ($ver =~ m/(\d*)\.0\.(\d*)(.*)/) + { + my $prev= $1-1; + $ver= $prev . '.0.' . $2 . $3; + } + else + { + $ver =~ s/^(\d*)\.(\d*)\.(\d*)(.*)/$1.0.$3$4/; + } open(FILE, ">$file/mysql_upgrade_info") or die "Failed to open $file"; print FILE "$ver\n"; close(FILE); diff --git a/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test b/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test index e86e93f7a3b..e397989bec5 100644 --- a/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test +++ b/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test @@ -17,7 +17,7 @@ alter table user drop column max_statement_time; flush privileges; ---replace_regex /1\d\d\d\d\d/MYSQL_VERSION_ID/ +--replace_regex /11\d\d\d\d/MYSQL_VERSION_ID/ --error ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE create role test_role; --error ER_CANNOT_USER @@ -30,8 +30,6 @@ after password_expired; create role test_role; create user test_user@localhost; grant test_role to test_user@localhost; -#--replace_regex /10\d\d\d\d/MYSQL_VERSION_ID/ -#--error ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE set default role test_role for root@localhost; drop role test_role; drop user test_user@localhost; diff --git a/mysql-test/suite/sys_vars/r/sysvars_star.result b/mysql-test/suite/sys_vars/r/sysvars_star.result index b3357fda3af..65a391828b2 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_star.result +++ b/mysql-test/suite/sys_vars/r/sysvars_star.result @@ -60,7 +60,7 @@ VARIABLE_NAME PLUGIN_MATURITY SESSION_VALUE NULL GLOBAL_VALUE alpha GLOBAL_VALUE_ORIGIN CONFIG -DEFAULT_VALUE beta +DEFAULT_VALUE experimental VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded diff --git a/storage/spider/spd_init_query.h b/storage/spider/spd_init_query.h index 0aba850ce0f..c3bea1c166b 100644 --- a/storage/spider/spd_init_query.h +++ b/storage/spider/spd_init_query.h @@ -544,11 +544,7 @@ static LEX_STRING spider_init_queries[] = { /* " if @server_name = 'MariaDB' and" " (" - " @server_major_version > 10 or" - " (" - " @server_major_version = 10 and" - " @server_minor_version >= 999" - " )" + " @server_major_version > 11" " )" " then" " create table if not exists mysql.spider_rewrite_tables(" @@ -806,13 +802,9 @@ static LEX_STRING spider_init_queries[] = { Install spider_rewrite plugin */ /* - " if @server_name = 'MariaDB' and" + " if @server_name = 'MariaDB' and " " (" - " @server_major_version > 10 or" - " (" - " @server_major_version = 10 and" - " @server_minor_version >= 999" - " )" + " @server_major_version > 11" " )" " then" " set @have_spider_i_s_rewrite_plugin := 0;" From d645025e87d8d82e627ba5822745710c5348ec52 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 18 Nov 2022 17:47:16 +0200 Subject: [PATCH 071/123] Change default of histogram_type to JSON_HB --- mysql-test/main/mysqld--help.result | 2 +- mysql-test/suite/sys_vars/r/histogram_type_basic.result | 2 +- sql/sys_vars.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index ad1343fa779..ea94fdc71d1 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -1632,7 +1632,7 @@ gtid-pos-auto-engines gtid-strict-mode FALSE help TRUE histogram-size 254 -histogram-type DOUBLE_PREC_HB +histogram-type JSON_HB host-cache-size 279 idle-readonly-transaction-timeout 0 idle-transaction-timeout 0 diff --git a/mysql-test/suite/sys_vars/r/histogram_type_basic.result b/mysql-test/suite/sys_vars/r/histogram_type_basic.result index c24192002aa..8dbd32512f8 100644 --- a/mysql-test/suite/sys_vars/r/histogram_type_basic.result +++ b/mysql-test/suite/sys_vars/r/histogram_type_basic.result @@ -10,7 +10,7 @@ SET @@global.histogram_type = 1; SET @@global.histogram_type = DEFAULT; SELECT @@global.histogram_type; @@global.histogram_type -DOUBLE_PREC_HB +JSON_HB SET @@global.histogram_type = 0; SELECT @@global.histogram_type; @@global.histogram_type diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 0df627a640a..bd193cad956 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -6670,7 +6670,7 @@ static Sys_var_enum Sys_histogram_type( "DOUBLE_PREC_HB - double precision height-balanced, " "JSON_HB - height-balanced, stored as JSON.", SESSION_VAR(histogram_type), CMD_LINE(REQUIRED_ARG), - histogram_types, DEFAULT(1)); + histogram_types, DEFAULT(2)); static Sys_var_mybool Sys_no_thread_alarm( "debug_no_thread_alarm", From c1512b1e7ca4a5c0d6486adee9bd7086827937e8 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 21 Nov 2022 14:24:00 +0200 Subject: [PATCH 072/123] Added "override" to ha_heap.h, ha_myisam.h, ha_myisammrg.h and ha_sequence.h Added override to a few functions in ha_partition.h --- sql/json_table.cc | 2 +- sql/rowid_filter.h | 4 +- storage/heap/ha_heap.h | 100 ++++++++++---------- storage/myisam/ha_myisam.h | 154 ++++++++++++++++--------------- storage/myisammrg/ha_myisammrg.h | 101 ++++++++++---------- storage/sequence/sequence.cc | 41 ++++---- 6 files changed, 206 insertions(+), 196 deletions(-) diff --git a/sql/json_table.cc b/sql/json_table.cc index 949175d8027..d404a54bc3f 100644 --- a/sql/json_table.cc +++ b/sql/json_table.cc @@ -246,7 +246,7 @@ public: int open(const char *name, int mode, uint test_if_locked) override { return 0; } int close(void) override { return 0; } - void update_optimizer_costs(OPTIMIZER_COSTS *costs) + void update_optimizer_costs(OPTIMIZER_COSTS *costs) override { memcpy(costs, &heap_optimizer_costs, sizeof(*costs)); } diff --git a/sql/rowid_filter.h b/sql/rowid_filter.h index 7c5b561107a..c80281385ea 100644 --- a/sql/rowid_filter.h +++ b/sql/rowid_filter.h @@ -265,7 +265,7 @@ public: ~Range_rowid_filter(); - bool build() { return fill(); } + bool build() override { return fill(); } bool check(char *elem) override { @@ -374,7 +374,7 @@ public: uint elements() override { return refpos_container.elements(); } void sort (int (*cmp) (void *ctxt, const void *el1, const void *el2), - void *cmp_arg) + void *cmp_arg) override { return refpos_container.sort(cmp, cmp_arg); } diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h index 663e75fc0fe..beb97601c06 100644 --- a/storage/heap/ha_heap.h +++ b/storage/heap/ha_heap.h @@ -37,15 +37,15 @@ class ha_heap final : public handler public: ha_heap(handlerton *hton, TABLE_SHARE *table); ~ha_heap() {} - handler *clone(const char *name, MEM_ROOT *mem_root); - const char *index_type(uint inx) + handler *clone(const char *name, MEM_ROOT *mem_root) override; + const char *index_type(uint inx) override { return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ? "BTREE" : "HASH"); } /* Rows also use a fixed-size format */ - enum row_type get_row_type() const { return ROW_TYPE_FIXED; } - ulonglong table_flags() const + enum row_type get_row_type() const override { return ROW_TYPE_FIXED; } + ulonglong table_flags() const override { return (HA_FAST_KEY_READ | HA_NO_BLOBS | HA_NULL_IN_KEY | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE | @@ -53,71 +53,73 @@ public: HA_REC_NOT_IN_SEQ | HA_CAN_INSERT_DELAYED | HA_NO_TRANSACTIONS | HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT | HA_CAN_HASH_KEYS); } - ulong index_flags(uint inx, uint part, bool all_parts) const + ulong index_flags(uint inx, uint part, bool all_parts) const override { return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ? HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE : HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR); } - const key_map *keys_to_use_for_scanning() { return &btree_keys; } - uint max_supported_keys() const { return MAX_KEY; } - uint max_supported_key_part_length() const { return MAX_KEY_LENGTH; } + const key_map *keys_to_use_for_scanning() override { return &btree_keys; } + uint max_supported_keys() const override { return MAX_KEY; } + uint max_supported_key_part_length() const override { return MAX_KEY_LENGTH; } IO_AND_CPU_COST scan_time() override; IO_AND_CPU_COST keyread_time(uint index, ulong ranges, ha_rows rows, ulonglong blocks) override; IO_AND_CPU_COST rnd_pos_time(ha_rows rows) override; /* 0 for avg_io_cost ensures that there are no read-block calculations */ - int open(const char *name, int mode, uint test_if_locked); - int close(void); - void set_keys_for_scanning(void); - int write_row(const uchar * buf); - int update_row(const uchar * old_data, const uchar * new_data); - int delete_row(const uchar * buf); - virtual void get_auto_increment(ulonglong offset, ulonglong increment, - ulonglong nb_desired_values, - ulonglong *first_value, - ulonglong *nb_reserved_values); + int open(const char *name, int mode, uint test_if_locked) override; + int close(void) override; + int write_row(const uchar * buf) override; + int update_row(const uchar * old_data, const uchar * new_data) override; + int delete_row(const uchar * buf) override; + void get_auto_increment(ulonglong offset, ulonglong increment, + ulonglong nb_desired_values, + ulonglong *first_value, + ulonglong *nb_reserved_values) override; int index_read_map(uchar * buf, const uchar * key, key_part_map keypart_map, - enum ha_rkey_function find_flag); - int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map); + enum ha_rkey_function find_flag) override; + int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map) + override; int index_read_idx_map(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, - enum ha_rkey_function find_flag); - int index_next(uchar * buf); - int index_prev(uchar * buf); - int index_first(uchar * buf); - int index_last(uchar * buf); - int rnd_init(bool scan); - int rnd_next(uchar *buf); - int rnd_pos(uchar * buf, uchar *pos); - void position(const uchar *record); - int can_continue_handler_scan(); - int info(uint); - int extra(enum ha_extra_function operation); - int reset(); - int external_lock(THD *thd, int lock_type); - int delete_all_rows(void); - int reset_auto_increment(ulonglong value); - int disable_indexes(uint mode); - int enable_indexes(uint mode); - int indexes_are_disabled(void); + enum ha_rkey_function find_flag) override; + int index_next(uchar * buf) override; + int index_prev(uchar * buf) override; + int index_first(uchar * buf) override; + int index_last(uchar * buf) override; + int rnd_init(bool scan) override; + int rnd_next(uchar *buf) override; + int rnd_pos(uchar * buf, uchar *pos) override; + void position(const uchar *record) override; + int can_continue_handler_scan() override; + int info(uint) override; + int extra(enum ha_extra_function operation) override; + int reset() override; + int external_lock(THD *thd, int lock_type) override; + int delete_all_rows(void) override; + int reset_auto_increment(ulonglong value) override; + int disable_indexes(uint mode) override; + int enable_indexes(uint mode) override; + int indexes_are_disabled(void) override; ha_rows records_in_range(uint inx, const key_range *start_key, - const key_range *end_key, page_range *pages); - int delete_table(const char *from); - void drop_table(const char *name); - int rename_table(const char * from, const char * to); - int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); - void update_create_info(HA_CREATE_INFO *create_info); + const key_range *end_key, page_range *pages) override; + int delete_table(const char *from) override; + void drop_table(const char *name) override; + int rename_table(const char * from, const char * to) override; + int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info) override; + void update_create_info(HA_CREATE_INFO *create_info) override; THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, - enum thr_lock_type lock_type); - int cmp_ref(const uchar *ref1, const uchar *ref2) + enum thr_lock_type lock_type) override; + int cmp_ref(const uchar *ref1, const uchar *ref2) override { return memcmp(ref1, ref2, sizeof(HEAP_PTR)); } - bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); - int find_unique_row(uchar *record, uint unique_idx); + bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) + override; + int find_unique_row(uchar *record, uint unique_idx) override; private: void update_key_stats(); + void set_keys_for_scanning(void); }; diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 0bea4938eb5..68ad636c48e 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -54,34 +54,35 @@ class ha_myisam final : public handler public: ha_myisam(handlerton *hton, TABLE_SHARE *table_arg); ~ha_myisam() {} - handler *clone(const char *name, MEM_ROOT *mem_root); - const char *index_type(uint key_number); - ulonglong table_flags() const { return int_table_flags; } - int index_init(uint idx, bool sorted); - int index_end(); - int rnd_end(); + handler *clone(const char *name, MEM_ROOT *mem_root) override; + const char *index_type(uint key_number) override; + ulonglong table_flags() const override { return int_table_flags; } + int index_init(uint idx, bool sorted) override; + int index_end() override; + int rnd_end() override; - ulong index_flags(uint inx, uint part, bool all_parts) const; - uint max_supported_keys() const { return MI_MAX_KEY; } - uint max_supported_key_parts() const { return HA_MAX_KEY_SEG; } - uint max_supported_key_length() const { return HA_MAX_KEY_LENGTH; } - uint max_supported_key_part_length() const { return HA_MAX_KEY_LENGTH; } - void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share); - int open(const char *name, int mode, uint test_if_locked); - int close(void); - int write_row(const uchar * buf); - int update_row(const uchar * old_data, const uchar * new_data); - int delete_row(const uchar * buf); + ulong index_flags(uint inx, uint part, bool all_parts) const override; + uint max_supported_keys() const override { return MI_MAX_KEY; } + uint max_supported_key_parts() const override { return HA_MAX_KEY_SEG; } + uint max_supported_key_length() const override { return HA_MAX_KEY_LENGTH; } + uint max_supported_key_part_length() const override + { return HA_MAX_KEY_LENGTH; } + void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) override; + int open(const char *name, int mode, uint test_if_locked) override; + int close(void) override; + int write_row(const uchar * buf) override; + int update_row(const uchar * old_data, const uchar * new_data) override; + int delete_row(const uchar * buf) override; int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, - enum ha_rkey_function find_flag); + enum ha_rkey_function find_flag) override; int index_read_idx_map(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, - enum ha_rkey_function find_flag); - int index_next(uchar * buf); - int index_prev(uchar * buf); - int index_first(uchar * buf); - int index_last(uchar * buf); - int index_next_same(uchar *buf, const uchar *key, uint keylen); + enum ha_rkey_function find_flag) override; + int index_next(uchar * buf) override; + int index_prev(uchar * buf) override; + int index_first(uchar * buf) override; + int index_last(uchar * buf) override; + int index_next_same(uchar *buf, const uchar *key, uint keylen) override; int ft_init() override { if (!ft_handler) @@ -95,73 +96,70 @@ class ha_myisam final : public handler (uchar *)key->ptr(), key->length(), key->charset(), table->record[0]); } - int ft_read(uchar *buf); - int rnd_init(bool scan); - int rnd_next(uchar *buf); - int rnd_pos(uchar * buf, uchar *pos); - int remember_rnd_pos(); - int restart_rnd_next(uchar *buf); - void position(const uchar *record); + int ft_read(uchar *buf) override; + int rnd_init(bool scan) override; + int rnd_next(uchar *buf) override; + int rnd_pos(uchar * buf, uchar *pos) override; + int remember_rnd_pos() override; + int restart_rnd_next(uchar *buf) override; + void position(const uchar *record) override; IO_AND_CPU_COST rnd_pos_time(ha_rows rows) override; - int info(uint); - int extra(enum ha_extra_function operation); - int extra_opt(enum ha_extra_function operation, ulong cache_size); - int reset(void); - int external_lock(THD *thd, int lock_type); - int delete_all_rows(void); - int reset_auto_increment(ulonglong value); - int disable_indexes(uint mode); - int enable_indexes(uint mode); - int indexes_are_disabled(void); - void start_bulk_insert(ha_rows rows, uint flags); - int end_bulk_insert(); + int info(uint) override; + int extra(enum ha_extra_function operation) override; + int extra_opt(enum ha_extra_function operation, ulong cache_size) override; + int reset(void) override; + int external_lock(THD *thd, int lock_type) override; + int delete_all_rows(void) override; + int reset_auto_increment(ulonglong value) override; + int disable_indexes(uint mode) override; + int enable_indexes(uint mode) override; + int indexes_are_disabled(void) override; + void start_bulk_insert(ha_rows rows, uint flags) override; + int end_bulk_insert() override; ha_rows records_in_range(uint inx, const key_range *min_key, - const key_range *max_key, page_range *pages); - void update_create_info(HA_CREATE_INFO *create_info); - int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); + const key_range *max_key, page_range *pages) override; + void update_create_info(HA_CREATE_INFO *create_info) override; + int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info) override; THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, - enum thr_lock_type lock_type); - virtual void get_auto_increment(ulonglong offset, ulonglong increment, - ulonglong nb_desired_values, - ulonglong *first_value, - ulonglong *nb_reserved_values); - int rename_table(const char * from, const char * to); - int delete_table(const char *name); - int check_for_upgrade(HA_CHECK_OPT *check_opt); - int check(THD* thd, HA_CHECK_OPT* check_opt); - int analyze(THD* thd,HA_CHECK_OPT* check_opt); - int repair(THD* thd, HA_CHECK_OPT* check_opt); - bool check_and_repair(THD *thd); - bool is_crashed() const; - bool auto_repair(int error) const + enum thr_lock_type lock_type) override; + void get_auto_increment(ulonglong offset, ulonglong increment, + ulonglong nb_desired_values, + ulonglong *first_value, + ulonglong *nb_reserved_values) override; + int rename_table(const char * from, const char * to) override; + int delete_table(const char *name) override; + int check_for_upgrade(HA_CHECK_OPT *check_opt) override; + int check(THD* thd, HA_CHECK_OPT* check_opt) override; + int analyze(THD* thd,HA_CHECK_OPT* check_opt) override; + int repair(THD* thd, HA_CHECK_OPT* check_opt) override; + bool check_and_repair(THD *thd) override; + bool is_crashed() const override; + bool auto_repair(int error) const override { return (myisam_recover_options != HA_RECOVER_OFF && error == HA_ERR_CRASHED_ON_USAGE); } - int optimize(THD* thd, HA_CHECK_OPT* check_opt); - int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt); - int preload_keys(THD* thd, HA_CHECK_OPT* check_opt); + int optimize(THD* thd, HA_CHECK_OPT* check_opt) override; + int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt) override; + int preload_keys(THD* thd, HA_CHECK_OPT* check_opt) override; enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *new_table, - Alter_inplace_info *alter_info); - bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); + Alter_inplace_info *alter_info) + override; + bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) + override; #ifdef HAVE_QUERY_CACHE my_bool register_query_cache_table(THD *thd, const char *table_key, uint key_length, qc_engine_callback *engine_callback, - ulonglong *engine_data); + ulonglong *engine_data) override; #endif - MI_INFO *file_ptr(void) - { - return file; - } -public: /** * Multi Range Read interface */ int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, - uint n_ranges, uint mode, HANDLER_BUFFER *buf); - int multi_range_read_next(range_id_t *range_info); + uint n_ranges, uint mode, HANDLER_BUFFER *buf) override; + int multi_range_read_next(range_id_t *range_info) override; ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint *bufsz, @@ -169,14 +167,20 @@ public: Cost_estimate *cost) override; ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, uint key_parts, uint *bufsz, - uint *flags, Cost_estimate *cost); - int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size); + uint *flags, Cost_estimate *cost) override; + int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size) override; /* Index condition pushdown implementation */ Item *idx_cond_push(uint keyno, Item* idx_cond) override; bool rowid_filter_push(Rowid_filter* rowid_filter) override; void rowid_filter_changed() override; + /* Used by myisammrg */ + MI_INFO *file_ptr(void) + { + return file; + } + private: DsMrr_impl ds_mrr; friend check_result_t index_cond_func_myisam(void *arg); diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h index a5e35540c55..0435f7d6bd6 100644 --- a/storage/myisammrg/ha_myisammrg.h +++ b/storage/myisammrg/ha_myisammrg.h @@ -82,8 +82,8 @@ public: ha_myisammrg(handlerton *hton, TABLE_SHARE *table_arg); ~ha_myisammrg(); - const char *index_type(uint key_number); - ulonglong table_flags() const + const char *index_type(uint key_number) override; + ulonglong table_flags() const override { return (HA_REC_NOT_IN_SEQ | HA_AUTO_PART_KEY | HA_NO_TRANSACTIONS | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE | @@ -93,15 +93,16 @@ public: HA_NO_COPY_ON_ALTER | HA_DUPLICATE_POS | HA_CAN_MULTISTEP_MERGE); } - ulong index_flags(uint inx, uint part, bool all_parts) const + ulong index_flags(uint inx, uint part, bool all_parts) const override { return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | HA_READ_ORDER | HA_KEYREAD_ONLY); } - uint max_supported_keys() const { return MI_MAX_KEY; } - uint max_supported_key_length() const { return HA_MAX_KEY_LENGTH; } - uint max_supported_key_part_length() const { return HA_MAX_KEY_LENGTH; } + uint max_supported_keys() const override { return MI_MAX_KEY; } + uint max_supported_key_length() const override { return HA_MAX_KEY_LENGTH; } + uint max_supported_key_part_length() const override + { return HA_MAX_KEY_LENGTH; } IO_AND_CPU_COST scan_time() override { IO_AND_CPU_COST cost; @@ -113,58 +114,60 @@ public: IO_AND_CPU_COST rnd_pos_time(ha_rows rows) override; IO_AND_CPU_COST keyread_time(uint index, ulong ranges, ha_rows rows, ulonglong blocks) override; - int open(const char *name, int mode, uint test_if_locked); - int add_children_list(void); - int attach_children(void); - int detach_children(void); - virtual handler *clone(const char *name, MEM_ROOT *mem_root); - int close(void); - int write_row(const uchar * buf); - int update_row(const uchar * old_data, const uchar * new_data); - int delete_row(const uchar * buf); + int open(const char *name, int mode, uint test_if_locked) override; + handler *clone(const char *name, MEM_ROOT *mem_root) override; + int close(void) override; + int write_row(const uchar * buf) override; + int update_row(const uchar * old_data, const uchar * new_data) override; + int delete_row(const uchar * buf) override; int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, - enum ha_rkey_function find_flag); + enum ha_rkey_function find_flag) override; int index_read_idx_map(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, - enum ha_rkey_function find_flag); - int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map); - int index_next(uchar * buf); - int index_prev(uchar * buf); - int index_first(uchar * buf); - int index_last(uchar * buf); - int index_next_same(uchar *buf, const uchar *key, uint keylen); - int rnd_init(bool scan); - int rnd_next(uchar *buf); - int rnd_pos(uchar * buf, uchar *pos); - void position(const uchar *record); + enum ha_rkey_function find_flag) override; + int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map) override; + int index_next(uchar * buf) override; + int index_prev(uchar * buf) override; + int index_first(uchar * buf) override; + int index_last(uchar * buf) override; + int index_next_same(uchar *buf, const uchar *key, uint keylen) override; + int rnd_init(bool scan) override; + int rnd_next(uchar *buf) override; + int rnd_pos(uchar * buf, uchar *pos) override; + void position(const uchar *record) override; ha_rows records_in_range(uint inx, const key_range *start_key, - const key_range *end_key, page_range *pages); - int delete_all_rows(); - int info(uint); - int reset(void); - int extra(enum ha_extra_function operation); - int extra_opt(enum ha_extra_function operation, ulong cache_size); - int external_lock(THD *thd, int lock_type); - uint lock_count(void) const; - int create_mrg(const char *name, HA_CREATE_INFO *create_info); - int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); + const key_range *end_key, page_range *pages) override; + int delete_all_rows() override; + int info(uint) override; + int reset(void) override; + int extra(enum ha_extra_function operation) override; + int extra_opt(enum ha_extra_function operation, ulong cache_size) override; + int external_lock(THD *thd, int lock_type) override; + uint lock_count(void) const override; + int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info) override; THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, - enum thr_lock_type lock_type); - void update_create_info(HA_CREATE_INFO *create_info); - void append_create_info(String *packet); - MYRG_INFO *myrg_info() { return file; } - TABLE *table_ptr() { return table; } + enum thr_lock_type lock_type) override; + void update_create_info(HA_CREATE_INFO *create_info) override; + void append_create_info(String *packet) override; enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *, - Alter_inplace_info *); + Alter_inplace_info *) override; bool inplace_alter_table(TABLE *altered_table, - Alter_inplace_info *ha_alter_info); - int check(THD* thd, HA_CHECK_OPT* check_opt); - ha_rows records(); - virtual uint count_query_cache_dependant_tables(uint8 *tables_type); + Alter_inplace_info *ha_alter_info) override; + int check(THD* thd, HA_CHECK_OPT* check_opt) override; + ha_rows records() override; + virtual uint count_query_cache_dependant_tables(uint8 *tables_type) override; virtual my_bool register_query_cache_dependant_tables(THD *thd, Query_cache *cache, Query_cache_block_table **block, - uint *n); - virtual void set_lock_type(enum thr_lock_type lock); + uint *n) override; + virtual void set_lock_type(enum thr_lock_type lock) override; + + /* Internal interface functions, not part of the normal handler interface */ + int add_children_list(void); + int attach_children(void); + int detach_children(void); + int create_mrg(const char *name, HA_CREATE_INFO *create_info); + MYRG_INFO *myrg_info() { return file; } + TABLE *table_ptr() { return table; } }; diff --git a/storage/sequence/sequence.cc b/storage/sequence/sequence.cc index fd95a897a46..38e1eea8c40 100644 --- a/storage/sequence/sequence.cc +++ b/storage/sequence/sequence.cc @@ -64,52 +64,53 @@ public: Sequence_share *seqs; ha_seq(handlerton *hton, TABLE_SHARE *table_arg) : handler(hton, table_arg), seqs(0) { } - ulonglong table_flags() const + ulonglong table_flags() const override { return HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE; } /* open/close/locking */ int create(const char *name, TABLE *table_arg, - HA_CREATE_INFO *create_info) + HA_CREATE_INFO *create_info) override { return HA_ERR_WRONG_COMMAND; } - int open(const char *name, int mode, uint test_if_locked); - int close(void); - int delete_table(const char *name) + int open(const char *name, int mode, uint test_if_locked) override; + int close(void) override; + int delete_table(const char *name) override { return 0; } - THR_LOCK_DATA **store_lock(THD *, THR_LOCK_DATA **, enum thr_lock_type); + THR_LOCK_DATA **store_lock(THD *, THR_LOCK_DATA **, enum thr_lock_type) + override; /* table scan */ - int rnd_init(bool scan); - int rnd_next(unsigned char *buf); - void position(const uchar *record); - int rnd_pos(uchar *buf, uchar *pos); - int info(uint flag); + int rnd_init(bool scan) override; + int rnd_next(unsigned char *buf) override; + void position(const uchar *record) override; + int rnd_pos(uchar *buf, uchar *pos) override; + int info(uint flag) override; IO_AND_CPU_COST keyread_time(uint index, ulong ranges, ha_rows rows, ulonglong blocks) override { /* Avoids assert in total_cost() and makes DBUG_PRINT more consistent */ return {0,0}; } - IO_AND_CPU_COST scan_time() + IO_AND_CPU_COST scan_time() override { /* Avoids assert in total_cost() and makes DBUG_PRINT more consistent */ return {0, 0}; } /* indexes */ - ulong index_flags(uint inx, uint part, bool all_parts) const + ulong index_flags(uint inx, uint part, bool all_parts) const override { return HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE | HA_KEYREAD_ONLY; } - uint max_supported_keys() const { return 1; } + uint max_supported_keys() const override { return 1; } int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, - enum ha_rkey_function find_flag); - int index_next(uchar *buf); - int index_prev(uchar *buf); - int index_first(uchar *buf); - int index_last(uchar *buf); + enum ha_rkey_function find_flag) override; + int index_next(uchar *buf) override; + int index_prev(uchar *buf) override; + int index_first(uchar *buf) override; + int index_last(uchar *buf) override; ha_rows records_in_range(uint inx, const key_range *start_key, - const key_range *end_key, page_range *pages); + const key_range *end_key, page_range *pages) override; private: void set(uchar *buf); From 1c88ac60cf5167b89c8e4911f157596e0f3ac1e1 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 22 Nov 2022 14:56:33 +0200 Subject: [PATCH 073/123] Simple cleanup of removing QQ comments from sql_select.cc - The comment in test_if_skip_sort_order was removed together with a not needed test of 'select' --- sql/sql_select.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a6841b87410..4f0fa3cdb00 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9764,7 +9764,6 @@ optimize_straight_join(JOIN *join, table_map remaining_tables) { /* Adjust records_out to contain the final number of rows */ double ratio= current_record_count / original_record_count; - /* QQQ This is just to stop an assert later */ if (ratio < 1) { position->records_out*= ratio; @@ -11047,7 +11046,6 @@ best_extension_by_limited_search(JOIN *join, { /* Adjust records_out and current_record_count after semi join */ double ratio= current_record_count / original_record_count; - /* QQQ This is just to stop an assert later */ if (ratio < 1.0) position->records_out*= ratio; if (unlikely(trace_one_table.trace_started())) @@ -25622,8 +25620,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, !(table->file->index_flags(best_key, 0, 1) & HA_CLUSTERED_INDEX))) goto use_filesort; - if (select && // psergey: why doesn't this use a quick? - table->opt_range_keys.is_set(best_key) && best_key != ref_key) + if (table->opt_range_keys.is_set(best_key) && best_key != ref_key) { key_map tmp_map; tmp_map.clear_all(); // Force the creation of quick select From 0dd9ec97d02e2823577aaaca2d8b8dc097b03921 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 22 Nov 2022 15:27:37 +0200 Subject: [PATCH 074/123] Changed a rule to be cost based in test_if_cheaper_ordering - Simplified test by setting read_time=DBL_MAX at start of loop if FORCE INDEX is used - No need to test for 'group by' as the cost compare should handle it. - Only one test change where index scan was replaced with table scan (correct) --- mysql-test/suite/innodb/r/innodb_mysql.result | 2 +- sql/sql_select.cc | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index 31f6dafd082..54c6f1ef262 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -1193,7 +1193,7 @@ INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1; INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1; EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 5 NULL 128 +1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4f0fa3cdb00..c7ed2ebd810 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -30550,6 +30550,13 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, add("fanout", fanout); } + /* + Force using an index for sorting if there was no ref key + and FORCE INDEX was used. + */ + if (table->force_index && ref_key < 0) + read_time= DBL_MAX; + Json_writer_array possible_keys(thd,"possible_keys"); for (nr=0; nr < table->s->keys ; nr++) { @@ -30702,8 +30709,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, there is either a group by or a FORCE_INDEX - If the new cost is better than read_time */ - if (((table->force_index || group) && best_key < 0 && ref_key < 0) || - range_cost < read_time) + if (range_cost < read_time) { read_time= range_cost; possible_key.add("chosen", true); From 657868f5e726e0a5e78d879e4ae50f1d3b5a8d71 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 22 Nov 2022 13:32:44 +0200 Subject: [PATCH 075/123] Change BUILD scripts to use wolfss by default --- BUILD/SETUP.sh | 11 ++++++----- cmake/configure.pl | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index d990608f14e..9b3a584bbab 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -127,7 +127,7 @@ get_make_parallel_flag # implementation of SSL. --with-ssl=yes will first try system library # then the bundled one --with-ssl=system will use the system library. # We use bundled by default as this is guaranteed to work with Galera -SSL_LIBRARY=--with-ssl +SSL_LIBRARY=--with-ssl=bundled if [ "x$warning_mode" = "xpedantic" ]; then warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE" @@ -202,6 +202,7 @@ base_configs="$base_configs --with-extra-charsets=complex " base_configs="$base_configs --enable-thread-safe-client " base_configs="$base_configs --with-big-tables $maintainer_mode" base_configs="$base_configs --with-plugin-aria --with-aria-tmp-tables --with-plugin-s3=STATIC" +base_configs="$base_configs $SSL_LIBRARY" if test -d "$path/../cmd-line-utils/readline" then @@ -212,10 +213,10 @@ then fi max_plugins="--with-plugins=max" -max_no_embedded_configs="$SSL_LIBRARY $max_plugins" -max_no_qc_configs="$SSL_LIBRARY $max_plugins --without-query-cache" -max_configs="$SSL_LIBRARY $max_plugins --with-embedded-server --with-libevent --with-plugin-rocksdb=dynamic --with-plugin-test_sql_discovery=DYNAMIC --with-plugin-file_key_management=DYNAMIC --with-plugin-hashicorp_key_management=DYNAMIC" -all_configs="$SSL_LIBRARY $max_plugins --with-embedded-server --with-innodb_plugin --with-libevent" +max_no_embedded_configs="$max_plugins" +max_no_qc_configs="$max_plugins --without-query-cache" +max_configs="$max_plugins --with-embedded-server --with-libevent --with-plugin-rocksdb=dynamic --with-plugin-test_sql_discovery=DYNAMIC --with-plugin-file_key_management=DYNAMIC --with-plugin-hashicorp_key_management=DYNAMIC --with-plugin-auth_gssapi=DYNAMIC" +all_configs="$max_plugins --with-embedded-server --with-innodb_plugin --with-libevent" # # CPU and platform specific compilation flags. diff --git a/cmake/configure.pl b/cmake/configure.pl index 4085110b6fa..87099169b85 100644 --- a/cmake/configure.pl +++ b/cmake/configure.pl @@ -190,7 +190,7 @@ foreach my $option (@ARGV) $cmakeargs = $cmakeargs." -DWITH_SSL=system"; next; } - if($option =~ /with-ssl$/) + if($option =~ /with-ssl$/ || $option =~ /with-ssl=bundled/) { $cmakeargs = $cmakeargs." -DWITH_SSL=bundled"; next; From ffe0beca2557a31758f50fa53ceb9948b6cd6248 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sat, 19 Nov 2022 21:00:23 +0300 Subject: [PATCH 076/123] MDEV-30032: EXPLAIN FORMAT=JSON output: print costs Basic printout for join and table execution costs. --- mysql-test/include/analyze-format.inc | 2 +- mysql-test/include/analyze-no-filtered.inc | 2 + .../include/explain-no-costs-filtered.inc | 1 + mysql-test/include/explain-no-costs.inc | 1 + mysql-test/main/analyze_format_json.result | 49 + mysql-test/main/analyze_format_json.test | 1 + mysql-test/main/analyze_stmt_orderby.result | 25 + mysql-test/main/analyze_stmt_orderby.test | 6 + mysql-test/main/brackets.result | 16 + mysql-test/main/brackets.test | 5 + mysql-test/main/cte_recursive.result | 48 + mysql-test/main/cte_recursive.test | 3 + mysql-test/main/derived_cond_pushdown.result | 1187 +++++++++++++++++ mysql-test/main/derived_cond_pushdown.test | 195 +++ mysql-test/main/derived_view.result | 38 + mysql-test/main/derived_view.test | 6 + mysql-test/main/except.result | 34 + mysql-test/main/except.test | 2 + mysql-test/main/except_all.result | 38 + mysql-test/main/except_all.test | 4 +- mysql-test/main/explain_json.result | 138 ++ mysql-test/main/explain_json.test | 53 +- .../explain_json_format_partitions.result | 4 + .../main/explain_json_format_partitions.test | 1 + mysql-test/main/explain_json_innodb.result | 5 + mysql-test/main/explain_json_innodb.test | 1 + mysql-test/main/fetch_first.result | 2 + mysql-test/main/having_cond_pushdown.result | 300 +++++ mysql-test/main/having_cond_pushdown.test | 146 ++ mysql-test/main/in_subq_cond_pushdown.result | 210 +++ mysql-test/main/in_subq_cond_pushdown.test | 38 + mysql-test/main/innodb_ext_key,off.rdiff | 8 +- mysql-test/main/innodb_ext_key.result | 8 +- mysql-test/main/innodb_ext_key.test | 6 +- mysql-test/main/intersect.result | 37 + mysql-test/main/intersect.test | 2 + mysql-test/main/intersect_all.result | 37 + mysql-test/main/intersect_all.test | 4 +- mysql-test/main/join_cache.result | 3 + mysql-test/main/join_cache.test | 1 + mysql-test/main/multi_update.test | 3 + mysql-test/main/opt_trace.result | 8 + mysql-test/main/opt_trace_ucs2.result | 2 + mysql-test/main/opt_trace_ucs2.test | 1 + mysql-test/main/order_by.result | 24 + mysql-test/main/order_by.test | 2 + mysql-test/main/order_by_pack_big.result | 8 + mysql-test/main/range.result | 30 + mysql-test/main/range.test | 11 + mysql-test/main/range_mrr_icp.result | 30 + mysql-test/main/rowid_filter.result | 80 ++ mysql-test/main/rowid_filter.test | 20 +- mysql-test/main/rowid_filter_aria.result | 80 ++ mysql-test/main/rowid_filter_innodb.result | 88 ++ mysql-test/main/rowid_filter_innodb.test | 1 + mysql-test/main/rowid_filter_myisam.result | 15 + mysql-test/main/rowid_filter_myisam.test | 1 + mysql-test/main/set_operation.result | 26 + mysql-test/main/set_operation.test | 1 + mysql-test/main/show_analyze.result | 2 + mysql-test/main/show_analyze_json.result | 68 + mysql-test/main/show_explain_json.result | 78 ++ mysql-test/main/show_explain_json.test | 28 + mysql-test/main/statistics_json.result | 2 + mysql-test/main/statistics_json.test | 1 + mysql-test/main/subselect4.result | 6 + mysql-test/main/subselect_cache.result | 20 + mysql-test/main/subselect_cache.test | 2 + mysql-test/main/subselect_no_semijoin.result | 4 + mysql-test/main/subselect_no_semijoin.test | 1 + mysql-test/main/table_elim.result | 15 + mysql-test/main/table_elim.test | 4 + mysql-test/main/table_value_constr.test | 9 + mysql-test/main/win.result | 26 + mysql-test/main/win.test | 12 + mysql-test/main/win_empty_over.result | 4 + mysql-test/main/win_empty_over.test | 2 + .../encryption/r/tempfiles_encrypted.result | 26 + .../federatedx_create_handlers.result | 9 + .../federated/federatedx_create_handlers.test | 4 + mysql-test/suite/json/r/json_table.result | 2 + .../suite/json/r/json_table_mysql.result | 2 + mysql-test/suite/json/t/json_table.test | 1 + mysql-test/suite/json/t/json_table_mysql.test | 1 + sql/sql_explain.cc | 9 + sql/sql_explain.h | 7 +- sql/sql_select.cc | 4 + sql/sql_select.h | 6 + .../rocksdb/include/rocksdb_icp.inc | 2 +- .../mysql-test/rocksdb/r/rocksdb_icp.result | 2 + .../rocksdb/r/rocksdb_icp_rev.result | 2 + 91 files changed, 3441 insertions(+), 18 deletions(-) create mode 100644 mysql-test/include/analyze-no-filtered.inc create mode 100644 mysql-test/include/explain-no-costs-filtered.inc create mode 100644 mysql-test/include/explain-no-costs.inc diff --git a/mysql-test/include/analyze-format.inc b/mysql-test/include/analyze-format.inc index f9579555d7b..e65450ff001 100644 --- a/mysql-test/include/analyze-format.inc +++ b/mysql-test/include/analyze-format.inc @@ -1,3 +1,3 @@ # The time on ANALYSE FORMAT=JSON is rather variable ---replace_regex /("(r_total_time_ms|r_table_time_ms|r_other_time_ms|r_buffer_size|r_filling_time_ms|r_query_time_in_progress_ms|r_unpack_time_ms)": )[^, \n]*/\1"REPLACED"/ +--replace_regex /("(r_total_time_ms|r_table_time_ms|r_other_time_ms|r_buffer_size|r_filling_time_ms|r_query_time_in_progress_ms|r_unpack_time_ms|cost)": )[^, \n]*/\1"REPLACED"/ diff --git a/mysql-test/include/analyze-no-filtered.inc b/mysql-test/include/analyze-no-filtered.inc new file mode 100644 index 00000000000..eb1663167b2 --- /dev/null +++ b/mysql-test/include/analyze-no-filtered.inc @@ -0,0 +1,2 @@ +--replace_regex /("(filtered|r_total_time_ms|r_table_time_ms|r_other_time_ms|r_buffer_size|r_filling_time_ms|r_query_time_in_progress_ms|r_unpack_time_ms|cost)": )[^, \n]*/\1"REPLACED"/ + diff --git a/mysql-test/include/explain-no-costs-filtered.inc b/mysql-test/include/explain-no-costs-filtered.inc new file mode 100644 index 00000000000..585d8b3fdcc --- /dev/null +++ b/mysql-test/include/explain-no-costs-filtered.inc @@ -0,0 +1 @@ +--replace_regex /("(cost|filtered)": )[^, \n]*/\1"REPLACED"/ diff --git a/mysql-test/include/explain-no-costs.inc b/mysql-test/include/explain-no-costs.inc new file mode 100644 index 00000000000..f2f362b8cbe --- /dev/null +++ b/mysql-test/include/explain-no-costs.inc @@ -0,0 +1 @@ +--replace_regex /("(cost)": )[^, \n]*/\1"COST_REPLACED"/ diff --git a/mysql-test/main/analyze_format_json.result b/mysql-test/main/analyze_format_json.result index 99ac42d34bd..32e6ae0a67e 100644 --- a/mysql-test/main/analyze_format_json.result +++ b/mysql-test/main/analyze_format_json.result @@ -10,6 +10,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -20,6 +21,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -46,6 +48,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -56,6 +59,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -75,6 +79,7 @@ ANALYZE "r_loops": 0, "rows": 1, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null } @@ -96,6 +101,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -106,6 +112,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -125,6 +132,7 @@ ANALYZE "r_loops": 10, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -149,6 +157,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -159,6 +168,7 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -174,6 +184,7 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -199,6 +210,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -209,6 +221,7 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -224,6 +237,7 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -258,6 +272,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -268,6 +283,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -287,6 +303,7 @@ ANALYZE "r_loops": 10, "rows": 2, "r_rows": 0.2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -319,6 +336,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -329,6 +347,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -383,6 +402,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -397,6 +417,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -463,6 +484,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -473,6 +495,7 @@ ANALYZE "r_loops": 1, "rows": 5, "r_rows": 5, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -499,6 +522,7 @@ ANALYZE "r_loops": 5, "rows": 1010, "r_rows": 203.8, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -533,6 +557,7 @@ ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -543,6 +568,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -557,6 +583,7 @@ ANALYZE "query_block": { "select_id": 2, "operation": "UNION", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -567,6 +594,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -604,6 +632,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "having_condition": "TOP > t2.a", @@ -624,6 +653,7 @@ ANALYZE "r_loops": 1, "rows": 256, "r_rows": 256, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -644,6 +674,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { @@ -663,6 +694,7 @@ ANALYZE "r_loops": 1, "rows": 256, "r_rows": 256, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -697,6 +729,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { @@ -716,6 +749,7 @@ ANALYZE "r_loops": 1, "rows": 256, "r_rows": 256, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -743,6 +777,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -753,6 +788,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -767,6 +803,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -786,6 +823,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -796,6 +834,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -832,6 +871,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { @@ -860,6 +900,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -874,6 +915,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -895,6 +937,7 @@ ANALYZE "r_loops": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -903,6 +946,7 @@ ANALYZE "r_loops": 0, "rows": 2, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null } @@ -915,6 +959,7 @@ ANALYZE "r_loops": 0, "rows": 2, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null }, @@ -954,6 +999,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -964,6 +1010,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -979,6 +1026,7 @@ ANALYZE "r_loops": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -996,6 +1044,7 @@ ANALYZE "r_loops": 0, "rows": 10, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null, "attached_condition": "t2.a < t1.a" diff --git a/mysql-test/main/analyze_format_json.test b/mysql-test/main/analyze_format_json.test index 8c0948daac9..84625f125fb 100644 --- a/mysql-test/main/analyze_format_json.test +++ b/mysql-test/main/analyze_format_json.test @@ -154,6 +154,7 @@ drop table t0, t1; --echo # --echo # MDEV-7970: EXPLAIN FORMAT=JSON does not print HAVING +--source include/explain-no-costs.inc --echo # create table t0(a int); insert into t0 values (0),(1),(2),(3); diff --git a/mysql-test/main/analyze_stmt_orderby.result b/mysql-test/main/analyze_stmt_orderby.result index e188f93c160..80c630217ca 100644 --- a/mysql-test/main/analyze_stmt_orderby.result +++ b/mysql-test/main/analyze_stmt_orderby.result @@ -182,6 +182,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t2.b", "temporary_table": { @@ -191,6 +192,7 @@ EXPLAIN "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t0.a is not null" } @@ -205,6 +207,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t0.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -222,6 +225,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { @@ -241,6 +245,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -260,6 +265,7 @@ ANALYZE "r_loops": 10, "rows": 1, "r_rows": 0.4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -285,6 +291,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -294,6 +301,7 @@ EXPLAIN "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t0.a is not null" } @@ -310,6 +318,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t0.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -325,6 +334,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -345,6 +355,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -366,6 +377,7 @@ ANALYZE "r_loops": 10, "rows": 1, "r_rows": 0.4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -396,6 +408,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { @@ -415,6 +428,7 @@ ANALYZE "r_loops": 1, "rows": 1000, "r_rows": 1000, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -459,6 +473,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "duplicate_removal": { @@ -471,6 +486,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -485,6 +501,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -527,6 +544,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { @@ -555,6 +573,7 @@ ANALYZE "r_loops": 1, "rows": 5, "r_rows": 5, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -570,6 +589,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 7, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -598,6 +618,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "count(distinct t5.b)", "temporary_table": { @@ -610,6 +631,7 @@ EXPLAIN "table_name": "t6", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t6.b > 0 and t6.a <= 5" } @@ -620,6 +642,7 @@ EXPLAIN "table_name": "t5", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -666,6 +689,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -679,6 +703,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 20, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/analyze_stmt_orderby.test b/mysql-test/main/analyze_stmt_orderby.test index ecee8040ed5..519cae45a97 100644 --- a/mysql-test/main/analyze_stmt_orderby.test +++ b/mysql-test/main/analyze_stmt_orderby.test @@ -21,6 +21,7 @@ insert into t2 select A.a*1000 + B.a, A.a*1000 + B.a from t0 A, t1 B; --echo # explain update t2 set b=b+1 order by b limit 5; +--source include/explain-no-costs.inc explain format=json update t2 set b=b+1 order by b limit 5; --source include/analyze-format.inc @@ -32,6 +33,7 @@ update t2 set b=b+1 order by b limit 5; --echo # explain update t2 set a=a+1 where a<10; +--source include/explain-no-costs.inc explain format=json update t2 set a=a+1 where a<10; --source include/analyze-format.inc @@ -43,6 +45,7 @@ update t2 set a=a+1 where a<10; --echo # explain delete from t2 order by b limit 5; +--source include/explain-no-costs.inc explain format=json delete from t2 order by b limit 5; --source include/analyze-format.inc @@ -54,6 +57,7 @@ delete from t2 order by b limit 5; --echo # explain select * from t0,t2 where t2.a=t0.a order by t2.b limit 4; +--source include/explain-no-costs.inc explain format=json select * from t0,t2 where t2.a=t0.a order by t2.b limit 4; --source include/analyze-format.inc @@ -66,6 +70,7 @@ select * from t0,t2 where t2.a=t0.a order by t2.b limit 4; --echo # explain select * from t0,t2 where t2.a=t0.a order by t0.a limit 4; +--source include/explain-no-costs.inc explain format=json select * from t0,t2 where t2.a=t0.a order by t0.a limit 4; --source include/analyze-format.inc @@ -143,6 +148,7 @@ select count(distinct t5.b) as sum from t5, t6 where t5.a=t6.a and t6.b > 0 and t5.a <= 5 group by t5.a order by sum limit 1; +--source include/explain-no-costs.inc explain format=json select count(distinct t5.b) as sum from t5, t6 where t5.a=t6.a and t6.b > 0 and t5.a <= 5 diff --git a/mysql-test/main/brackets.result b/mysql-test/main/brackets.result index f87afdc0f47..73917dd635b 100644 --- a/mysql-test/main/brackets.result +++ b/mysql-test/main/brackets.result @@ -261,6 +261,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -270,6 +271,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -291,6 +293,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -300,6 +303,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -329,12 +333,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 20" } @@ -346,12 +352,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -383,12 +391,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 20" } @@ -400,12 +410,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -445,6 +457,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -454,6 +467,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -466,12 +480,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.pk > 4" } diff --git a/mysql-test/main/brackets.test b/mysql-test/main/brackets.test index 9a0c204e271..4300e8a0592 100644 --- a/mysql-test/main/brackets.test +++ b/mysql-test/main/brackets.test @@ -117,24 +117,28 @@ let $q1= select a from t1 order by a desc limit 1; eval $q1; eval explain extended $q1; +--source include/explain-no-costs.inc eval explain format=json $q1; let $q2= (select a from t1 order by a desc) limit 1; eval $q2; eval explain extended $q2; +--source include/explain-no-costs.inc eval explain format=json $q2; let $q1= (select a from t1 where a=20 union select a from t1) order by a desc limit 1; eval $q1; eval explain extended $q1; +--source include/explain-no-costs.inc eval explain format=json $q1; let $q2= ((select a from t1 where a=20 union select a from t1) order by a desc) limit 1; eval $q2; eval explain extended $q2; +--source include/explain-no-costs.inc eval explain format=json $q2; drop table t1; @@ -150,6 +154,7 @@ let $q= ((select * from t1 order by pk) limit 2) union (select * from t1 where pk > 4); eval $q; eval explain extended $q; +--source include/explain-no-costs.inc eval explain format=json $q; drop table t1; diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index f6a71b2f53c..6356d94f933 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -1339,12 +1339,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 24, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -1355,12 +1357,14 @@ EXPLAIN { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "folks", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "folks.`name` = 'Me2'" } @@ -1372,12 +1376,14 @@ EXPLAIN "query_block": { "select_id": 6, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "prev_gen.`id` < 345", "materialized": { @@ -1389,12 +1395,14 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "folks", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "folks.`name` = 'Me'" } @@ -1406,6 +1414,7 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1413,6 +1422,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["PRIMARY"], "rows": 12, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1422,6 +1432,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -1446,12 +1457,14 @@ EXPLAIN "query_block": { "select_id": 5, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 24, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "ancestors.`id` < 234" } @@ -1499,12 +1512,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -1515,12 +1530,14 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "v", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.`name` = 'Me' and v.father is not null and v.mother is not null" } @@ -1535,6 +1552,7 @@ EXPLAIN "used_key_parts": ["id"], "ref": ["test.v.father"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1548,6 +1566,7 @@ EXPLAIN "used_key_parts": ["id"], "ref": ["test.v.mother"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1558,12 +1577,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "a.father is not null and a.mother is not null" } @@ -1578,6 +1599,7 @@ EXPLAIN "used_key_parts": ["id"], "ref": ["a.father"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1591,6 +1613,7 @@ EXPLAIN "used_key_parts": ["id"], "ref": ["a.mother"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1824,12 +1847,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -1840,12 +1865,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1856,12 +1883,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a < 1000" } @@ -2460,6 +2489,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -2470,6 +2500,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -2494,6 +2525,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "UNION", + "cost": "REPLACED", "r_loops": 10, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -2504,6 +2536,7 @@ ANALYZE "r_loops": 10, "rows": 2, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -3869,6 +3902,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -3879,6 +3913,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -3898,6 +3933,7 @@ ANALYZE "r_loops": 3, "rows": 1, "r_rows": 0.333333333, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -3941,6 +3977,7 @@ ANALYZE "query_block": { "select_id": 4, "operation": "UNION", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -3952,6 +3989,7 @@ ANALYZE "r_loops": 1, "rows": 14, "r_rows": 14, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -3971,6 +4009,7 @@ ANALYZE "r_loops": 14, "rows": 1, "r_rows": 0.071428571, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4145,6 +4184,7 @@ ANALYZE "query_block": { "select_id": 4, "operation": "UNION", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -4155,6 +4195,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4170,6 +4211,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -4180,6 +4222,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4193,6 +4236,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "UNION", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -4203,6 +4247,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4222,6 +4267,7 @@ ANALYZE "r_loops": 4, "rows": 2, "r_rows": 0.5, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4300,6 +4346,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -4310,6 +4357,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/cte_recursive.test b/mysql-test/main/cte_recursive.test index 8efbdbf9677..06237c7b5dc 100644 --- a/mysql-test/main/cte_recursive.test +++ b/mysql-test/main/cte_recursive.test @@ -1110,6 +1110,7 @@ as ) select ancestors.name, ancestors.dob from ancestors; +--source include/explain-no-costs.inc explain FORMAT=JSON with recursive prev_gen @@ -1139,6 +1140,7 @@ as select ancestors.name, ancestors.dob from ancestors; --echo # +--source include/explain-no-costs.inc explain format=json with recursive ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, @@ -1343,6 +1345,7 @@ drop table folks; create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +--source include/explain-no-costs.inc explain format=json with recursive t as (select a from t1 union select a+10 from t where a < 1000) select * from t; diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index bf3b8591f0f..ab0e09cbec6 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -122,12 +122,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -137,6 +139,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 214" }, @@ -147,6 +150,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 214", "filesort": { "sort_key": "t1.a, t1.b", @@ -157,6 +161,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -208,12 +213,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -228,11 +235,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 300", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -243,6 +252,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -297,12 +307,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -312,6 +324,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 400 or v1.max_c < 135" }, @@ -322,6 +335,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (max_c > 400 or max_c < 135)", "filesort": { "sort_key": "t1.a, t1.b", @@ -332,6 +346,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -375,12 +390,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -390,6 +407,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 300 or v1.max_c < 135" }, @@ -400,6 +418,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (max_c > 300 or max_c < 135)", "filesort": { "sort_key": "t1.a, t1.b", @@ -410,6 +429,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -442,12 +462,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -457,6 +479,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a > 6" }, @@ -467,6 +490,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -477,6 +501,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 6" } @@ -519,12 +544,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -534,6 +561,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.b > 25" }, @@ -544,6 +572,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -554,6 +583,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and t1.b > 25" } @@ -617,12 +647,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -632,6 +664,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a > 7 or v1.a < 2" }, @@ -642,6 +675,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -652,6 +686,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 7 or t1.a < 2" } @@ -708,12 +743,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -723,6 +760,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.a > 7 or v2.a > 5" }, @@ -733,6 +771,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -743,6 +782,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and (t1.a > 7 or t1.a > 5)" } @@ -785,12 +825,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -800,6 +842,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a > 4 or v1.a < 2" }, @@ -810,6 +853,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -820,6 +864,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 4 or t1.a < 2" } @@ -855,12 +900,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -870,6 +917,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 2 and v1.max_c > 400" }, @@ -880,6 +928,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 400", "filesort": { "sort_key": "t1.a, t1.b", @@ -890,6 +939,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 2" } @@ -936,12 +986,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a is not null" } @@ -956,11 +1008,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.avg_a > 0.45 and v.b > 10", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "avg_a < 22.333 and avg_a > 0.45", "filesort": { "sort_key": "t1_double.b, t1_double.c", @@ -971,6 +1025,7 @@ EXPLAIN "table_name": "t1_double", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1_double.b > 12.2 and t1_double.b > 10" } @@ -1005,12 +1060,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a is not null" } @@ -1025,11 +1082,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.avg_c > 15 and v.b > 1", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "avg_c > 12 and avg_c > 15", "filesort": { "sort_key": "t1_decimal.a, t1_decimal.b", @@ -1040,6 +1099,7 @@ EXPLAIN "table_name": "t1_decimal", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1_decimal.b > 1" } @@ -1097,12 +1157,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1112,6 +1174,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a > 7 and v1.max_c > 300 or v1.a < 4 and v1.max_c < 500" }, @@ -1122,6 +1185,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (t1.a > 7 and max_c > 300 or t1.a < 4 and max_c < 500)", "filesort": { "sort_key": "t1.a, t1.b", @@ -1132,6 +1196,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 7 or t1.a < 4" } @@ -1196,12 +1261,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1211,6 +1278,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 2 and v1.max_c > 120 or v1.a > 7" }, @@ -1221,6 +1289,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (t1.a < 2 and max_c > 120 or t1.a > 7)", "filesort": { "sort_key": "t1.a, t1.b", @@ -1231,6 +1300,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 2 or t1.a > 7" } @@ -1284,12 +1354,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1299,6 +1371,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 2 and v1.max_c > 120 or v1.a > 7" }, @@ -1309,6 +1382,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (t1.a < 2 and max_c > 120 or t1.a > 7)", "filesort": { "sort_key": "t1.a, t1.b", @@ -1319,6 +1393,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 2 or t1.a > 7" } @@ -1361,12 +1436,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1376,6 +1453,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 2 and v1.max_c < 200 or v1.a > 4" }, @@ -1386,6 +1464,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (t1.a < 2 and max_c < 200 or t1.a > 4 and max_c < 500)", "filesort": { "sort_key": "t1.a, t1.b", @@ -1396,6 +1475,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 2 or t1.a > 4" } @@ -1448,12 +1528,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1463,6 +1545,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 400 or v1.max_c < 135" }, @@ -1473,6 +1556,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (max_c > 400 or max_c < 135)", "filesort": { "sort_key": "t1.a, t1.b", @@ -1483,6 +1567,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1501,12 +1586,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1516,6 +1603,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 400 or v1.max_c < 135" }, @@ -1526,6 +1614,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (max_c > 400 or max_c < 135)", "filesort": { "sort_key": "t1.a, t1.b", @@ -1536,6 +1625,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1570,12 +1660,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 1 and t2.b is not null" } @@ -1590,11 +1682,13 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 1", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.b", @@ -1605,6 +1699,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -1635,12 +1730,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.d is not null" } @@ -1655,11 +1752,13 @@ EXPLAIN "used_key_parts": ["max_c"], "ref": ["test.t2.d"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 5 and v1.max_c = t2.d", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.b", @@ -1670,6 +1769,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 5" } @@ -1707,12 +1807,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 5 and t2.a is not null" } @@ -1727,10 +1829,12 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -1741,6 +1845,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 5" } @@ -1769,12 +1874,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null and t2.a is not null" } @@ -1789,10 +1896,12 @@ EXPLAIN "used_key_parts": ["a", "b"], "ref": ["test.t2.a", "test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -1803,6 +1912,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t1.a" } @@ -1836,12 +1946,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c > 150 and t2.c is not null" } @@ -1856,10 +1968,12 @@ EXPLAIN "used_key_parts": ["max_c"], "ref": ["test.t2.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 150", "filesort": { "sort_key": "t1.a, t1.b", @@ -1870,6 +1984,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1899,12 +2014,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 3" } @@ -1915,6 +2032,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 3 and v1.b = 3" }, @@ -1924,6 +2042,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "nested_loop": [ { @@ -1931,6 +2050,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 3 and t1.b = 3" } @@ -1959,12 +2079,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 2" } @@ -1975,6 +2097,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 1 and v1.b = 21" }, @@ -1984,6 +2107,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "nested_loop": [ { @@ -1991,6 +2115,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.b = 21" } @@ -2025,17 +2150,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.a = 'c' and v.b < 'Hermes'", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 9", "filesort": { "sort_key": "t1_char.b", @@ -2046,6 +2174,7 @@ EXPLAIN "table_name": "t1_char", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1_char.a = 'c' and t1_char.b < 'Hermes'" } @@ -2063,6 +2192,7 @@ EXPLAIN "table_name": "t", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -2108,12 +2238,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t.b > 1 or t.b = 1) and t.b is not null and t.b is not null" } @@ -2128,10 +2260,12 @@ EXPLAIN "used_key_parts": ["a", "b"], "ref": ["test.t.b", "test.t.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "avg_c > 12", "filesort": { "sort_key": "t1_decimal.a, t1_decimal.b", @@ -2142,6 +2276,7 @@ EXPLAIN "table_name": "t1_decimal", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1_decimal.b = t1_decimal.a and (t1_decimal.a > 1 or t1_decimal.a = 1)" } @@ -2187,12 +2322,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 4 or t2.c > 150" } @@ -2203,6 +2340,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -2212,6 +2350,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (t1.a < 4 or max_c > 150)", "filesort": { "sort_key": "t1.a, t1.b", @@ -2222,6 +2361,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2256,12 +2396,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 5 and t2.c > 250 and t2.a is not null and t2.c is not null" } @@ -2276,10 +2418,12 @@ EXPLAIN "used_key_parts": ["a", "max_c"], "ref": ["test.t2.a", "test.t2.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 250", "filesort": { "sort_key": "t1.a, t1.b", @@ -2290,6 +2434,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -2336,12 +2481,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 8" } @@ -2352,6 +2499,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 8 and v1.max_c = 404" }, @@ -2361,6 +2509,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c = 404", "filesort": { "sort_key": "t1.b", @@ -2371,6 +2520,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 8" } @@ -2406,12 +2556,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.d is not null" } @@ -2426,11 +2578,13 @@ EXPLAIN "used_key_parts": ["max_c"], "ref": ["test.t2.d"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a > 3 and v1.max_c > 200 and t2.b < v1.b and t2.d = v1.max_c", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -2441,6 +2595,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 3" } @@ -2476,12 +2631,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.c is not null and t.c is not null" } @@ -2496,11 +2653,13 @@ EXPLAIN "used_key_parts": ["b", "c"], "ref": ["test.t.c", "test.t.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.c > 10 or v.a = 1", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "avg_a < 22.333 and (t1_double.b > 10 or t1_double.a = 1)", "filesort": { "sort_key": "t1_double.b, t1_double.c", @@ -2511,6 +2670,7 @@ EXPLAIN "table_name": "t1_double", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1_double.c = t1_double.b and t1_double.b > 12.2" } @@ -2551,12 +2711,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.c > 18 and t.c is not null" } @@ -2571,11 +2733,13 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.a > 0.2 or v.b < 17 or t.c > 17", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "avg_a < 22.333 and (t1_double.a > 0.2 or t1_double.b < 17 or t1_double.c > 17)", "filesort": { "sort_key": "t1_double.b, t1_double.c", @@ -2586,6 +2750,7 @@ EXPLAIN "table_name": "t1_double", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1_double.b > 12.2 and t1_double.c > 18" } @@ -2657,17 +2822,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(v.a > 4 or v.a = 2 or v.b > 3) and v.avg_c = 13", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "avg_c > 12 and avg_c = 13", "filesort": { "sort_key": "t1_decimal.a, t1_decimal.b", @@ -2678,6 +2846,7 @@ EXPLAIN "table_name": "t1_decimal", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1_decimal.a > 4 or t1_decimal.a = 2 or t1_decimal.b > 3" } @@ -2695,6 +2864,7 @@ EXPLAIN "table_name": "t", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -2731,12 +2901,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null and t2.a is not null" } @@ -2751,11 +2923,13 @@ EXPLAIN "used_key_parts": ["a", "b"], "ref": ["test.t2.a", "test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 300", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -2766,6 +2940,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t1.a and t1.a > 5" } @@ -2807,12 +2982,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 2 and t2.c > 900" } @@ -2823,6 +3000,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -2831,6 +3009,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -2841,6 +3020,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2874,12 +3054,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null and t2.b is not null" } @@ -2894,10 +3076,12 @@ EXPLAIN "used_key_parts": ["a", "b"], "ref": ["test.t2.a", "test.t2.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -2908,6 +3092,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2955,12 +3140,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -2970,6 +3157,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -2979,6 +3167,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -2989,6 +3178,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3060,12 +3250,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -3075,6 +3267,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -3084,6 +3277,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3094,6 +3288,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3137,12 +3332,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 2 and t2.c > 900" } @@ -3153,6 +3350,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -3162,6 +3360,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3172,6 +3371,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3214,12 +3414,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null and t2.a is not null" } @@ -3234,10 +3436,12 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3248,6 +3452,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3268,11 +3473,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.b < 50", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3283,6 +3490,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and t1.b < 50" } @@ -3345,12 +3553,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b < 50" } @@ -3361,6 +3571,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -3370,6 +3581,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3380,6 +3592,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3400,11 +3613,13 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["v1.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.a = v1.a or v1.a = t2.a", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3415,6 +3630,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -3457,12 +3673,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -3472,6 +3690,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -3481,6 +3700,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3491,6 +3711,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3507,6 +3728,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "incremental", @@ -3516,6 +3738,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3526,6 +3749,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -3572,12 +3796,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -3587,6 +3813,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c < 300" }, @@ -3596,6 +3823,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c < 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -3606,6 +3834,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3622,6 +3851,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.b < 50 or v2.b = 19" }, @@ -3632,6 +3862,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3642,6 +3873,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and (t1.b < 50 or t1.b = 19)" } @@ -3679,12 +3911,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null and t2.a is not null and t2.a is not null" } @@ -3699,10 +3933,12 @@ EXPLAIN "used_key_parts": ["a", "b"], "ref": ["test.t2.a", "test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3713,6 +3949,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t1.a" } @@ -3734,11 +3971,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.max_c < 300", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c < 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -3749,6 +3988,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -3783,12 +4023,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -3798,6 +4040,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 1 and v1.b > 10" }, @@ -3808,6 +4051,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.b", @@ -3818,6 +4062,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.b > 10" } @@ -3839,10 +4084,12 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["v1.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -3853,6 +4100,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and t1.b > 10" } @@ -3898,17 +4146,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.a = 'b' and (v.b = 'Vika' or v.b = 'Ali')", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 9", "filesort": { "sort_key": "t1_char.b", @@ -3919,6 +4170,7 @@ EXPLAIN "table_name": "t1_char", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1_char.a = 'b' and (t1_char.b = 'Vika' or t1_char.b = 'Ali')" } @@ -3936,6 +4188,7 @@ EXPLAIN "table_name": "t", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a = 'b'" }, @@ -4005,12 +4258,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -4025,11 +4280,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v3.b < 50 or v3.b = 33", "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "min_c > 109", "filesort": { "sort_key": "t1.a, t1.b", @@ -4040,6 +4297,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 10 and (t1.b < 50 or t1.b = 33)" } @@ -4057,6 +4315,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c < 500" }, @@ -4066,6 +4325,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c < 500", "filesort": { "sort_key": "t1.a, t1.b", @@ -4076,6 +4336,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -4092,6 +4353,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.max_c > 300" }, @@ -4102,6 +4364,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -4112,6 +4375,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -4164,12 +4428,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b is not null" } @@ -4184,11 +4450,13 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 130 and v1.a is not null", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 130", "filesort": { "sort_key": "t1.a, t1.b", @@ -4199,6 +4467,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -4220,11 +4489,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["v1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.min_c < 130", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "min_c < 707 and min_c < 130", "filesort": { "sort_key": "t1.a, t1.b", @@ -4235,6 +4506,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -4320,12 +4592,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -4335,6 +4609,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.avg_c < 400 or v1.a > 1" }, @@ -4345,6 +4620,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (avg_c < 400 or t1.a > 1)", "filesort": { "sort_key": "t1.a, t1.b", @@ -4355,6 +4631,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -4376,11 +4653,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["v1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.min_c < 200", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "min_c < 707 and min_c < 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -4391,6 +4670,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -4412,11 +4692,13 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["v1.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v3.avg_c > 170 or v3.a < 5", "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "avg_c > 170 or t1.a < 5", "filesort": { "sort_key": "t1.a, t1.b", @@ -4427,6 +4709,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 8" } @@ -4487,12 +4770,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -4502,6 +4787,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(v1.a = 1 or v1.max_c < 300) and v1.b > 25" }, @@ -4512,6 +4798,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (t1.a = 1 or max_c < 300)", "filesort": { "sort_key": "t1.a, t1.b", @@ -4522,6 +4809,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 25" } @@ -4568,12 +4856,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -4588,11 +4878,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 300 and v1.b < 30", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -4603,6 +4895,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and t1.b < 30" } @@ -4656,12 +4949,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c > 800 and t2.b is not null" } @@ -4676,11 +4971,13 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 5", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -4691,6 +4988,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 5" } @@ -4709,12 +5007,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.d > 800" } @@ -4725,6 +5025,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 100 and v1.a > 7" }, @@ -4734,6 +5035,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 100", "filesort": { "sort_key": "t1.a, t1.b", @@ -4744,6 +5046,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 7" } @@ -4820,12 +5123,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b = 19" } @@ -4836,6 +5141,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b = 19 and v1.a < 5" }, @@ -4845,6 +5151,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a", @@ -4855,6 +5162,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 19 and t1.a < 5" } @@ -4873,12 +5181,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -4888,6 +5198,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 400 or v1.avg_c > 270" }, @@ -4898,6 +5209,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (max_c > 400 or avg_c > 270)", "filesort": { "sort_key": "t1.a, t1.b", @@ -4908,6 +5220,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -4995,12 +5308,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -5010,6 +5325,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 1 or v1.a = 6" }, @@ -5020,6 +5336,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -5030,6 +5347,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 or t1.a = 6" } @@ -5048,12 +5366,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -5063,6 +5383,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a > 3 and v1.b > 27 or v1.max_c > 550" }, @@ -5073,6 +5394,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (t1.a > 3 and t1.b > 27 or max_c > 550)", "filesort": { "sort_key": "t1.a, t1.b", @@ -5083,6 +5405,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -5171,12 +5494,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 1" } @@ -5187,6 +5512,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 1 and (v1.max_c < 500 or v1.avg_c > 500)" }, @@ -5197,6 +5523,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and (max_c < 500 or avg_c > 500)", "filesort": { "sort_key": "t1.b", @@ -5207,6 +5534,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -5225,12 +5553,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 2" } @@ -5241,6 +5571,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.b > 10" }, @@ -5251,6 +5582,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 5, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -5261,6 +5593,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and t1.b > 10" } @@ -5279,12 +5612,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c is not null" } @@ -5299,11 +5634,13 @@ EXPLAIN "used_key_parts": ["max_c"], "ref": ["test.t2.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.b < 10", "materialized": { "query_block": { "select_id": 6, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -5314,6 +5651,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and t1.b < 10" } @@ -5368,12 +5706,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -5383,6 +5723,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 40, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v_union.a < 3 and v_union.c > 100" }, @@ -5398,6 +5739,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 109 and c > 100", "filesort": { "sort_key": "t1.a, t1.b", @@ -5408,6 +5750,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 10 and t1.a < 3" } @@ -5421,6 +5764,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 300 and c > 100", "filesort": { "sort_key": "t1.a, t1.b", @@ -5431,6 +5775,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a < 3" } @@ -5490,12 +5835,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -5505,6 +5852,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 40, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(v_union.a < 2 or v_union.c > 800) and v_union.b > 12" }, @@ -5521,6 +5869,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 109 and (t1.a < 2 or c > 800)", "filesort": { "sort_key": "t1.a, t1.b", @@ -5531,6 +5880,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 10 and t1.b > 12" } @@ -5544,6 +5894,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 300 and (t1.a < 2 or c > 800)", "filesort": { "sort_key": "t1.a, t1.b", @@ -5554,6 +5905,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.b > 12" } @@ -5600,12 +5952,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 1" } @@ -5616,6 +5970,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 40, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v_union.a = 1 and v_union.c < 200" }, @@ -5631,6 +5986,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 109 and c < 200", "filesort": { "sort_key": "t1.b", @@ -5641,6 +5997,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -5654,6 +6011,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 300 and c < 200", "filesort": { "sort_key": "t1.b", @@ -5664,6 +6022,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.b > 10" } @@ -5708,12 +6067,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a is not null" } @@ -5728,11 +6089,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.b = 'Vika' and v.max_c > 2", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 9 and max_c > 2", "filesort": { "sort_key": "t1_char.a", @@ -5743,6 +6106,7 @@ EXPLAIN "table_name": "t1_char", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1_char.b = 'Vika'" } @@ -5791,12 +6155,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 1" } @@ -5807,6 +6173,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 1" }, @@ -5816,6 +6183,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.b", @@ -5826,6 +6194,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -5843,6 +6212,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 40, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v_union.a = 1" }, @@ -5859,6 +6229,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 109", "filesort": { "sort_key": "t1.b", @@ -5869,6 +6240,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -5882,6 +6254,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.b", @@ -5892,6 +6265,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.b > 10" } @@ -5947,12 +6321,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t2.a = 6 or t2.a = 8) and t2.a is not null" } @@ -5967,6 +6343,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 6, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.c > 200", "materialized": { @@ -5978,6 +6355,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 109 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -5988,6 +6366,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 10 and (t1.a = 6 or t1.a = 8)" } @@ -6001,6 +6380,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 300 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -6011,6 +6391,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and (t1.a = 6 or t1.a = 8)" } @@ -6024,6 +6405,7 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 707 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -6034,6 +6416,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c > 300 and (t1.a = 6 or t1.a = 8)" } @@ -6134,12 +6517,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -6154,6 +6539,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.c > 6", "materialized": { @@ -6165,12 +6551,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 10 and t1.a + 1 > 6" } @@ -6182,12 +6570,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.c > 100 and t1.c > 6" } @@ -6266,12 +6656,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -6286,6 +6678,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 1 or v.b < 20", "materialized": { @@ -6297,12 +6690,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 10 and (t1.a > 1 or t1.b < 20)" } @@ -6314,12 +6709,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.c > 100 and (t1.a > 1 or t1.b < 20)" } @@ -6366,12 +6763,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -6386,6 +6785,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(v.b = 19 or v.b = 21) and (v.c < 3 or v.c > 600)", "materialized": { @@ -6397,12 +6797,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 10 and (t1.b = 19 or t1.b = 21) and (t1.a + 1 < 3 or t1.a + 1 > 600)" } @@ -6414,12 +6816,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.c > 100 and (t1.b = 19 or t1.b = 21) and (t1.c < 3 or t1.c > 600)" } @@ -6463,12 +6867,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -6483,6 +6889,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.b < 20", "materialized": { @@ -6494,6 +6901,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 109", "filesort": { "sort_key": "t1.a, t1.b", @@ -6504,6 +6912,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 10 and t1.b < 20" } @@ -6517,12 +6926,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.b < 20" } @@ -6585,12 +6996,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -6605,6 +7018,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t2.a < 3 or v.b < 40) and v.c > 500", "materialized": { @@ -6616,6 +7030,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 109 and c > 500", "filesort": { "sort_key": "t1.a, t1.b", @@ -6626,6 +7041,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 10 and (t1.a < 3 or t1.b < 40)" } @@ -6639,12 +7055,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and (t1.a < 3 or t1.b < 40) and t1.c + 100 > 500" } @@ -6709,17 +7127,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v4.a < 13", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "v1.a, v1.b", "temporary_table": { @@ -6729,11 +7150,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 15 and v1.a < 13", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -6744,6 +7167,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 15 and t1.a < 13" } @@ -6768,6 +7192,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a > 5 and v1.b > 12" }, @@ -6777,6 +7202,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -6787,6 +7213,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and t1.b > 12" } @@ -6829,12 +7256,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null and t2.a is not null" } @@ -6849,10 +7278,12 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "v1.a, v1.b", "temporary_table": { @@ -6862,11 +7293,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 15", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -6877,6 +7310,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 15" } @@ -6905,11 +7339,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b > 30", "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -6920,6 +7356,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 30" } @@ -6964,12 +7401,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 1 and t2.a is not null and t2.a is not null" } @@ -6984,11 +7423,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v4.min_c > 100", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "min_c > 100", "filesort": { "sort_key": "v1.a, v1.b", @@ -6999,11 +7440,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 15 and v1.a > 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7014,6 +7457,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 15 and t1.a > 1" } @@ -7042,11 +7486,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b < 30", "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7057,6 +7503,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.b < 30" } @@ -7186,12 +7633,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -7201,6 +7650,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v4.b > 10 and v4.a > 1 or v4.b < 20" }, @@ -7211,6 +7661,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "v1.a, v1.b", "temporary_table": { @@ -7220,11 +7671,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 15 and (v1.b > 10 and v1.a > 1 or v1.b < 20)", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7235,6 +7688,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 15 and (t1.b > 10 and t1.a > 1 or t1.b < 20)" } @@ -7263,11 +7717,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["v4.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.max_c > 200", "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -7278,6 +7734,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -7315,17 +7772,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v4.a > 12 and v4.min_c < 300 and v4.b > 13 or v4.a < 1", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "v1.a > 12 and min_c < 300 and v1.b > 13 or v1.a < 1", "filesort": { "sort_key": "v1.a, v1.b", @@ -7336,11 +7796,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 15 and (v1.a > 12 and v1.b > 13 or v1.a < 1)", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7351,6 +7813,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 15 and (t1.a > 12 and t1.b > 13 or t1.a < 1)" } @@ -7375,6 +7838,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -7383,6 +7847,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7393,6 +7858,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -7432,17 +7898,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v4.b = v4.a and v4.min_c < 100 and v4.a is not null", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "min_c < 100", "filesort": { "sort_key": "v1.a, v1.b", @@ -7453,11 +7922,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b = v1.a and v1.a < 15", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7468,6 +7939,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t1.a and t1.a < 15" } @@ -7496,10 +7968,12 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["v4.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7510,6 +7984,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -7549,17 +8024,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v4.b = v4.a and v4.a < 30 and v4.a is not null", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "v1.a, v1.b", "temporary_table": { @@ -7569,11 +8047,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b = v1.a and v1.a < 15 and v1.a < 30", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7584,6 +8064,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t1.a and t1.a < 15 and t1.a < 30" } @@ -7612,10 +8093,12 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["v4.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7626,6 +8109,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and t1.b < 30" } @@ -7665,17 +8149,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v4.b = v4.a and (v4.a < 30 or v4.a > 2) and v4.a is not null", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "v1.a, v1.b", "temporary_table": { @@ -7685,11 +8172,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b = v1.a and v1.a < 15 and (v1.a < 30 or v1.a > 2)", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7700,6 +8189,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t1.a and t1.a < 15 and (t1.a < 30 or t1.a > 2)" } @@ -7728,10 +8218,12 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["v4.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7742,6 +8234,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5 and (t1.b < 30 or t1.b > 2)" } @@ -7789,17 +8282,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(v4.a < 12 and v4.b > 13 or v4.a > 10) and v4.min_c > 100 and v4.min_c is not null", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "min_c > 100", "filesort": { "sort_key": "v1.a, v1.b", @@ -7810,11 +8306,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 15 and (v1.a < 12 and v1.b > 13 or v1.a > 10)", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7825,6 +8323,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 15 and (t1.a < 12 and t1.b > 13 or t1.a > 10)" } @@ -7853,10 +8352,12 @@ EXPLAIN "used_key_parts": ["max_c"], "ref": ["v4.min_c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707 and max_c > 100", "filesort": { "sort_key": "t1.a, t1.b", @@ -7867,6 +8368,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -7913,12 +8415,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c > 100 and t2.c is not null" } @@ -7933,11 +8437,13 @@ EXPLAIN "used_key_parts": ["min_c"], "ref": ["test.t2.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v4.a < 12 and t2.b > 13 or v4.a > 10", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "min_c > 100", "filesort": { "sort_key": "v1.a, v1.b", @@ -7948,11 +8454,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 15 and (v1.a < 12 or v1.a > 10)", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -7963,6 +8471,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 15 and (t1.a < 12 or t1.a > 10)" } @@ -7987,6 +8496,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -7995,6 +8505,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "max_c < 707", "filesort": { "sort_key": "t1.a, t1.b", @@ -8005,6 +8516,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 5" } @@ -8159,6 +8671,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "0 or (2,(subquery#3))", "nested_loop": [ { @@ -8174,6 +8687,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 50, "attached_condition": "t2.b = 2", "first_match": "t1" @@ -8184,6 +8698,7 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -8195,16 +8710,19 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["func"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 5, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.c = 2" } @@ -8257,6 +8775,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "0 or (2,(subquery#3))", "nested_loop": [ { @@ -8272,6 +8791,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 50, "attached_condition": "t2.b = 2", "first_match": "t1" @@ -8282,6 +8802,7 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -8293,10 +8814,12 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["func"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 5, + "cost": "COST_REPLACED", "having_condition": "s > 2", "filesort": { "sort_key": "t4.d", @@ -8307,6 +8830,7 @@ EXPLAIN "table_name": "t4", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -8361,23 +8885,27 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.b = 1", "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b = 1" } @@ -8416,12 +8944,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -8435,17 +8965,20 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "trigcond(v2.b is null) and trigcond(trigcond(t1.a is not null))", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -8471,23 +9004,27 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(v1.i <= 3)", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.i <= 3)" } @@ -8532,12 +9069,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.b,(subquery#2)) or t1.b = 100" } @@ -8547,6 +9086,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -8558,16 +9098,19 @@ EXPLAIN "used_key_parts": ["pk2"], "ref": ["func"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -8594,12 +9137,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.b,(subquery#3)) or t1.b = 100" } @@ -8609,6 +9154,7 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -8620,16 +9166,19 @@ EXPLAIN "used_key_parts": ["pk2"], "ref": ["func"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -8678,23 +9227,27 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 50", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 50" } @@ -8736,17 +9289,20 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.s < 50", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "s < 50", "filesort": { "sort_key": "t3.a", @@ -8757,6 +9313,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -8794,6 +9351,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -8820,17 +9378,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b = 2", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 2" } @@ -8864,6 +9425,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -8887,17 +9449,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.f = 2", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.f = 2" } @@ -8913,6 +9478,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.pk > 2" }, @@ -8922,6 +9488,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -8932,6 +9499,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t.pk > 2" } @@ -8964,6 +9532,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -8987,17 +9556,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "sq.i = 3", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.i = 3" } @@ -9031,6 +9603,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -9054,17 +9627,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "sq.i = 2.71", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.i = 2.7100000381469727" } @@ -9093,6 +9669,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -9116,17 +9693,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "sq.i = 3.21", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.i = 3.21" } @@ -9155,6 +9735,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -9178,17 +9759,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "sq.i = 'aa'", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.i = 'aa'" } @@ -9219,6 +9803,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -9242,17 +9827,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "sq.i = '2007-05-28 00:00:00'", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.i = TIMESTAMP'2007-05-28 00:00:00'" } @@ -9281,6 +9869,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -9304,17 +9893,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "sq.i = '2007-05-28'", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.i = DATE'2007-05-28'" } @@ -9343,6 +9935,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -9366,17 +9959,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "sq.i = '10:00:02'", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.i = TIME'10:00:02'" } @@ -9405,23 +10001,27 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "nullif(1,v1.i)", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "nullif(1,t1.i)" } @@ -9500,23 +10100,27 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c = 'foo'", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = 'foo'" } @@ -9531,12 +10135,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "1 = t2.a" } @@ -9561,23 +10167,27 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "((1,(subquery#2))) or v1.c = 'foo'", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -9591,12 +10201,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 128, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "1 = t2.a" } @@ -9737,12 +10349,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 2 and t1.a is not null" } @@ -9757,10 +10371,12 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t2.b", "temporary_table": { @@ -9770,6 +10386,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b > 2" } @@ -9797,12 +10414,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 2 and t1.a is not null" } @@ -9817,10 +10436,12 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t2.b", "temporary_table": { @@ -9830,6 +10451,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b > 2" } @@ -9860,12 +10482,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 2 and t1.a is not null" } @@ -9880,10 +10504,12 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -9891,6 +10517,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b > 2" } @@ -9917,12 +10544,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 2 and t1.a is not null" } @@ -9937,10 +10566,12 @@ EXPLAIN "used_key_parts": ["m"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "m > 2", "filesort": { "sort_key": "t2.b", @@ -9951,6 +10582,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -9980,17 +10612,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.f > 0", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "f > 0", "nested_loop": [ { @@ -9998,6 +10633,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -10028,6 +10664,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -10039,6 +10676,7 @@ EXPLAIN "used_key_parts": ["i1"], "ref": ["const"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "using_index": true } @@ -10049,6 +10687,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.i2 = 1" }, @@ -10058,12 +10697,14 @@ EXPLAIN "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.i2 = 1" } @@ -10096,17 +10737,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.f = 'a' or t.f = 'b'", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -10114,6 +10758,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -10151,12 +10796,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.id2 is not null" } @@ -10171,11 +10818,13 @@ EXPLAIN "used_key_parts": ["id2"], "ref": ["test.t1.id2"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "vc.ct > 0", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "ct > 0", "filesort": { "sort_key": "t2.id2", @@ -10186,6 +10835,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -10250,12 +10900,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x = 1" } @@ -10266,6 +10918,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 1 and v1.b = 1 and v1.max_c > 30" }, @@ -10275,6 +10928,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c > 37 and max_c > 30", "nested_loop": [ { @@ -10282,6 +10936,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.b = 1" } @@ -10335,12 +10990,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x = 1" } @@ -10351,6 +11008,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 1 and v1.b = 1 and v1.d = 1 and v1.max_c > 30" }, @@ -10360,6 +11018,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c > 37 and max_c > 30", "nested_loop": [ { @@ -10367,6 +11026,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.b = 1 and t1.d = 1" } @@ -10452,12 +11112,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" } @@ -10472,10 +11134,12 @@ EXPLAIN "used_key_parts": ["e", "max_f"], "ref": ["test.t1.a", "test.t1.b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_f > 18", "filesort": { "sort_key": "t2.e", @@ -10486,6 +11150,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e > 1" } @@ -10550,12 +11215,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b < 25 and t1.a is not null and t1.b is not null" } @@ -10570,10 +11237,12 @@ EXPLAIN "used_key_parts": ["e", "max_f"], "ref": ["test.t1.a", "test.t1.b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_f > 18 and max_f < 25", "filesort": { "sort_key": "t2.e", @@ -10584,6 +11253,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -10647,12 +11317,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a is not null and t1.b is not null" } @@ -10667,11 +11339,13 @@ EXPLAIN "used_key_parts": ["e", "max_f"], "ref": ["test.t1.a", "test.t1.b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -10679,11 +11353,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "d_tab.e > 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t2.e", "temporary_table": { @@ -10693,6 +11369,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e > 1" } @@ -10763,12 +11440,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a is not null and t1.b is not null" } @@ -10783,11 +11462,13 @@ EXPLAIN "used_key_parts": ["e", "max_f"], "ref": ["test.t1.a", "test.t1.b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -10795,11 +11476,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "d_tab.max_f > 20", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_f > 20", "filesort": { "sort_key": "t2.e", @@ -10810,6 +11493,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -10871,17 +11555,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "dt.a = 2", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "a = 2", "filesort": { "sort_key": "t1.a", @@ -10892,6 +11579,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -10928,17 +11616,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "dt.a > 1", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "a > 1", "filesort": { "sort_key": "t1.a", @@ -10949,6 +11640,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 3" } @@ -10985,17 +11677,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "dt.a = 'ab'", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -11005,6 +11700,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -11040,17 +11736,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "dt.a = 1", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -11060,6 +11759,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -11115,12 +11815,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "1 in (0,t1.a) and t1.a is not null" } @@ -11135,10 +11837,12 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -11148,6 +11852,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "1 in (0,t1.a) and 1 in (0,t1.a)" } @@ -11183,12 +11888,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a in (1,t1.a) and t1.a is not null" } @@ -11203,10 +11910,12 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -11216,6 +11925,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a in (1,t1.a)" } @@ -11314,17 +12024,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a <= 2", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -11334,6 +12047,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a <= 2" } @@ -11360,12 +12074,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -11380,11 +12096,13 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = t.c and t.a >= 3", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -11394,6 +12112,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a >= 3" } @@ -11423,12 +12142,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -11437,17 +12158,20 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a = 2 and t2.a = t.c + 9", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2" } @@ -11497,17 +12221,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "case when tab2.max_a = 1 or tab2.max_a = 2 then 1 else 0 end = 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "case when max_a = 1 or max_a = 2 then 1 else 0 end = 1", "filesort": { "sort_key": "t1.b", @@ -11518,6 +12245,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -11554,17 +12282,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "case when tab2.max_a = 1 or tab2.max_a > 2 and tab2.max_a < 4 then 1 else 0 end = 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "case when max_a = 1 or max_a > 2 and max_a < 4 then 1 else 0 end = 1", "filesort": { "sort_key": "t1.b", @@ -11575,6 +12306,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -11611,17 +12343,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "case when tab2.max_a > 1 and (tab2.max_a = 2 or tab2.max_a > 2) then 1 else 0 end = 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "case when max_a > 1 and (max_a = 2 or max_a > 2) then 1 else 0 end = 1", "filesort": { "sort_key": "t1.b", @@ -11632,6 +12367,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -11668,17 +12404,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "case when tab2.b = 2 or tab2.b = 4 then 1 else 0 end = 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.b", "temporary_table": { @@ -11688,6 +12427,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "case when t1.b = 2 or t1.b = 4 then 1 else 0 end = 1" } @@ -11745,33 +12485,39 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 144, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.f is not null", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -11786,6 +12532,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f is not null" }, @@ -11828,23 +12575,27 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.f is not null", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 8, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f is not null" } @@ -11859,16 +12610,19 @@ EXPLAIN "used_key_parts": ["f"], "ref": ["test.t1.f"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 8, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f is not null" } @@ -11913,12 +12667,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f2 < 2 and t1.f2 is not null" } @@ -11933,16 +12689,19 @@ EXPLAIN "used_key_parts": ["f2"], "ref": ["test.t1.f2"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f2 < 2" } @@ -11968,12 +12727,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f2 < 2 and t1.f2 is not null" } @@ -11988,10 +12749,12 @@ EXPLAIN "used_key_parts": ["f2"], "ref": ["test.t1.f2"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -11999,6 +12762,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f2 < 2" } @@ -12048,12 +12812,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -12254,12 +13020,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v3.col1 = 123 and v3.col2 = 321", "materialized": { @@ -12269,6 +13037,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -12280,6 +13049,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["const"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -12290,6 +13060,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -12301,6 +13072,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["const"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -12338,17 +13110,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.s + 1 > 10 and v2.a > 1 and v2.a2 > 123", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "s + 1 > 10 and a2 > 123", "filesort": { "sort_key": "t1.a, f1(t1.a)", @@ -12359,6 +13134,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -12391,12 +13167,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t4", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t4.a + 1 > 10 and t4.b > 1 and t4.c > 123 and t4.a is not null and t4.b is not null and t4.c is not null" } @@ -12411,12 +13189,14 @@ EXPLAIN "used_key_parts": ["a", "f1(a)", "sum(b)"], "ref": ["test.t4.a", "test.t4.b", "test.t4.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t4.c = ``.`sum(b)`", "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`f1(a)` > 1 and `sum(b)` > 123", "temporary_table": { "nested_loop": [ @@ -12425,6 +13205,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a + 1 > 10" } @@ -12488,12 +13269,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 5 and t2.a is not null" } @@ -12508,6 +13291,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -12518,6 +13302,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -12528,6 +13313,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a < 5" } @@ -12541,6 +13327,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 100", "filesort": { "sort_key": "t1.a, t1.b", @@ -12551,6 +13338,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a < 5" } @@ -12590,12 +13378,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 8" } @@ -12606,6 +13396,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 8" }, @@ -12621,6 +13412,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.b", @@ -12631,6 +13423,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 8" } @@ -12644,6 +13437,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 100", "filesort": { "sort_key": "t1.b", @@ -12654,6 +13448,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 8 and t1.b > 10" } @@ -12692,12 +13487,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 8" } @@ -12708,6 +13505,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 8" }, @@ -12723,6 +13521,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.b", @@ -12733,6 +13532,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 8" } @@ -12746,6 +13546,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 100", "filesort": { "sort_key": "t1.b", @@ -12756,6 +13557,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 8 and t1.b > 10" } @@ -12796,12 +13598,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -12816,6 +13620,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 200", "materialized": { @@ -12827,6 +13632,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -12837,6 +13643,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9" } @@ -12850,6 +13657,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 100 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -12860,6 +13668,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10" } @@ -12901,12 +13710,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 5 and t2.a is not null" } @@ -12921,6 +13732,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 110", "materialized": { @@ -12932,6 +13744,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300 and c > 110", "filesort": { "sort_key": "t1.a, t1.b", @@ -12942,6 +13755,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a < 5" } @@ -12955,6 +13769,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 100 and c > 110", "filesort": { "sort_key": "t1.a, t1.b", @@ -12965,6 +13780,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a < 5" } @@ -13007,12 +13823,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -13027,6 +13845,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b > 27 or v1.b < 19", "materialized": { @@ -13038,6 +13857,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -13048,6 +13868,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and (t1.b > 27 or t1.b < 19)" } @@ -13061,6 +13882,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 100", "filesort": { "sort_key": "t1.a, t1.b", @@ -13071,6 +13893,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and (t1.b > 27 or t1.b < 19)" } @@ -13119,12 +13942,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -13139,6 +13964,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 200 or v1.c < 105", "materialized": { @@ -13150,6 +13976,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300 and (c > 200 or c < 105)", "filesort": { "sort_key": "t1.a, t1.b", @@ -13160,6 +13987,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9" } @@ -13173,6 +14001,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 100 and (c > 200 or c < 105)", "filesort": { "sort_key": "t1.a, t1.b", @@ -13183,6 +14012,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10" } @@ -13253,12 +14083,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -13268,6 +14100,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a > 3 or v1.a = 1 and v1.c < 110" }, @@ -13284,6 +14117,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300 and (t1.a > 3 and c > 110 or t1.a = 1 and c < 110)", "filesort": { "sort_key": "t1.a, t1.b", @@ -13294,6 +14128,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and (t1.a > 3 or t1.a = 1)" } @@ -13307,6 +14142,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 100 and (t1.a > 3 and c > 110 or t1.a = 1 and c < 110)", "filesort": { "sort_key": "t1.a, t1.b", @@ -13317,6 +14153,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and (t1.a > 3 or t1.a = 1)" } @@ -13416,12 +14253,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b is not null" } @@ -13436,6 +14275,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c = 909 and t2.b > 13 or d1.a < 4 and d1.c < 200", "materialized": { @@ -13447,6 +14287,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300 and (t1.b > 13 or t1.a < 4 and c < 200)", "filesort": { "sort_key": "t1.a, t1.b", @@ -13457,6 +14298,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and (t1.b > 13 or t1.a < 4)" } @@ -13470,6 +14312,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 100 and (t1.b > 13 or t1.a < 4 and c < 200)", "filesort": { "sort_key": "t1.a, t1.b", @@ -13480,6 +14323,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and (t1.b > 13 or t1.a < 4)" } @@ -13531,12 +14375,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 5 and t2.a is not null" } @@ -13551,6 +14397,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -13561,6 +14408,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -13571,6 +14419,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a < 5" } @@ -13584,6 +14433,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -13594,6 +14444,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a < 5" } @@ -13635,12 +14486,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 6" } @@ -13651,6 +14504,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 6" }, @@ -13666,6 +14520,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200", "filesort": { "sort_key": "t1.b", @@ -13676,6 +14531,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 6" } @@ -13689,6 +14545,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.b", @@ -13699,6 +14556,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 6 and t1.b > 10" } @@ -13739,12 +14597,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = 6" } @@ -13755,6 +14615,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a = 6" }, @@ -13770,6 +14631,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200", "filesort": { "sort_key": "t1.b", @@ -13780,6 +14642,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 6" } @@ -13793,6 +14656,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.b", @@ -13803,6 +14667,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 6 and t1.b > 10" } @@ -13847,12 +14712,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -13867,6 +14734,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 500", "materialized": { @@ -13878,6 +14746,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200 and c > 500", "filesort": { "sort_key": "t1.a, t1.b", @@ -13888,6 +14757,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9" } @@ -13901,6 +14771,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 300 and c > 500", "filesort": { "sort_key": "t1.a, t1.b", @@ -13911,6 +14782,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10" } @@ -13952,12 +14824,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 5 and t2.a is not null" } @@ -13972,6 +14846,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 500", "materialized": { @@ -13983,6 +14858,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200 and c > 500", "filesort": { "sort_key": "t1.a, t1.b", @@ -13993,6 +14869,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a < 5" } @@ -14006,6 +14883,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 300 and c > 500", "filesort": { "sort_key": "t1.a, t1.b", @@ -14016,6 +14894,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a < 5" } @@ -14060,12 +14939,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -14080,6 +14961,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b > 27 or v1.b < 19", "materialized": { @@ -14091,6 +14973,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14101,6 +14984,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and (t1.b > 27 or t1.b < 19)" } @@ -14114,6 +14998,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -14124,6 +15009,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and (t1.b > 27 or t1.b < 19)" } @@ -14172,12 +15058,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a is not null" } @@ -14192,6 +15080,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c < 400 or v1.c > 800", "materialized": { @@ -14203,6 +15092,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200 and (c < 400 or c > 800)", "filesort": { "sort_key": "t1.a, t1.b", @@ -14213,6 +15103,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9" } @@ -14226,6 +15117,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 300 and (c < 400 or c > 800)", "filesort": { "sort_key": "t1.a, t1.b", @@ -14236,6 +15128,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10" } @@ -14304,12 +15197,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -14319,6 +15214,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a > 1 or v1.a = 1 and v1.c > 500" }, @@ -14335,6 +15231,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200 and (t1.a > 1 and c < 500 or t1.a = 1 and c > 500)", "filesort": { "sort_key": "t1.a, t1.b", @@ -14345,6 +15242,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and (t1.a > 1 or t1.a = 1)" } @@ -14358,6 +15256,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 300 and (t1.a > 1 and c < 500 or t1.a = 1 and c > 500)", "filesort": { "sort_key": "t1.a, t1.b", @@ -14368,6 +15267,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and (t1.a > 1 or t1.a = 1)" } @@ -14463,12 +15363,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b is not null" } @@ -14483,6 +15385,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c = 988 and t2.b > 13 or d1.a > 4 and d1.c > 500", "materialized": { @@ -14494,6 +15397,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200 and (t1.b > 13 or t1.a > 4 and c > 500)", "filesort": { "sort_key": "t1.a, t1.b", @@ -14504,6 +15408,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and (t1.b > 13 or t1.a > 4)" } @@ -14517,6 +15422,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 300 and (t1.b > 13 or t1.a > 4 and c > 500)", "filesort": { "sort_key": "t1.a, t1.b", @@ -14527,6 +15433,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and (t1.b > 13 or t1.a > 4)" } @@ -14580,12 +15487,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 5 and t2.a is not null" } @@ -14600,6 +15509,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 200", "materialized": { @@ -14611,6 +15521,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14621,6 +15532,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a > 5" } @@ -14634,12 +15546,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "__5.a > 5 and __5.c > 200", "materialized": { @@ -14651,6 +15565,7 @@ EXPLAIN { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "c < 300 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14661,6 +15576,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a > 5" } @@ -14674,6 +15590,7 @@ EXPLAIN "query_block": { "select_id": 5, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c < 530 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14684,6 +15601,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 3 and t1.a > 5" } @@ -14746,12 +15664,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 4 and t2.a is not null" } @@ -14766,6 +15686,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c < 200", "materialized": { @@ -14777,6 +15698,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200 and c < 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14787,6 +15709,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a > 4" } @@ -14800,6 +15723,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c < 500 and c < 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14810,6 +15734,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 3 and t1.a > 4" } @@ -14823,6 +15748,7 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 300 and c < 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14833,6 +15759,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a > 4" } @@ -14884,12 +15811,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 5 and t2.a is not null" } @@ -14904,6 +15833,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 200", "materialized": { @@ -14915,6 +15845,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14925,6 +15856,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a > 5" } @@ -14938,6 +15870,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 300 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14948,6 +15881,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a > 5" } @@ -14961,6 +15895,7 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 530 and c > 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -14971,6 +15906,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 3 and t1.a > 5" } @@ -15024,12 +15960,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 4 and t2.a is not null" } @@ -15044,6 +15982,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c < 200", "materialized": { @@ -15055,6 +15994,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 200 and c < 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -15065,6 +16005,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a > 4" } @@ -15078,6 +16019,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c < 500 and c < 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -15088,6 +16030,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 3 and t1.a > 4" } @@ -15101,6 +16044,7 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 300 and c < 200", "filesort": { "sort_key": "t1.a, t1.b", @@ -15111,6 +16055,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a > 4" } @@ -15162,12 +16107,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 4 and t2.a is not null" } @@ -15182,6 +16129,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c < 150", "materialized": { @@ -15193,6 +16141,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300 and c < 150", "filesort": { "sort_key": "t1.a, t1.b", @@ -15203,6 +16152,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a > 4" } @@ -15216,6 +16166,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c < 500 and c < 150", "filesort": { "sort_key": "t1.a, t1.b", @@ -15226,6 +16177,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 7 and t1.a > 4" } @@ -15239,6 +16191,7 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c > 150 and c < 150", "filesort": { "sort_key": "t1.a, t1.b", @@ -15249,6 +16202,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a > 4" } @@ -15300,12 +16254,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 4 and t2.a is not null" } @@ -15320,6 +16276,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c < 130", "materialized": { @@ -15331,6 +16288,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300 and c < 130", "filesort": { "sort_key": "t1.a, t1.b", @@ -15341,6 +16299,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a > 4" } @@ -15354,12 +16313,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "__5.a > 4 and __5.c < 130", "materialized": { @@ -15371,6 +16332,7 @@ EXPLAIN { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "c > 150 and c < 130", "filesort": { "sort_key": "t1.a, t1.b", @@ -15381,6 +16343,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a > 4" } @@ -15394,6 +16357,7 @@ EXPLAIN "query_block": { "select_id": 5, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c < 500 and c < 130", "filesort": { "sort_key": "t1.a, t1.b", @@ -15404,6 +16368,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 7 and t1.a > 4" } @@ -15468,12 +16433,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 4 and t2.a is not null" } @@ -15488,6 +16455,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c < 130", "materialized": { @@ -15499,6 +16467,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 300 and c < 130", "filesort": { "sort_key": "t1.a, t1.b", @@ -15509,6 +16478,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a > 4" } @@ -15522,12 +16492,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "__6.a > 4 and __6.c < 130", "materialized": { @@ -15539,6 +16511,7 @@ EXPLAIN { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "having_condition": "c > 150 and c < 130", "filesort": { "sort_key": "t1.a, t1.b", @@ -15549,6 +16522,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a > 4" } @@ -15562,6 +16536,7 @@ EXPLAIN "query_block": { "select_id": 5, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c < 500 and c < 130", "filesort": { "sort_key": "t1.a, t1.b", @@ -15572,6 +16547,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 7 and t1.a > 4" } @@ -15594,6 +16570,7 @@ EXPLAIN "query_block": { "select_id": 6, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c < 120 and c < 130", "filesort": { "sort_key": "t1.a, t1.b", @@ -15604,6 +16581,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 7 and t1.a > 4" } @@ -15656,12 +16634,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 4 and t2.a is not null" } @@ -15676,11 +16656,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.c < 150", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 150", "filesort": { "sort_key": "v1.a, v1.b", @@ -15691,6 +16673,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 7 and v1.a > 4", "materialized": { @@ -15702,6 +16685,7 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -15712,6 +16696,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a < 7 and t1.a > 4" } @@ -15725,6 +16710,7 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 120", "filesort": { "sort_key": "t1.a, t1.b", @@ -15735,6 +16721,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a < 7 and t1.a > 4" } @@ -15794,12 +16781,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 4 and t2.a is not null" } @@ -15814,11 +16803,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.c < 150", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c < 150", "filesort": { "sort_key": "v1.a, v1.b", @@ -15829,6 +16820,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 7 and v1.a > 4", "materialized": { @@ -15840,6 +16832,7 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "c < 300", "filesort": { "sort_key": "t1.a, t1.b", @@ -15850,6 +16843,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a < 7 and t1.a > 4" } @@ -15863,6 +16857,7 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c > 150", "filesort": { "sort_key": "t1.a, t1.b", @@ -15873,6 +16868,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a < 7 and t1.a > 4" } @@ -15928,12 +16924,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 4 and t2.a is not null" } @@ -15948,6 +16946,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b > 12 and v1.c < 450", "materialized": { @@ -15959,6 +16958,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 300 and t1.b > 12 and c < 450", "filesort": { "sort_key": "t1.a", @@ -15969,6 +16969,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a > 4" } @@ -15982,6 +16983,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c > 200 and t1.a > 4 and c < 450", "filesort": { "sort_key": "t1.b", @@ -15992,6 +16994,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b < 21 and t1.b > 12" } @@ -16040,12 +17043,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a < 2 and t2.a is not null" } @@ -16060,6 +17065,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b < 30 and v1.c > 450", "materialized": { @@ -16071,6 +17077,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 300 and t1.b < 30 and c > 450", "filesort": { "sort_key": "t1.a", @@ -16081,6 +17088,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 20 and t1.a < 2" } @@ -16094,6 +17102,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c > 150 and t1.a < 2 and c > 450", "filesort": { "sort_key": "t1.b", @@ -16104,6 +17113,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 7 and t1.b < 30" } @@ -16154,12 +17164,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t2.a < 2 or t2.a < 5) and t2.a is not null" } @@ -16174,6 +17186,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 450", "materialized": { @@ -16185,6 +17198,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 300 and c > 450", "filesort": { "sort_key": "t1.a", @@ -16195,6 +17209,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 20 and (t1.a < 2 or t1.a < 5)" } @@ -16208,6 +17223,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "having_condition": "c > 150 and (t1.a < 2 or t1.a < 5) and c > 450", "filesort": { "sort_key": "t1.b", @@ -16218,6 +17234,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 7" } @@ -16270,12 +17287,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a > 1 and t2.a is not null" } @@ -16290,6 +17309,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b > 12 and v1.c > 400", "materialized": { @@ -16301,6 +17321,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "c > 100 and t1.b > 12 and c > 400", "filesort": { "sort_key": "t1.a", @@ -16311,6 +17332,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 9 and t1.a > 1" } @@ -16324,6 +17346,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "having_condition": "c < 800 and t1.a > 1 and c > 400", "filesort": { "sort_key": "t1.b", @@ -16334,6 +17357,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 3 and t1.b > 12" } @@ -16347,6 +17371,7 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "c > 300 and c > 400", "filesort": { "sort_key": "t1.a, t1.b", @@ -16357,6 +17382,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 10 and t1.a > 1 and t1.b > 12" } @@ -16414,12 +17440,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b is not null" } @@ -16434,11 +17462,13 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 5", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -16449,6 +17479,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t3.a > 0 and t3.a < 5" } @@ -16493,12 +17524,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b is not null" } @@ -16513,6 +17546,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 4", "materialized": { @@ -16524,6 +17558,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -16534,6 +17569,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t3.a > 1 and t3.a < 4" } @@ -16545,6 +17581,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -16555,6 +17592,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t3.a > 2 and t3.a < 4" } @@ -16603,12 +17641,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b is not null" } @@ -16623,6 +17663,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 3", "materialized": { @@ -16634,6 +17675,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -16644,6 +17686,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t3.a > 1 and t3.a < 3" } @@ -16655,6 +17698,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "t3.a < 3", "filesort": { "sort_key": "t3.b", @@ -16665,6 +17709,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.b < 21" } @@ -16736,17 +17781,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -16763,6 +17811,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 20, + "cost": "COST_REPLACED", "filtered": 80, "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" } @@ -16851,12 +17900,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 32, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", "materialized": { @@ -16866,6 +17917,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -16882,6 +17934,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 20, + "cost": "COST_REPLACED", "filtered": 80, "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" } @@ -16895,6 +17948,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -16911,6 +17965,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 20, + "cost": "COST_REPLACED", "filtered": 80, "attached_condition": "t2.a > 2" } @@ -16959,12 +18014,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 8, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c in ('aa','bb','cc') and t1.a is not null and t1.c is not null" } @@ -16979,10 +18036,12 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t1.a", "test.t1.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -16998,6 +18057,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c in ('aa','bb','cc')" } @@ -17099,12 +18159,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 48, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", "materialized": { @@ -17114,6 +18176,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -17130,6 +18193,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 20, + "cost": "COST_REPLACED", "filtered": 80, "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" } @@ -17143,6 +18207,7 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "UNION", + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -17159,6 +18224,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 20, + "cost": "COST_REPLACED", "filtered": 80, "attached_condition": "t2.a > 2" } @@ -17172,6 +18238,7 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "UNION", + "cost": "COST_REPLACED", "having_condition": "t2.c in ('aa','bb','cc')", "filesort": { "sort_key": "t2.a", @@ -17183,6 +18250,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 20, + "cost": "COST_REPLACED", "filtered": 80, "attached_condition": "t2.a > 2" } @@ -17248,17 +18316,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -17275,6 +18346,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 20, + "cost": "COST_REPLACED", "filtered": 80, "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" } @@ -17336,17 +18408,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -17363,6 +18438,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 20, + "cost": "COST_REPLACED", "filtered": 80, "attached_condition": "t2.a > 2" } @@ -17424,17 +18500,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -17455,6 +18534,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 20, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c in ('aa','bb','cc')" } @@ -17539,6 +18619,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -17549,6 +18630,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.b < 3", "attached_condition": "t1.a is not null" @@ -17564,11 +18646,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 50, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t1.a is not null", "nested_loop": [ { @@ -17581,6 +18665,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -17660,6 +18745,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -17667,6 +18753,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx_b"], "rows": 12, + "cost": "COST_REPLACED", "filtered": 83.33333588, "attached_condition": "t1.b <= 5 and t1.a is not null" } @@ -17681,11 +18768,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 50, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t1.a is not null", "nested_loop": [ { @@ -17698,6 +18787,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -17774,6 +18864,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "nested_loop": [ { @@ -17781,6 +18872,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -17794,12 +18886,14 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 50, "attached_condition": "trigcond(trigcond(t1.a is not null))", "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t1.a is not null", "nested_loop": [ { @@ -17812,6 +18906,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -17877,6 +18972,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -17887,6 +18983,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t3.b > 15", "attached_condition": "t3.a is not null and t3.c is not null" @@ -17902,11 +18999,13 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t3.a is not null and t3.c is not null", "nested_loop": [ { @@ -17919,6 +19018,7 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -17966,6 +19066,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -17973,6 +19074,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx_b"], "rows": 12, + "cost": "COST_REPLACED", "filtered": 83.33333588, "attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null" } @@ -17987,11 +19089,13 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 50, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t3.a is not null and t3.c is not null", "nested_loop": [ { @@ -18004,6 +19108,7 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -18051,6 +19156,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -18061,6 +19167,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t3.b > 15", "attached_condition": "t3.a is not null and t3.c is not null" @@ -18076,11 +19183,13 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t3.a is not null and t3.c is not null", "nested_loop": [ { @@ -18093,6 +19202,7 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -18140,6 +19250,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -18147,6 +19258,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx_b"], "rows": 12, + "cost": "COST_REPLACED", "filtered": 83.33333588, "attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null" } @@ -18161,11 +19273,13 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 50, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t3.a is not null and t3.c is not null", "nested_loop": [ { @@ -18178,6 +19292,7 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -18236,6 +19351,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -18246,6 +19362,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["c", "b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t2.b between 80 and 85 and t2.c in ('y','z')", "attached_condition": "t2.a is not null" @@ -18261,6 +19378,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.c is not null" } @@ -18275,11 +19393,13 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t3.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t3.c is not null", "nested_loop": [ { @@ -18292,6 +19412,7 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t3.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -18396,12 +19517,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 90, + "cost": "COST_REPLACED", "filtered": 60, "attached_condition": "t2.b < 40 and t2.a is not null" } @@ -18416,6 +19539,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.c is not null" } @@ -18430,10 +19554,12 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t3.c"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t4.c", "temporary_table": { @@ -18444,6 +19570,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx_c"], "rows": 160, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -18508,6 +19635,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -18518,6 +19646,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["c", "b"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t2.b between 80 and 85 and t2.c in ('y','z')", "attached_condition": "t2.a is not null" @@ -18533,6 +19662,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.c is not null" } @@ -18547,11 +19677,13 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t3.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t3.c is not null", "window_functions_computation": { "sorts": [ @@ -18573,6 +19705,7 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t3.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -18919,12 +20052,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 90, + "cost": "COST_REPLACED", "filtered": 60, "attached_condition": "t2.b < 40 and t2.a is not null" } @@ -18939,6 +20074,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.c is not null" } @@ -18953,10 +20089,12 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t3.c"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -18973,6 +20111,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx_c"], "rows": 160, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -19036,6 +20175,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -19046,6 +20186,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t4.a < 2", "attached_condition": "t4.c is not null" @@ -19061,12 +20202,14 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t4.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 50, "first_match": "t4", "materialized": { "lateral": 1, "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "const_condition": "1", "outer_ref_condition": "t4.c is not null", "nested_loop": [ @@ -19080,6 +20223,7 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t4.c"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -19104,6 +20248,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -19113,6 +20258,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -19206,6 +20352,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -19213,6 +20360,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["PRIMARY"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f <> 5" } @@ -19227,11 +20375,13 @@ EXPLAIN "used_key_parts": ["pk2"], "ref": ["test.t1.pk1"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -19243,6 +20393,7 @@ EXPLAIN "used_key_parts": ["pk2"], "ref": ["test.t1.pk1"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "using_index": true } @@ -19649,6 +20800,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -19659,6 +20811,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -19675,6 +20828,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -19685,6 +20839,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -19758,12 +20913,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.`id` is not null and t3.`id` is not null" } @@ -19778,6 +20935,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.id"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -19802,6 +20960,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 1007, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -19820,10 +20979,12 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.id"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -19833,6 +20994,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "using_index_for_group_by": true } @@ -19866,12 +21028,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.`id` is not null and t3.`id` is not null" } @@ -19886,6 +21050,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.id"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -19910,6 +21075,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 1007, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -19928,11 +21094,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.id"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t1.a is not null", "nested_loop": [ { @@ -19945,6 +21113,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "cp2.a = t3.`id`", "using_index": true @@ -20078,6 +21247,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -20088,6 +21258,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["t1_id"], "rows": 47, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.t1_id between 200 and 100000 and t3.t1_id is not null", "using_index": true @@ -20103,6 +21274,7 @@ EXPLAIN "used_key_parts": ["id"], "ref": ["test.t3.t1_id"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "using_index": true } @@ -20117,11 +21289,13 @@ EXPLAIN "used_key_parts": ["t1_id"], "ref": ["test.t3.t1_id"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 50, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -20133,6 +21307,7 @@ EXPLAIN "used_key_parts": ["t1_id"], "ref": ["test.t1.id"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 34.55045319, "index_condition": "t2.t1_id between 200 and 100000 and t2.t1_id = t3.t1_id", "attached_condition": "t2.reporting_person = 1" @@ -20315,6 +21490,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -20330,6 +21506,7 @@ EXPLAIN "used_key_parts": ["to_ledger_id"], "ref": ["const"], "rows": 8, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -20343,11 +21520,13 @@ EXPLAIN "used_key_parts": ["ledger_id", "charge_id"], "ref": ["test.charges.from_ledger_id", "test.charges.id"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -20359,6 +21538,7 @@ EXPLAIN "used_key_parts": ["charge_id"], "ref": ["test.charges.id"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -20372,6 +21552,7 @@ EXPLAIN "used_key_parts": ["id"], "ref": ["test.transaction_items.transaction_id"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "transactions.ledger_id = charges.from_ledger_id" } @@ -20512,6 +21693,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -20523,6 +21705,7 @@ EXPLAIN "used_key_parts": ["to_ledger_id"], "ref": ["const"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -20536,11 +21719,13 @@ EXPLAIN "used_key_parts": ["ledger_id", "charge_id"], "ref": ["test.charges.from_ledger_id", "test.charges.id"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "lateral": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -20552,6 +21737,7 @@ EXPLAIN "used_key_parts": ["charge_id"], "ref": ["test.charges.id"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -20565,6 +21751,7 @@ EXPLAIN "used_key_parts": ["id"], "ref": ["test.transaction_items.transaction_id"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "transactions.ledger_id = charges.from_ledger_id" } diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index 55ccd9b4839..2f2e72fb09f 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -112,6 +112,7 @@ let $query= select * from v1,t2 where (v1.max_c>214) and (t2.a>v1.a); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -122,6 +123,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # extracted or formula : pushing into HAVING @@ -131,6 +133,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -140,6 +143,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # conjunctive subformula : pushing into WHERE @@ -147,12 +151,14 @@ let $query= select * from v1,t2 where (v1.a>6) and (t2.b>v1.b); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= select * from v2,t2 where (v2.b>25) and (t2.a400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a150) and (v1.max_c=t2.c); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # extracted and formula : pushing into WHERE @@ -296,6 +319,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -303,6 +327,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -311,6 +336,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # extracted and formula : pushing into WHERE using equalities @@ -321,6 +347,7 @@ select * from v_decimal as v,t2_decimal as t where eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # extracted or formula : pushing into HAVING using equalities @@ -330,6 +357,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # conjunctive subformulas : pushing into WHERE and HAVING using equalities @@ -339,6 +367,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # conjunctive subformulas : pushing into WHERE and HAVING @@ -351,6 +380,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # conjunctive subformulas : pushing into WHERE and HAVING @@ -360,6 +390,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # conjunctive subformula : pushing into WHERE @@ -371,6 +402,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # conjunctive subformula : pushing into WHERE @@ -381,6 +413,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # extracted or formula : pushing into WHERE @@ -392,6 +425,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -402,6 +436,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # nothing to push @@ -410,12 +445,14 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.b=t2.b); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -424,6 +461,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -431,6 +469,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -439,6 +478,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using several derived tables : nothing to push @@ -447,6 +487,7 @@ let $query= select * from v1,v2,t2 where eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -455,6 +496,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -463,6 +505,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using several derived tables : pushing in all tables @@ -475,6 +518,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using several derived tables : pushing only in one table @@ -486,6 +530,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using several derived tables : pushing only in one table @@ -497,6 +542,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # extracted or formula : pushing into WHERE @@ -508,6 +554,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using several derived tables : pushing in all tables @@ -521,6 +568,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using several derived tables : pushing in all tables @@ -535,6 +583,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using several derived tables : pushing in all tables @@ -553,6 +602,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # extracted or formula : pushing into HAVING @@ -565,6 +615,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # extracted and formula : pushing into WHERE @@ -577,6 +628,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using query with union @@ -589,6 +641,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using query with union @@ -602,6 +655,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using query with union @@ -616,6 +670,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using query with union @@ -634,6 +689,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union @@ -642,6 +698,7 @@ let $query= select * from v_union,t2 where (v_union.a<3) and (v_union.c>100); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union @@ -653,6 +710,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union @@ -665,6 +723,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= @@ -673,6 +732,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union @@ -686,6 +746,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union @@ -698,6 +759,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union of selects without aggregation @@ -707,6 +769,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union of selects without aggregation @@ -716,6 +779,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union of selects without aggregation @@ -726,6 +790,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union of @@ -736,6 +801,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using derived table with union of @@ -750,6 +816,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded derived table : pushing the same conditions @@ -762,6 +829,7 @@ select * from v4,v1 where eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded view : nothing to push @@ -773,6 +841,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded view : pushing different conditions @@ -786,6 +855,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded view : pushing different conditions @@ -798,6 +868,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded view : pushing different conditions @@ -810,6 +881,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded view : pushing different conditions @@ -823,6 +895,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded view : pushing the same conditions @@ -836,6 +909,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded view : pushing the same conditions @@ -849,6 +923,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded view : pushing the same conditions @@ -863,6 +938,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using embedded view : pushing the same conditions @@ -875,6 +951,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1,v2,v3,v4; @@ -982,6 +1059,7 @@ SELECT * FROM t1 WHERE a IN ( ) ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN ( SELECT b FROM v2 WHERE b < a OR b IN ( @@ -1004,6 +1082,7 @@ SELECT * FROM t1 WHERE a IN ( eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; DROP VIEW v2,v3,v4; @@ -1026,6 +1105,7 @@ SELECT * FROM ( SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM v2 WHERE b = a ) ) AS sq; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM ( SELECT * FROM t1 @@ -1051,6 +1131,7 @@ SELECT * FROM t1 LEFT JOIN t2 ON a = b WHERE b IS NULL; SELECT * FROM t1 LEFT JOIN v2 ON a = b WHERE b IS NULL; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN v2 ON a = b WHERE b IS NULL; @@ -1065,6 +1146,7 @@ CREATE TABLE t1 (i INT); CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; INSERT INTO t1 VALUES (1),(2); --enable_prepare_warnings +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 ); --disable_prepare_warnings @@ -1092,12 +1174,14 @@ CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; SELECT * FROM v1 AS sq WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM v1 AS sq WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100; SELECT * FROM ( SELECT * FROM t1 ) AS sq WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM ( SELECT * FROM t1 ) AS sq WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100; @@ -1117,6 +1201,7 @@ INSERT INTO t2 VALUES (50); CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; SELECT ( SELECT COUNT(*) FROM v1 WHERE a = t2.b ) AS f FROM t2 GROUP BY f; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT ( SELECT COUNT(*) FROM v1 WHERE a = t2.b ) AS f FROM t2 GROUP BY f; @@ -1124,6 +1209,7 @@ CREATE TABLE t3 (a INT, b INT) ENGINE=MYISAM; INSERT INTO t3 VALUES (1,10),(3,11),(2,10),(2,20),(3,21); CREATE VIEW v2 AS SELECT a, sum(b) AS s FROM t3 GROUP BY a ; SELECT ( SELECT COUNT(*) FROM v2 WHERE s < t2.b ) AS f FROM t2 GROUP BY f; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT ( SELECT COUNT(*) FROM v2 WHERE s < t2.b ) AS f FROM t2 GROUP BY f; @@ -1145,6 +1231,7 @@ INSERT INTO t2 VALUES (5),(6); SELECT a, GROUP_CONCAT(b) FROM v1 WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT a, GROUP_CONCAT(b) FROM v1 WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a; @@ -1163,6 +1250,7 @@ INSERT INTO t VALUES (1,1),(3,2); SELECT * FROM v AS v1, v AS v2 WHERE v2.pk > v1.f AND v1.f IN ( SELECT COUNT(pk) FROM t ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM v AS v1, v AS v2 WHERE v2.pk > v1.f AND v1.f IN ( SELECT COUNT(pk) FROM t ); @@ -1182,6 +1270,7 @@ INSERT INTO t2 VALUES (3),(4); SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); @@ -1200,6 +1289,7 @@ INSERT INTO t2 VALUES (3.2),(2.71); SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); @@ -1214,6 +1304,7 @@ INSERT INTO t2 VALUES (3.21),(4.55); SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); @@ -1228,6 +1319,7 @@ INSERT INTO t2 VALUES ('bbb'),('aa'); SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); @@ -1244,6 +1336,7 @@ INSERT INTO t2 VALUES SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); @@ -1258,6 +1351,7 @@ INSERT INTO t2 VALUES ('2007-05-28'), ('2010-08-25'); SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); @@ -1272,6 +1366,7 @@ INSERT INTO t2 VALUES ('10:00:02'), ('11:00:10'); SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE i IN ( SELECT MIN(j) FROM t2 ); @@ -1288,6 +1383,7 @@ CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; INSERT INTO t1 VALUES (2), (1); SELECT * FROM v1 WHERE NULLIF(1, i); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE NULLIF(1, i); @@ -1306,6 +1402,7 @@ CREATE TABLE t2 (c VARCHAR(3)); INSERT INTO t2 VALUES ('foo'),('xyz'); SELECT * FROM v1 WHERE v1.c IN ( SELECT MIN(c) FROM t2 WHERE 0 ); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE v1.c IN ( SELECT MIN(c) FROM t2 WHERE 0 ); @@ -1340,7 +1437,9 @@ PREPARE stmt1 FROM PREPARE stmt2 FROM "EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE 1 IN (SELECT a FROM t2) OR c = 'foo'"; +--source include/explain-no-costs.inc EXECUTE stmt1; +--source include/explain-no-costs.inc EXECUTE stmt2; INSERT INTO t2 SELECT a+1 FROM t2; INSERT INTO t2 SELECT a+1 FROM t2; @@ -1348,7 +1447,9 @@ INSERT INTO t2 SELECT a+1 FROM t2; INSERT INTO t2 SELECT a+1 FROM t2; INSERT INTO t2 SELECT a+1 FROM t2; INSERT INTO t2 SELECT a+1 FROM t2; +--source include/explain-no-costs.inc EXECUTE stmt1; +--source include/explain-no-costs.inc EXECUTE stmt2; DEALLOCATE PREPARE stmt1; # the result here will change after the merge with the fix for mdev-11859 @@ -1485,6 +1586,7 @@ from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t where b > 2; eval $q1; +--source include/explain-no-costs.inc eval explain format=json $q1; let $q2= @@ -1493,6 +1595,7 @@ from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t where a > 2; eval $q2; +--source include/explain-no-costs.inc eval explain format=json $q2; let $q3= @@ -1501,6 +1604,7 @@ from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t where a > 2; eval $q3; +--source include/explain-no-costs.inc eval explain format=json $q3; let $q4= @@ -1509,6 +1613,7 @@ from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t where a > 2; eval $q4; +--source include/explain-no-costs.inc eval explain format=json $q4; drop view v1,v2,v3; @@ -1526,6 +1631,7 @@ let $q= SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0; eval $q; +--source include/explain-no-costs.inc eval explain format=json $q; DROP VIEW v1; @@ -1548,6 +1654,7 @@ SELECT * FROM t1, ( SELECT * FROM v2 ) AS sq WHERE i1 = 1 AND ( i1 = i2 OR i1 = 2 ); eval $q; +--source include/explain-no-costs.inc eval explain format=json $q; DROP VIEW v2; @@ -1566,6 +1673,7 @@ from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t where t.f = 'a' or t.f = 'b'; eval $q; +--source include/explain-no-costs.inc eval explain format=json $q; drop table t1; @@ -1589,6 +1697,7 @@ SELECT * FROM t1 WHERE (vc.ct>0); eval $q; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q; DROP TABLE t1,t2; @@ -1619,6 +1728,7 @@ WHERE (v1.a=1) AND (v1.b=v1.a) AND (v1.a=t2.x) AND (v1.max_c>30); eval $query; eval EXPLAIN $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; let $query= @@ -1634,6 +1744,7 @@ WHERE (v1.a=1) AND (v1.b=v1.a) AND (v1.b=v1.d) AND (v1.a=t2.x) AND (v1.max_c>30); eval $query; eval EXPLAIN $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; DROP TABLE t1,t2; @@ -1676,6 +1787,7 @@ WHERE (t1.a,t1.b) IN ; eval $query; eval EXPLAIN $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; let $query= @@ -1694,6 +1806,7 @@ WHERE (t1.a,t1.b) IN ; eval $query; eval EXPLAIN $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; let $query= @@ -1712,6 +1825,7 @@ WHERE (t1.a,t1.b) IN ; eval $query; eval EXPLAIN $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; let $query= @@ -1730,6 +1844,7 @@ WHERE (t1.a,t1.b) IN ; eval $query; eval EXPLAIN $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; DROP TABLE t1,t2; @@ -1768,6 +1883,7 @@ SELECT * FROM ) dt WHERE (dt.a=2); eval $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; let $query= @@ -1780,6 +1896,7 @@ SELECT * FROM ) dt WHERE (dt.a>1); eval $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; let $query= @@ -1791,6 +1908,7 @@ SELECT * FROM ) dt WHERE (dt.a='ab'); eval $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; let $query= @@ -1802,6 +1920,7 @@ SELECT * FROM ) dt WHERE (dt.a=1); eval $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; DROP TABLE t1; @@ -1830,6 +1949,7 @@ JOIN ) AS dt2 ON dt1.a = dt2.a; eval $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; let $query= @@ -1841,6 +1961,7 @@ SELECT * FROM ) AS dt, t1 WHERE dt.a=t1.a AND dt.a IN (1,t1.a); eval $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; DROP TABLE t1; @@ -1943,6 +2064,7 @@ let $q1= INSERT INTO t3 SELECT * FROM (SELECT a, count(*) as c FROM t1 GROUP BY a) t WHERE a<=2; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q1; eval $q1; @@ -1952,6 +2074,7 @@ let $q2= UPDATE t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t SET t2.a=t.c+10 WHERE t2.a= t.c and t.a>=3; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q2; eval $q2; @@ -1961,6 +2084,7 @@ let $q3= DELETE t2 FROM t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t WHERE t2.a= t.c+9 and t.a=2; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q3; eval $q3; @@ -1986,6 +2110,7 @@ FROM ) AS tab1 WHERE (tab1.max_a=1); EVAL $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; LET $query= @@ -1998,6 +2123,7 @@ FROM ) AS tab1 WHERE (tab1.max_a=1); EVAL $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; LET $query= @@ -2010,6 +2136,7 @@ FROM ) AS tab1 WHERE (tab1.max_a=1); EVAL $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; LET $query= @@ -2022,6 +2149,7 @@ FROM ) AS tab1 WHERE (tab1.max_a=1); EVAL $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; DROP TABLE t1; @@ -2061,6 +2189,7 @@ SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL; eval $q1; eval EXPLAIN $q1; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q1; SELECT * FROM t1; @@ -2073,6 +2202,7 @@ SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ON v1.f=t1.f) AS t WHERE f IS NOT NULL; eval $q2; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q2; SELECT * FROM t1; @@ -2093,6 +2223,7 @@ CREATE VIEW v1 AS SELECT f2 FROM ( SELECT f2 FROM t1 ) AS t; let $q1 = UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2; eval $q1; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q1; SELECT * FROM t1; @@ -2101,6 +2232,7 @@ CREATE VIEW v2 AS SELECT f2 FROM ( SELECT DISTINCT f2 FROM t1 ) AS t; let $q2 = SELECT * FROM v2, t1 WHERE v2.f2 < 2 AND t1.f2 = v2.f2; eval $q2; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q2; DROP VIEW v1,v2; @@ -2136,6 +2268,7 @@ CREATE TABLE t1 (a INT, b INT); CREATE VIEW v1 AS SELECT a, MAX(b) FROM t1 GROUP BY a; SELECT * FROM (SELECT 1 FROM v1 UNION (SELECT 1 FROM v1 WHERE @a := uuid())) dt; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM (SELECT 1 FROM v1 UNION (SELECT 1 FROM v1 WHERE @a := uuid())) dt; @@ -2280,6 +2413,7 @@ select col2, col1 from v2; explain select * from v3 where col1=123; --echo # This must use ref accesses for reading table t1, not full scans: +--source include/explain-no-costs.inc explain format=json select * from v3 where col1=123 and col2=321; @@ -2303,6 +2437,7 @@ select a, f1(a), sum(b) from t1 group by a, f1(a); --echo # "a > 1" will be pushed all the way to the table scan on t1 --echo # "a2>123" will be pushed into HAVING (as it refers to an SP call which --echo # prevents pushing it to the WHERE) +--source include/explain-no-costs.inc explain format=json select * from v2 where (s+1) > 10 AND a > 1 and a2>123; @@ -2315,6 +2450,7 @@ insert into t4 select a,a,a from t1; --echo # The subquery must be materialized and must have --echo # "attached_condition": "t1.a + 1 > 10", --echo # "having_condition": "`f1(a)` > 1 and `sum(b)` > 123", +--source include/explain-no-costs.inc explain format=json select * from t4 @@ -2359,6 +2495,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using intersect in view definition @@ -2368,6 +2505,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a=8); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using intersect in view definition @@ -2376,6 +2514,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (t2.a=8); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using intersect in view definition @@ -2384,6 +2523,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.c>200); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using intersect in view definition @@ -2393,6 +2533,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5) and (v1.c>110); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using intersect in view definition @@ -2402,6 +2543,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using intersect in view definition @@ -2412,6 +2554,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using intersect in view definition @@ -2425,6 +2568,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using intersect in view definition @@ -2456,6 +2600,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2473,6 +2618,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using except in view definition @@ -2482,6 +2628,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a=6); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using except in view definition @@ -2490,6 +2637,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (t2.a=6); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using except in view definition @@ -2498,6 +2646,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.c>500); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using except in view definition @@ -2507,6 +2656,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5) and (v1.c>500); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using except in view definition @@ -2516,6 +2666,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using except in view definition @@ -2526,6 +2677,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using except in view definition @@ -2540,6 +2692,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --echo # using except in view definition @@ -2571,6 +2724,7 @@ let $query= eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2591,6 +2745,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>5) and (v1.c>200); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2611,6 +2766,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<200); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2631,6 +2787,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>5) and (v1.c>200); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2651,6 +2808,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<200); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2671,6 +2829,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<150); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2691,6 +2850,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<130); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2714,6 +2874,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<130); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2736,6 +2897,7 @@ let $query= select * from v2,t2 where (v2.a=t2.a) and (v2.a>4) and (v2.c<150); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1,v2; @@ -2758,6 +2920,7 @@ let $query= select * from v2,t2 where (v2.a=t2.a) and (v2.a>4) and (v2.c<150); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1,v2; @@ -2776,6 +2939,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.b>12) and eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2794,6 +2958,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<2) and (v1.b<30) and eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2814,6 +2979,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and ((v1.a<2) or (v1.a<5)) and eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2835,6 +3001,7 @@ let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>1) and (v1.b > 12) a eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2858,6 +3025,7 @@ let $query= select * from v1,t2 where (v1.b=t2.b) and (v1.a<5); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2876,6 +3044,7 @@ let $query= select * from v1,t2 where (v1.b=t2.b) and (v1.a<4); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2894,6 +3063,7 @@ let $query= select * from v1,t2 where (v1.b=t2.b) and (v1.a<3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; drop view v1; @@ -2930,6 +3100,7 @@ eval $no_pushdown $q1; --sorted_result eval $q1; eval explain $q1; +--source include/explain-no-costs.inc eval explain format=json $q1; let $q2= @@ -2946,6 +3117,7 @@ eval $no_pushdown $q2; --sorted_result eval $q2; eval explain $q2; +--source include/explain-no-costs.inc eval explain format=json $q2; let $q3= @@ -2956,6 +3128,7 @@ from (select a, c, sum(b) over (partition by a,c) as s from t2) as t, t1 eval $no_pushdown $q3; eval $q3; eval explain $q3; +--source include/explain-no-costs.inc eval explain format=json $q3; let $q4= @@ -2974,6 +3147,7 @@ eval $no_pushdown $q4; --sorted_result eval $q4; eval explain $q4; +--source include/explain-no-costs.inc eval explain format=json $q4; let $q5= @@ -2988,6 +3162,7 @@ eval $no_pushdown $q5; --sorted_result eval $q5; eval explain $q5; +--source include/explain-no-costs.inc eval explain format=json $q5; let $q6= @@ -3002,6 +3177,7 @@ eval $no_pushdown $q6; --sorted_result eval $q6; eval explain $q6; +--source include/explain-no-costs.inc eval explain format=json $q6; let $q7= @@ -3016,6 +3192,7 @@ eval $no_pushdown $q7; --sorted_result eval $q7; eval explain $q7; +--source include/explain-no-costs.inc eval explain format=json $q7; drop table t1,t2; @@ -3063,6 +3240,7 @@ where t1.b < 3; eval $no_splitting $q1; eval $q1; eval explain extended $q1; +--source include/explain-no-costs.inc eval explain format=json $q1; eval prepare stmt from "$q1"; execute stmt; @@ -3079,6 +3257,7 @@ where t1.b <= 5; eval $no_splitting $q10; eval $q10; eval explain extended $q10; +--source include/explain-no-costs.inc eval explain format=json $q10; eval prepare stmt from "$q10"; execute stmt; @@ -3096,6 +3275,7 @@ from t1 left join eval $no_splitting $q2; eval $q2; eval explain extended $q2; +--source include/explain-no-costs.inc eval explain format=json $q2; create table t3 (a int, b int, c char(127), index idx_b(b)) engine=myisam; @@ -3125,6 +3305,7 @@ where t3.b > 15; eval $no_splitting $q3; eval $q3; eval explain extended $q3; +--source include/explain-no-costs.inc eval explain format=json $q3; let $q30= @@ -3137,6 +3318,7 @@ where t3.b <= 15; eval $no_splitting $q30; eval $q30; eval explain extended $q30; +--source include/explain-no-costs.inc eval explain format=json $q30; let $q4= @@ -3149,6 +3331,7 @@ where t3.b > 15; eval $no_splitting $q4; eval $q4; eval explain extended $q4; +--source include/explain-no-costs.inc eval explain format=json $q4; let $q40= @@ -3161,6 +3344,7 @@ where t3.b <= 15; eval $no_splitting $q40; eval $q40; eval explain extended $q40; +--source include/explain-no-costs.inc eval explain format=json $q40; drop index idx_a on t2; @@ -3184,6 +3368,7 @@ eval $no_splitting $q5; --sorted_result eval $q5; eval explain extended $q5; +--source include/explain-no-costs.inc eval explain format=json $q5; let $q50= @@ -3194,6 +3379,7 @@ where t2.b < 40 and t2.a=t3.a and t3.c=t.c; eval $no_splitting $q50; eval $q50; eval explain extended $q50; +--source include/explain-no-costs.inc eval explain format=json $q50; let $q6= @@ -3206,6 +3392,7 @@ eval $no_splitting $q6; --sorted_result eval $q6; eval explain extended $q6; +--source include/explain-no-costs.inc eval explain format=json $q6; let $q60= @@ -3218,6 +3405,7 @@ eval $no_splitting $q60; --sorted_result eval $q60; eval explain extended $q60; +--source include/explain-no-costs.inc eval explain format=json $q60; drop table t1,t2,t3,t4; @@ -3254,6 +3442,7 @@ SELECT * FROM t4 WHERE c IN ( SELECT c FROM v1 ) and a < 2; eval $no_splitting $q1; eval $q1; eval explain extended $q1; +--source include/explain-no-costs.inc eval explain format=json $q1; DROP VIEW v1; @@ -3333,6 +3522,7 @@ SELECT * FROM t1 INNER JOIN v2 ON pk1 = pk2 WHERE f <> 5; eval $q; eval EXPLAIN EXTENDED $q; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q; DROP VIEW v2; @@ -3616,11 +3806,13 @@ select * from t1, (select a from t1 cp2 group by a) dt, t3 set optimizer_switch="split_materialized=off"; eval $q; eval explain $q; +--source include/explain-no-costs.inc eval explain format=json $q; set optimizer_switch="split_materialized=default"; eval $q; eval explain $q; +--source include/explain-no-costs.inc eval explain format=json $q; eval prepare stmt from "$q"; @@ -3723,6 +3915,7 @@ set optimizer_switch='split_materialized=on'; eval $q; eval EXPLAIN $q; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q; set optimizer_switch='split_materialized=off'; @@ -3831,6 +4024,7 @@ WHERE charges.to_ledger_id = 2; set optimizer_switch='split_materialized=on'; eval $q; eval EXPLAIN $q; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q; set optimizer_switch='split_materialized=off'; @@ -3863,6 +4057,7 @@ WHERE charges.to_ledger_id = 2; set optimizer_switch='split_materialized=on'; eval $q1; eval EXPLAIN $q1; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q1; set optimizer_switch='split_materialized=off'; diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index dd74d2953b0..3329fb7552d 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -381,12 +381,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.f2 in (2,3) and t2.f2 is not null" } @@ -401,10 +403,12 @@ EXPLAIN "used_key_parts": ["f1"], "ref": ["test.t2.f2"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.f1", "temporary_table": { @@ -414,6 +418,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f1 in (2,3)" } @@ -485,16 +490,19 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "tt.f1", "temporary_table": { @@ -504,11 +512,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tt.f1 > 2", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.f1", "temporary_table": { @@ -518,6 +528,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f1 < 7 and t1.f1 > 2" } @@ -566,17 +577,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tt.f1 > 2 and tt.f1 > 2 and tt.f1 is not null", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.f1", "temporary_table": { @@ -586,6 +600,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f1 < 7 and t1.f1 > 2 and t1.f1 > 2" } @@ -607,10 +622,12 @@ EXPLAIN "used_key_parts": ["f1"], "ref": ["tt.f1"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 5, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.f1", "temporary_table": { @@ -620,6 +637,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f1 < 7 and t1.f1 > 2 and t1.f1 > 2" } @@ -707,17 +725,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "x.f1 is not null", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "tt.f1", "temporary_table": { @@ -727,11 +748,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tt.f1 > 2", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.f1", "temporary_table": { @@ -741,6 +764,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f1 < 7 and t1.f1 > 2" } @@ -769,10 +793,12 @@ EXPLAIN "used_key_parts": ["f1"], "ref": ["x.f1"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 4, + "cost": "COST_REPLACED", "filesort": { "sort_key": "tt.f1", "temporary_table": { @@ -782,11 +808,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tt.f1 > 2", "materialized": { "query_block": { "select_id": 5, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.f1", "temporary_table": { @@ -796,6 +824,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f1 < 7 and t1.f1 > 2" } @@ -853,17 +882,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.f1 < 7", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.f1", "temporary_table": { @@ -873,6 +905,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f1 < 7" } @@ -939,12 +972,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.f2 < 7 and t2.f2 in (2,3) and t2.f2 is not null" } @@ -959,10 +994,12 @@ EXPLAIN "used_key_parts": ["f1"], "ref": ["test.t2.f2"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 5, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.f1", "temporary_table": { @@ -972,6 +1009,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.f1 < 7 and t1.f1 in (2,3)" } diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index c511b8febc9..13444676659 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -118,6 +118,7 @@ select * from t1 join v2 on f1=f2; show status like 'Handler_read%'; explain extended select * from v1 join v4 on f1=f2; +--source include/explain-no-costs.inc explain format=json select * from v1 join v4 on f1=f2; select * from v1 join v4 on f1=f2; @@ -142,6 +143,7 @@ select * from (select * from --echo materialized derived in materialized derived explain extended select * from (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) zz; +--source include/explain-no-costs.inc explain format=json select * from (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) zz; select * from (select * from @@ -153,6 +155,7 @@ explain extended select * from join (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) z on x.f1 = z.f1; +--source include/explain-no-costs.inc explain format=json select * from (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) x join @@ -194,6 +197,7 @@ join (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) z on x.f1 = z.f1; +--source include/explain-no-costs.inc explain format=json select * from (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) x @@ -218,6 +222,7 @@ select * from (select * from v4 group by 1) tt; --echo materialized view in merged derived explain extended select * from ( select * from v1 where f1 < 7) tt; +--source include/explain-no-costs.inc explain format=json select * from ( select * from v1 where f1 < 7) tt; select * from ( select * from v1 where f1 < 7) tt; @@ -234,6 +239,7 @@ select * from (select * from v7 group by 1) tt; --echo join of above two explain extended select * from v6 join v7 on f2=f1; +--source include/explain-no-costs.inc explain format=json select * from v6 join v7 on f2=f1; select * from v6 join v7 on f2=f1; diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result index 4d23ca772b3..416c7eab8d4 100644 --- a/mysql-test/main/except.result +++ b/mysql-test/main/except.result @@ -37,12 +37,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "REPLACED", "filtered": 100 } } @@ -53,12 +55,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "EXCEPT", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "REPLACED", "filtered": 100 } } @@ -85,6 +89,7 @@ ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -95,6 +100,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -108,6 +114,7 @@ ANALYZE "query_block": { "select_id": 2, "operation": "EXCEPT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -118,6 +125,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -139,6 +147,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -149,6 +158,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -164,6 +174,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -174,6 +185,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -187,6 +199,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -197,6 +210,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -281,12 +295,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "REPLACED", "filtered": 100 } }, @@ -296,6 +312,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 2, + "cost": "REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -310,12 +327,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "EXCEPT", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "REPLACED", "filtered": 100 } }, @@ -325,6 +344,7 @@ EXPLAIN "table_name": "t4", "access_type": "ALL", "rows": 2, + "cost": "REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -355,6 +375,7 @@ ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -365,6 +386,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -379,6 +401,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -398,6 +421,7 @@ ANALYZE "query_block": { "select_id": 2, "operation": "EXCEPT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -408,6 +432,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -422,6 +447,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -450,6 +476,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -460,6 +487,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -475,6 +503,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -485,6 +514,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -499,6 +529,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -518,6 +549,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -528,6 +560,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -542,6 +575,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/except.test b/mysql-test/main/except.test index 090826ce94d..d253b288d3b 100644 --- a/mysql-test/main/except.test +++ b/mysql-test/main/except.test @@ -11,6 +11,7 @@ insert into t2 values (2,2),(3,3); EXPLAIN (select a,b from t1) except (select c,d from t2); EXPLAIN extended (select a,b from t1) except (select c,d from t2); EXPLAIN extended select * from ((select a,b from t1) except (select c,d from t2)) a; +--source include/analyze-format.inc EXPLAIN format=json (select a,b from t1) except (select c,d from t2); --source include/analyze-format.inc @@ -43,6 +44,7 @@ insert into t4 values (4,4),(7,7); EXPLAIN (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4); EXPLAIN (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4); EXPLAIN extended select * from ((select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4)) a; +--source include/analyze-format.inc EXPLAIN format=json (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4); --source include/analyze-format.inc diff --git a/mysql-test/main/except_all.result b/mysql-test/main/except_all.result index e62062d0427..522ed7cedfc 100644 --- a/mysql-test/main/except_all.result +++ b/mysql-test/main/except_all.result @@ -65,12 +65,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -81,12 +83,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "EXCEPT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -120,6 +124,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -130,6 +135,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -145,6 +151,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -155,6 +162,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 7, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -168,6 +176,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -178,6 +187,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 7, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -204,6 +214,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -214,6 +225,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -229,6 +241,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -239,6 +252,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 7, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -252,6 +266,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -262,6 +277,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 7, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -387,12 +403,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -403,12 +421,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -418,6 +438,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -432,12 +453,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -447,6 +470,7 @@ EXPLAIN "table_name": "t4", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -482,6 +506,7 @@ ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -492,6 +517,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -506,6 +532,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -525,6 +552,7 @@ ANALYZE "query_block": { "select_id": 2, "operation": "EXCEPT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -535,6 +563,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -549,6 +578,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -576,6 +606,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -586,6 +617,7 @@ ANALYZE "r_loops": 1, "rows": 9, "r_rows": 7, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -601,6 +633,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -611,6 +644,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -625,6 +659,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -644,6 +679,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "EXCEPT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -654,6 +690,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -668,6 +705,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/except_all.test b/mysql-test/main/except_all.test index f873b220126..9f788f52dea 100644 --- a/mysql-test/main/except_all.test +++ b/mysql-test/main/except_all.test @@ -16,6 +16,7 @@ select * from t1 except all select * from t1 union all select * from t1 union al select * from (select * from t1 except all select * from t2) q1 except all select * from (select * from t1 except all select * from t2) q2; EXPLAIN select * from t1 except all select * from t2; +--source include/explain-no-costs.inc EXPLAIN format=json select * from t1 except all select * from t2; EXPLAIN extended (select * from t1) except all (select * from t2); EXPLAIN extended select * from ((select * from t1) except all (select * from t2)) a; @@ -53,6 +54,7 @@ select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4 EXPLAIN (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); EXPLAIN select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; EXPLAIN extended select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +--source include/explain-no-costs.inc EXPLAIN format=json select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; --source include/analyze-format.inc @@ -96,4 +98,4 @@ INSERT INTO t VALUES (1),(2); SELECT * FROM t WHERE i != ANY ( SELECT 3 EXCEPT ALL SELECT 3 ); -drop table t; \ No newline at end of file +drop table t; diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index d2a8f38c33e..e2ebe9fbc9b 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -6,12 +6,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -33,12 +35,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t0.a < 3" } @@ -59,12 +63,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t0.a is not null" } @@ -79,6 +85,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t0.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -93,6 +100,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -103,6 +111,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a1"], "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t2.a1 < 5" } @@ -115,6 +124,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -139,6 +149,7 @@ EXPLAIN ] }, "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a1 = 1 or t2.b1 = 2" } @@ -151,6 +162,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -175,6 +187,7 @@ EXPLAIN ] }, "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a1 = 1 or t2.b1 = 2 and t2.b2 = 3" } @@ -188,6 +201,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -212,6 +226,7 @@ EXPLAIN ] }, "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a1 = 1 and t2.a2 = 1 or t2.b1 = 2 and t2.b2 = 1" } @@ -225,12 +240,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t0.a is not null" } @@ -245,6 +262,7 @@ EXPLAIN "used_key_parts": ["b1", "b2"], "ref": ["test.t0.a", "const"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -266,12 +284,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "A", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -282,12 +302,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "B", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -307,12 +329,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "A", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -323,12 +347,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "B", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -349,12 +375,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -365,12 +393,14 @@ EXPLAIN "state": "uninitialized", "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t0.a" } @@ -389,12 +419,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t0.a > (subquery#2) or t0.a < 3" } @@ -406,12 +438,14 @@ EXPLAIN "state": "uninitialized", "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t0.a" } @@ -435,12 +469,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "tbl1", "access_type": "ALL", "rows": 100, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tbl1.b < 3" } @@ -451,6 +487,7 @@ EXPLAIN "table_name": "tbl2", "access_type": "ALL", "rows": 100, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tbl2.b < 5" }, @@ -538,12 +575,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -566,17 +605,20 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tbl.cnt > 0", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "cnt > 0", "filesort": { "sort_key": "t1.a", @@ -587,6 +629,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -607,12 +650,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "tbl2", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tbl2.a is not null" } @@ -627,11 +672,13 @@ EXPLAIN "used_key_parts": ["cnt"], "ref": ["test.tbl2.a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tbl1.cnt = tbl2.a", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -641,6 +688,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -663,12 +711,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a is not null" } @@ -683,11 +733,13 @@ EXPLAIN "used_key_parts": ["max(a)"], "ref": ["test.t1.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -695,6 +747,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -718,12 +771,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -752,6 +807,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["seq"], "rows": 100, + "cost": "COST_REPLACED", "filtered": 100, "using_index": true } @@ -767,6 +823,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -791,12 +848,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -806,6 +865,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "first_match": "t2" }, @@ -834,12 +894,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -851,6 +913,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 10 }, "buffer_type": "flat", @@ -878,6 +941,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -888,6 +952,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a < 3", "mrr_type": "Rowid-ordered scan" @@ -904,12 +969,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "tbl1", "access_type": "ALL", "rows": 100, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -921,6 +988,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["a"], "rows": 100, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -942,6 +1010,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -951,6 +1020,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "!(outer_t1.a,(subquery#2))", "using_index": true @@ -961,6 +1031,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "trigcond(t1.a is null)", "nested_loop": [ { @@ -974,6 +1045,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["func"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "trigcond((outer_t1.a) = t1.a or t1.a is null)", "using_index": true @@ -986,6 +1058,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -1017,6 +1090,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "((20000,(subquery#2) >= 20000))", "nested_loop": [ { @@ -1024,6 +1098,7 @@ EXPLAIN "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1032,12 +1107,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "tbl1", "access_type": "ALL", "rows": 100, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1047,6 +1124,7 @@ EXPLAIN "table_name": "tbl2", "access_type": "ALL", "rows": 100, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -1075,12 +1153,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "!(t1.a,(subquery#2))" } @@ -1090,6 +1170,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "trigcond(t2.b is null)", "nested_loop": [ { @@ -1097,6 +1178,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "trigcond((t1.a) = t2.b or t2.b is null)" } @@ -1135,6 +1217,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1144,6 +1227,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["a", "b"], "rows": 101, + "cost": "COST_REPLACED", "filtered": 100, "using_index_for_group_by": true } @@ -1159,6 +1243,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1172,6 +1257,7 @@ ANALYZE "r_loops": 1, "rows": 101, "r_rows": 100, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1246,6 +1332,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1255,6 +1342,7 @@ EXPLAIN "key_length": "147", "used_key_parts": ["a1", "a2", "b"], "rows": 17, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 'a' and t1.a2 >= 'b'", "using_index_for_group_by": true @@ -1268,6 +1356,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1277,6 +1366,7 @@ EXPLAIN "key_length": "163", "used_key_parts": ["a1", "a2", "b", "c"], "rows": 128, + "cost": "COST_REPLACED", "filtered": 0.198364258, "attached_condition": "t1.b = 'a' and t1.c = 'i121' and t1.a2 >= 'b'", "using_index": true @@ -1290,6 +1380,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1300,6 +1391,7 @@ EXPLAIN "key_length": "147", "used_key_parts": ["a1", "a2", "b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 'a' and t1.a1 >= '' and t1.a2 >= 'b'", "using_index_for_group_by": true @@ -1319,12 +1411,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = _latin1'\xDF'" } @@ -1343,12 +1437,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(case when convert(t1.a using utf8mb3) = (_utf8mb3'a' collate utf8mb3_bin) then NULL else t1.a end)" } @@ -1376,6 +1472,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "TOP > t2.a", "filesort": { "sort_key": "t2.a", @@ -1386,6 +1483,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 256, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1400,6 +1498,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t2.a", "temporary_table": { @@ -1409,6 +1508,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 256, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1434,6 +1534,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t2.a", "temporary_table": { @@ -1443,6 +1544,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 256, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1511,6 +1613,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "nested_loop": [ { @@ -1528,6 +1631,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1543,6 +1647,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "const_condition": "1", @@ -1567,6 +1672,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1588,12 +1694,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -1607,6 +1715,7 @@ EXPLAIN "used_key_parts": ["pk"], "ref": ["test.t1.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "trigcond(t2.pk is null) and trigcond(trigcond(t1.a is not null))", "using_index": true, @@ -1625,6 +1734,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1635,6 +1745,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1653,6 +1764,7 @@ ANALYZE "r_loops": 2, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1677,6 +1789,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1684,6 +1797,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a is not null" } @@ -1698,6 +1812,7 @@ EXPLAIN "used_key_parts": ["pk"], "ref": ["test.t1.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "using_index": true, "distinct": true @@ -1716,6 +1831,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "temporary_table": { @@ -1727,6 +1843,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1746,6 +1863,7 @@ ANALYZE "r_loops": 2, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1783,12 +1901,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.a is not null" } @@ -1804,6 +1924,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.a"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "index_condition_bka": "t4.b + 1 <= t3.b + 1" }, @@ -1825,6 +1946,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1835,6 +1957,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1855,6 +1978,7 @@ ANALYZE "r_loops": 1, "rows": 1, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1888,12 +2012,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1904,6 +2030,7 @@ EXPLAIN "state": "uninitialized", "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "outer_ref_condition": "t0.a < 5", "nested_loop": [ { @@ -1911,6 +2038,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b < t0.a" } @@ -1933,6 +2061,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -1942,6 +2071,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1955,6 +2085,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -1964,6 +2095,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1977,6 +2109,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -1986,6 +2119,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2007,12 +2141,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -2024,6 +2160,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -2038,6 +2175,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 25 }, "buffer_type": "incremental", diff --git a/mysql-test/main/explain_json.test b/mysql-test/main/explain_json.test index be077b22f48..6403fdefdd7 100644 --- a/mysql-test/main/explain_json.test +++ b/mysql-test/main/explain_json.test @@ -11,10 +11,13 @@ drop table if exists t0,t1,t2; create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +--source include/explain-no-costs.inc explain format=json select * from t0; +--source include/explain-no-costs.inc explain format=json select * from t0 where 1>2; +--source include/explain-no-costs.inc explain format=json select * from t0 where a<3; --echo # Try a basic join @@ -26,22 +29,28 @@ select 'filler' from t0 a, t0 b, t0 c; +--source include/explain-no-costs.inc explain format=json select * from t0,t1 where t1.a=t0.a; --echo # Try range and index_merge create table t2 (a1 int, a2 int, b1 int, b2 int, key(a1,a2), key(b1,b2)); insert into t2 select a,a,a,a from t1; +--source include/explain-no-costs.inc explain format=json select * from t2 where a1<5; +--source include/explain-no-costs.inc explain format=json select * from t2 where a1=1 or b1=2; +--source include/explain-no-costs.inc explain format=json select * from t2 where a1=1 or (b1=2 and b2=3); +--source include/explain-no-costs.inc explain format=json select * from t2 where (a1=1 and a2=1) or (b1=2 and b2=1); --echo # Try ref access on two key components +--source include/explain-no-costs.inc explain format=json select * from t0,t2 where t2.b1=t0.a and t2.b2=4; drop table t1,t2; @@ -49,7 +58,9 @@ drop table t1,t2; --echo # --echo # Try a UNION --echo # +--source include/explain-no-costs.inc explain format=json select * from t0 A union select * from t0 B; +--source include/explain-no-costs.inc explain format=json select * from t0 A union all select * from t0 B; --echo # @@ -57,8 +68,10 @@ explain format=json select * from t0 A union all select * from t0 B; --echo # create table t1 (a int, b int); insert into t1 select a,a from t0; +--source include/explain-no-costs.inc explain format=json select a, a > (select max(b) from t1 where t1.b=t0.a) from t0; +--source include/explain-no-costs.inc explain format=json select * from t0 where a > (select max(b) from t1 where t1.b=t0.a) or a < 3 ; @@ -71,6 +84,7 @@ drop table t1; create table t1 (a int, b int); insert into t1 select tbl1.a+10*tbl2.a, tbl1.a+10*tbl2.a from t0 tbl1, t0 tbl2; +--source include/explain-no-costs.inc explain format=json select * from t1 tbl1, t1 tbl2 where tbl1.a=tbl2.a and tbl1.b < 3 and tbl2.b < 5; @@ -79,16 +93,22 @@ drop table t1; --echo # --echo # Single-table UPDATE/DELETE, INSERT --echo # +--source include/explain-no-costs.inc explain format=json delete from t0; +--source include/explain-no-costs.inc explain format=json delete from t0 where 1 > 2; +--source include/explain-no-costs.inc explain format=json delete from t0 where a < 3; +--source include/explain-no-costs.inc explain format=json update t0 set a=3 where a in (2,3,4); +--source include/explain-no-costs.inc explain format=json insert into t0 values (1); create table t1 like t0; +--source include/explain-no-costs.inc explain format=json insert into t1 values ((select max(a) from t0)); drop table t1; @@ -98,10 +118,12 @@ drop table t1; --echo # create table t1 (a int, b int); insert into t1 select a,a from t0; +--source include/explain-no-costs.inc explain format=json select * from (select a, count(*) as cnt from t1 group by a) as tbl where cnt>0; +--source include/explain-no-costs.inc explain format=json select * from (select a, count(*) as cnt from t1 group by a) as tbl1, t1 as tbl2 where cnt=tbl2.a; @@ -109,6 +131,7 @@ tbl2 where cnt=tbl2.a; --echo # --echo # Non-merged semi-join (aka JTBM) --echo # +--source include/explain-no-costs.inc explain format=json select * from t1 where a in (select max(a) from t1 group by b); @@ -117,6 +140,7 @@ select * from t1 where a in (select max(a) from t1 group by b); --echo # create table t2 like t1; insert into t2 select * from t1; +--source include/explain-no-costs.inc explain format=json select * from t1,t2 where t1.a in ( select seq+0 from seq_1_to_100); @@ -125,6 +149,7 @@ select * from t1,t2 where t1.a in ( select seq+0 from seq_1_to_100); --echo # explain select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b); +--source include/explain-no-costs.inc explain format=json select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b); @@ -135,6 +160,7 @@ set @tmp= @@optimizer_switch; set optimizer_switch='firstmatch=off'; explain select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b); +--source include/explain-no-costs.inc explain format=json select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b); set optimizer_switch=@tmp; @@ -149,10 +175,12 @@ insert into t1 select tbl1.a+10*tbl2.a, 12345 from t0 tbl1, t0 tbl2; set @tmp= @@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on'; +--source include/explain-no-costs.inc explain format=json select * from t1 where a < 3; --echo # 'Range checked for each record' set optimizer_switch=@tmp; +--source include/explain-no-costs.inc explain format=json select * from t1 tbl1, t1 tbl2 where tbl2.a < tbl1.b; @@ -169,6 +197,7 @@ INSERT INTO t1 VALUES (1),(2),(5),(6),(7); CREATE TABLE t2 (b INT); INSERT INTO t2 VALUES (3),(4),(9),(10),(11); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM t1 AS outer_t1 WHERE a <> ALL ( SELECT a FROM t1, t2 WHERE b <> outer_t1.a ); DROP TABLE t1,t2; @@ -182,6 +211,7 @@ insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1(a int, b int); insert into t1 select tbl1.a+10*tbl2.a, 1234 from t0 tbl1, t0 tbl2; +--source include/explain-no-costs.inc explain format=json select * from t0 where @@ -200,6 +230,7 @@ INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2 (b INT); INSERT INTO t2 VALUES (3),(4); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a <> ALL ( SELECT b FROM t2 ); DROP TABLE t1, t2; @@ -221,6 +252,7 @@ insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 (a int, b int, c int, d int, key(a,b,c)); insert into t1 select A.a, B.a, C.a, D.a from t2 A, t2 B, t2 C, t2 D; explain select count(distinct b) from t1 group by a; +--source include/explain-no-costs.inc explain format=json select count(distinct b) from t1 group by a; --source include/analyze-format.inc analyze format=json select count(distinct b) from t1 group by a; @@ -278,10 +310,13 @@ explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); explain select count(distinct a1,a2,b) from t1 where a1 >= "" and (a2 >= 'b') and (b = 'a'); +--source include/explain-no-costs.inc explain format=json select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); +--source include/explain-no-costs.inc explain format=json select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +--source include/explain-no-costs.inc explain format=json select count(distinct a1,a2,b) from t1 where a1 >= "" and (a2 >= 'b') and (b = 'a'); drop table t1; @@ -290,6 +325,7 @@ drop table t1; --echo # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1); INSERT INTO t1 VALUES ('a'),('b'); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a=_latin1 0xDF; DROP TABLE t1; @@ -298,6 +334,7 @@ DROP TABLE t1; --echo # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1); INSERT INTO t1 VALUES ('a'),('A'); +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE NULLIF(a,_utf8'a' COLLATE utf8_bin); DROP TABLE t1; @@ -315,12 +352,16 @@ create table t2 ( ); insert into t2 select A.a*1000 + B.a, A.a*1000 + B.a from t0 A, t1 B; --echo # normal HAVING +--source include/explain-no-costs.inc explain format=json select a, max(b) as TOP from t2 group by a having TOP > a; --echo # HAVING is always TRUE (not printed) +--source include/explain-no-costs.inc explain format=json select a, max(b) as TOP from t2 group by a having 1<>2; --echo # HAVING is always FALSE (intercepted by message) +--source include/explain-no-costs.inc explain format=json select a, max(b) as TOP from t2 group by a having 1=2; --echo # HAVING is absent +--source include/explain-no-costs.inc explain format=json select a, max(b) as TOP from t2 group by a; drop table t0, t1, t2; @@ -332,6 +373,7 @@ drop table t0, t1, t2; create table t1 (i int) engine=myisam; explain select * from t1; +--source include/explain-no-costs.inc explain format=json select * from t1; --source include/analyze-format.inc @@ -348,6 +390,7 @@ insert into t2 values (1),(2); explain select * from t1 left join t2 on t2.pk > 10 and t2.pk < 0; +--source include/explain-no-costs.inc explain format=json select * from t1 left join t2 on t2.pk > 10 and t2.pk < 0; --source include/analyze-format.inc @@ -357,6 +400,7 @@ select * from t1 left join t2 on t2.pk > 10 and t2.pk < 0; --echo # Check ET_NOT_EXISTS: explain select * from t1 left join t2 on t2.pk=t1.a where t2.pk is null; +--source include/explain-no-costs.inc explain format=json select * from t1 left join t2 on t2.pk=t1.a where t2.pk is null; --source include/analyze-format.inc @@ -366,6 +410,7 @@ select * from t1 left join t2 on t2.pk=t1.a where t2.pk is null; --echo # Check ET_DISTINCT explain select distinct t1.a from t1 join t2 on t2.pk=t1.a; +--source include/explain-no-costs.inc explain format=json select distinct t1.a from t1 join t2 on t2.pk=t1.a; --source include/analyze-format.inc @@ -392,6 +437,7 @@ set optimizer_switch='mrr=on'; set join_cache_level=6; explain select * from t3,t4 where t3.a=t4.a and (t4.b+1 <= t3.b+1); +--source include/explain-no-costs.inc explain format=json select * from t3,t4 where t3.a=t4.a and (t4.b+1 <= t3.b+1); --source include/analyze-format.inc @@ -410,6 +456,7 @@ insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 (a int, b int); insert into t1 select a,a from t0; +--source include/explain-no-costs.inc explain format=json select a, (select max(a) from t1 where t0.a<5 and t1.b 2" } @@ -60,6 +62,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -69,6 +72,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 2" } @@ -105,12 +109,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2" } @@ -126,12 +132,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2" } @@ -168,6 +176,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -177,6 +186,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a < 4" } @@ -194,6 +204,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -203,6 +214,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a < 4" } @@ -243,6 +255,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -252,6 +265,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 or t1.a = 3" } @@ -271,6 +285,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -280,6 +295,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 or t1.a = 3" } @@ -319,6 +335,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a > 2 and max(t1.b) > 13 or t1.a < 3 and min(t1.c) > 1", "filesort": { "sort_key": "t1.a", @@ -329,6 +346,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 2 or t1.a < 3" } @@ -347,6 +365,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a > 2 and max(t1.b) > 13 or t1.a < 3 and min(t1.c) > 1", "filesort": { "sort_key": "t1.a", @@ -357,6 +376,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 2 or t1.a < 3" } @@ -393,6 +413,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.a) < 3", "filesort": { "sort_key": "t1.a", @@ -403,6 +424,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -421,6 +443,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.a) < 3", "filesort": { "sort_key": "t1.a", @@ -431,6 +454,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -466,6 +490,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) > 13", "filesort": { "sort_key": "t1.a", @@ -476,6 +501,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -494,6 +520,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) > 13", "filesort": { "sort_key": "t1.a", @@ -504,6 +531,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -539,6 +567,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.a) = 3", "nested_loop": [ { @@ -546,6 +575,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 3" } @@ -562,6 +592,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.a) = 3", "nested_loop": [ { @@ -569,6 +600,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 3" } @@ -602,6 +634,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) > 12", "nested_loop": [ { @@ -609,6 +642,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2" } @@ -625,6 +659,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) > 12", "nested_loop": [ { @@ -632,6 +667,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2" } @@ -665,6 +701,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) = 13", "filesort": { "sort_key": "t1.a", @@ -675,6 +712,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -693,6 +731,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) = 13", "filesort": { "sort_key": "t1.a", @@ -703,6 +742,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -740,6 +780,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "min(t1.c) < 3", "filesort": { "sort_key": "t1.a", @@ -750,6 +791,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -768,6 +810,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "min(t1.c) < 3", "filesort": { "sort_key": "t1.a", @@ -778,6 +821,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -813,6 +857,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) = 13 and min(t1.c) = 2", "nested_loop": [ { @@ -820,6 +865,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2" } @@ -836,6 +882,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) = 13 and min(t1.c) = 2", "nested_loop": [ { @@ -843,6 +890,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2" } @@ -877,6 +925,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a = test.f1()", "filesort": { "sort_key": "t1.a", @@ -887,6 +936,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -905,6 +955,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a = test.f1()", "filesort": { "sort_key": "t1.a", @@ -915,6 +966,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -959,6 +1011,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "v1.a", "temporary_table": { @@ -968,6 +1021,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x > 1 and t2.x is not null" } @@ -982,10 +1036,12 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.x"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -995,6 +1051,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -1019,6 +1076,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "v1.a", "temporary_table": { @@ -1028,6 +1086,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x > 1 and t2.x is not null" } @@ -1042,10 +1101,12 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.x"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -1055,6 +1116,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -1106,6 +1168,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "v1.c", "temporary_table": { @@ -1115,6 +1178,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x is not null" } @@ -1129,11 +1193,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.x"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 2", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "t1.c > 2", "filesort": { "sort_key": "t1.a", @@ -1144,6 +1210,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1167,6 +1234,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "v1.c", "temporary_table": { @@ -1176,6 +1244,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x is not null" } @@ -1190,11 +1259,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.x"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 2", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "t1.c > 2", "filesort": { "sort_key": "t1.a", @@ -1205,6 +1276,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1256,6 +1328,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -1265,6 +1338,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" } @@ -1279,11 +1353,13 @@ EXPLAIN "used_key_parts": ["x", "MAX(t2.y)"], "ref": ["test.t1.a", "test.t1.b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1291,6 +1367,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x < 5 and t2.x > 1" } @@ -1315,6 +1392,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -1324,6 +1402,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" } @@ -1338,11 +1417,13 @@ EXPLAIN "used_key_parts": ["x", "MAX(t2.y)"], "ref": ["test.t1.a", "test.t1.b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1350,6 +1431,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x < 5 and t2.x > 1" } @@ -1399,6 +1481,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.b", "temporary_table": { @@ -1408,6 +1491,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b < 14 and t1.a is not null and t1.b is not null" } @@ -1422,11 +1506,13 @@ EXPLAIN "used_key_parts": ["x", "MAX(t2.y)"], "ref": ["test.t1.a", "test.t1.b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.y)` < 14", "temporary_table": { "nested_loop": [ @@ -1435,6 +1521,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x < 5" } @@ -1459,6 +1546,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.b", "temporary_table": { @@ -1468,6 +1556,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b < 14 and t1.a is not null and t1.b is not null" } @@ -1482,11 +1571,13 @@ EXPLAIN "used_key_parts": ["x", "MAX(t2.y)"], "ref": ["test.t1.a", "test.t1.b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.y)` < 14", "temporary_table": { "nested_loop": [ @@ -1495,6 +1586,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.x < 5" } @@ -1538,6 +1630,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.c = 2", "filesort": { "sort_key": "t1.a", @@ -1548,6 +1641,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -1565,6 +1659,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.c = 2", "filesort": { "sort_key": "t1.a", @@ -1575,6 +1670,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1" } @@ -1610,6 +1706,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a = 2 and t1.c = 2", "nested_loop": [ { @@ -1617,6 +1714,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 13" } @@ -1633,6 +1731,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a = 2 and t1.c = 2", "nested_loop": [ { @@ -1640,6 +1739,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 13" } @@ -1674,6 +1774,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -1683,6 +1784,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and t1.a > 1" } @@ -1699,6 +1801,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -1708,6 +1811,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and t1.a > 1" } @@ -1743,12 +1847,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2 and t1.c = 2" } @@ -1764,12 +1870,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2 and t1.c = 2" } @@ -1803,6 +1911,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.c = t1.a and t1.a > 1 or t1.a < 3 and t1.c > 3", "filesort": { "sort_key": "t1.a", @@ -1813,6 +1922,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and t1.a > 1 or t1.a < 3" } @@ -1831,6 +1941,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.c = t1.a and t1.a > 1 or t1.a < 3 and t1.c > 3", "filesort": { "sort_key": "t1.a", @@ -1841,6 +1952,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and t1.a > 1 or t1.a < 3" } @@ -1883,6 +1995,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -1892,6 +2005,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and t1.a < 3" } @@ -1909,6 +2023,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -1918,6 +2033,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and t1.a < 3" } @@ -1958,6 +2074,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -1967,6 +2084,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and t1.a > 1 and t1.a < 3" } @@ -1984,6 +2102,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -1993,6 +2112,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and t1.a > 1 and t1.a < 3" } @@ -2032,6 +2152,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a > 1 and max(t1.c) < 3 or t1.c < 4", "filesort": { "sort_key": "t1.a", @@ -2042,6 +2163,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4) and t1.a < 2" } @@ -2060,6 +2182,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a > 1 and max(t1.c) < 3 or t1.c < 4", "filesort": { "sort_key": "t1.a", @@ -2070,6 +2193,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4) and t1.a < 2" } @@ -2112,6 +2236,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a > 1 and max(t1.c) < 3 or t1.c < 4", "filesort": { "sort_key": "t1.a", @@ -2122,6 +2247,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4)" } @@ -2140,6 +2266,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a > 1 and max(t1.c) < 3 or t1.c < 4", "filesort": { "sort_key": "t1.a", @@ -2150,6 +2277,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4)" } @@ -2208,6 +2336,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.b = 13 and max(t1.c) > 2", "filesort": { "sort_key": "t1.a", @@ -2218,6 +2347,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2234,6 +2364,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.b = 13 and max(t1.c) > 2", "filesort": { "sort_key": "t1.a", @@ -2244,6 +2375,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2281,6 +2413,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2290,6 +2423,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a = 1 or t1.b > 10) and t1.b < 14" } @@ -2307,6 +2441,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2316,6 +2451,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a = 1 or t1.b > 10) and t1.b < 14" } @@ -2355,6 +2491,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2364,6 +2501,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.b > 15)" } @@ -2381,6 +2519,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2390,6 +2529,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.b > 15)" } @@ -2428,6 +2568,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2437,6 +2578,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.a = 2 and t1.b > 15)" } @@ -2454,6 +2596,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2463,6 +2606,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.a = 2 and t1.b > 15)" } @@ -2503,6 +2647,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2512,6 +2657,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 2 or t1.b = 13 and t1.a > 2" } @@ -2529,6 +2675,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2538,6 +2685,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 2 or t1.b = 13 and t1.a > 2" } @@ -2575,6 +2723,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2584,6 +2733,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 14 and t1.a < 2 or t1.b = 13 and t1.a > 2" } @@ -2601,6 +2751,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2610,6 +2761,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 14 and t1.a < 2 or t1.b = 13 and t1.a > 2" } @@ -2649,6 +2801,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2658,6 +2811,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 14 and t1.a < 2 or t1.a > 2 and (t1.b = 13 or t1.b = 14)" } @@ -2675,6 +2829,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -2684,6 +2839,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 14 and t1.a < 2 or t1.a > 2 and (t1.b = 13 or t1.b = 14)" } @@ -2719,6 +2875,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a < 2 and max(t1.c) = 2 or max(t1.c) > 2 and (t1.a = 1 or t1.a = 2)", "filesort": { "sort_key": "t1.a", @@ -2729,6 +2886,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 2 or t1.a = 1 or t1.a = 2" } @@ -2747,6 +2905,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a < 2 and max(t1.c) = 2 or max(t1.c) > 2 and (t1.a = 1 or t1.a = 2)", "filesort": { "sort_key": "t1.a", @@ -2757,6 +2916,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 2 or t1.a = 1 or t1.a = 2" } @@ -2794,6 +2954,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a = 2 and max(t1.c) = 2 or max(t1.c) > 2 and (t1.a = 1 or t1.a = 2)", "filesort": { "sort_key": "t1.a", @@ -2804,6 +2965,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2 or t1.a = 1 or t1.a = 2" } @@ -2822,6 +2984,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.a = 2 and max(t1.c) = 2 or max(t1.c) > 2 and (t1.a = 1 or t1.a = 2)", "filesort": { "sort_key": "t1.a", @@ -2832,6 +2995,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 2 or t1.a = 1 or t1.a = 2" } @@ -2868,6 +3032,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.c) = 3", "nested_loop": [ { @@ -2875,6 +3040,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -2891,6 +3057,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.c) = 3", "nested_loop": [ { @@ -2898,6 +3065,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -2932,6 +3100,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b = 14)", "nested_loop": [ { @@ -2939,6 +3108,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 3" } @@ -2955,6 +3125,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) = 14", "nested_loop": [ { @@ -2962,6 +3133,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 3" } @@ -2995,6 +3167,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b = 14)", "nested_loop": [ { @@ -3002,6 +3175,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 1" } @@ -3018,6 +3192,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "max(t1.b) = 14", "nested_loop": [ { @@ -3025,6 +3200,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 1" } @@ -3068,6 +3244,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3077,6 +3254,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 2 and t1.a < 3" } @@ -3094,6 +3272,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3103,6 +3282,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 2 and t1.a < 3" } @@ -3143,12 +3323,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 3 and t1.b > 2" } @@ -3164,12 +3346,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 3 and t1.b > 2" } @@ -3208,6 +3392,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3217,6 +3402,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 14 and t1.a < 3" } @@ -3234,6 +3420,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3243,6 +3430,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 14 and t1.a < 3" } @@ -3283,12 +3471,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.b = 14" } @@ -3304,12 +3494,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = 14 and t1.a = 1" } @@ -3395,12 +3587,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 1" } @@ -3416,12 +3610,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = 1 and t1.a = 1" } @@ -3462,6 +3658,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3471,6 +3668,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c > 0 and t1.c < 3 and t1.a > 1" } @@ -3488,6 +3686,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3497,6 +3696,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c > 0 and t1.c < 3 and t1.a > 1" } @@ -3537,12 +3737,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c > 0 and t1.c < 3" } @@ -3558,12 +3760,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c > 0 and t1.c < 3" } @@ -3602,6 +3806,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "nested_loop": [ { @@ -3609,6 +3814,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c < 3" } @@ -3624,12 +3830,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c < 3" } @@ -3713,12 +3921,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.b = 2 and t3.d = 1 and t3.a = 1" } @@ -3734,12 +3944,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.b = 2 and t3.d = 1 and t3.a = 1" } @@ -3778,6 +3990,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3787,6 +4000,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 2" } @@ -3804,6 +4018,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3813,6 +4028,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 2" } @@ -3901,6 +4117,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3910,6 +4127,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a < 4 and t1.a > 0" } @@ -3927,6 +4145,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -3936,6 +4155,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a < 4 and t1.a > 0" } @@ -3976,6 +4196,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1 and 1", "nested_loop": [ { @@ -3983,6 +4204,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -3998,12 +4220,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -4044,6 +4268,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -4053,6 +4278,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and (t1.a < 4 or t1.a > 0)" } @@ -4070,6 +4296,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -4079,6 +4306,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and (t1.a < 4 or t1.a > 0)" } @@ -4119,6 +4347,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "nested_loop": [ { @@ -4126,6 +4355,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -4141,12 +4371,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1" } @@ -4187,6 +4419,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.c > 1", "filesort": { "sort_key": "t1.a", @@ -4197,6 +4430,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.c < 3 and t1.a < 4" } @@ -4216,6 +4450,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.c > 1", "filesort": { "sort_key": "t1.a", @@ -4226,6 +4461,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.c < 3 and t1.a < 4" } @@ -4263,6 +4499,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "filesort": { "sort_key": "t1.c", @@ -4273,6 +4510,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c < 3 and t1.c > 1" } @@ -4291,6 +4529,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.c", "temporary_table": { @@ -4300,6 +4539,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c < 3 and t1.c > 1" } @@ -4339,6 +4579,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1 and 1", "nested_loop": [ { @@ -4346,6 +4587,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 3" } @@ -4362,12 +4604,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 3" } @@ -4405,6 +4649,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t3.d > 0", "nested_loop": [ { @@ -4412,6 +4657,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" } @@ -4429,6 +4675,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t3.d > 0", "nested_loop": [ { @@ -4436,6 +4683,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" } @@ -4473,6 +4721,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "nested_loop": [ { @@ -4480,6 +4729,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" } @@ -4496,12 +4746,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" } @@ -4542,6 +4794,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.c > 1", "filesort": { "sort_key": "t1.a", @@ -4552,6 +4805,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4" } @@ -4571,6 +4825,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "t1.c > 1", "filesort": { "sort_key": "t1.a", @@ -4581,6 +4836,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4" } @@ -4624,6 +4880,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.c", "temporary_table": { @@ -4633,6 +4890,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4 and t1.c > 1" } @@ -4651,6 +4909,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.c", "temporary_table": { @@ -4660,6 +4919,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4 and t1.c > 1" } @@ -4703,6 +4963,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.c", "temporary_table": { @@ -4712,6 +4973,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a = 1 or t1.a = 3) and (t1.a = 4 or t1.c > 1)" } @@ -4730,6 +4992,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.c", "temporary_table": { @@ -4739,6 +5002,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a = 1 or t1.a = 3) and (t1.a = 4 or t1.c > 1)" } @@ -4779,12 +5043,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 1" } @@ -4800,12 +5066,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 1" } @@ -4844,12 +5112,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 1" } @@ -4866,12 +5136,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.c = 1" } @@ -5051,6 +5323,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t3.a", "temporary_table": { @@ -5060,6 +5333,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.a = 1 or t3.a > 1)" } @@ -5078,6 +5352,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t3.a", "temporary_table": { @@ -5087,6 +5362,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.a = 1 or t3.a > 1)" } @@ -5125,6 +5401,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t3.a", "temporary_table": { @@ -5134,6 +5411,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.c = t3.a and t3.c < 15 or t3.a > 1)" } @@ -5152,6 +5430,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t3.a", "temporary_table": { @@ -5161,6 +5440,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.c = t3.a and t3.a < 15 or t3.a > 1)" } @@ -5240,6 +5520,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.d1", "temporary_table": { @@ -5249,6 +5530,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.d1 between (inet_aton('1978-04-27')) and ('2018-08-26')" } @@ -5282,6 +5564,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.d1", "temporary_table": { @@ -5291,6 +5574,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.d1 not between (0) and (exp(0))" } @@ -5357,6 +5641,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "temporary_table": { @@ -5366,6 +5651,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 8 or t1.a = (subquery#2)" } @@ -5375,12 +5661,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -5401,6 +5689,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { @@ -5410,6 +5699,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a = 8 or t1.a = (subquery#2)) and t1.b < 20" } @@ -5419,12 +5709,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -5445,6 +5737,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "sum(t1.b) > 20", "filesort": { "sort_key": "t1.a", @@ -5455,6 +5748,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 8 or t1.a = (subquery#2)" } @@ -5464,12 +5758,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -5490,12 +5786,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = (subquery#2)" } @@ -5505,12 +5803,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } diff --git a/mysql-test/main/having_cond_pushdown.test b/mysql-test/main/having_cond_pushdown.test index 99e4a597f22..be18699519e 100644 --- a/mysql-test/main/having_cond_pushdown.test +++ b/mysql-test/main/having_cond_pushdown.test @@ -23,12 +23,14 @@ HAVING (t1.a>2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) FROM t1 WHERE (t1.a>2) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : using equality @@ -40,12 +42,14 @@ HAVING (t1.a=2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) FROM t1 WHERE (t1.a=2) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # extracted AND formula @@ -57,12 +61,14 @@ HAVING (t1.a>1) AND (t1.a<4); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) FROM t1 WHERE (t1.a>1) AND (t1.a<4) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # extracted OR formula @@ -75,6 +81,7 @@ eval $no_pushdown $query; eval $query; --enable_prepare_warnings eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; --disable_prepare_warnings let $query= @@ -83,6 +90,7 @@ FROM t1 WHERE (t1.a>1) OR (a IN (SELECT 3)) GROUP BY t1.a; --enable_prepare_warnings +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --disable_prepare_warnings @@ -94,6 +102,7 @@ HAVING ((t1.a>2) AND (MAX(t1.b)>13)) OR ((t1.a<3) AND (MIN(t1.c)>1)); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -101,6 +110,7 @@ FROM t1 WHERE (t1.a>2) OR (t1.a<3) GROUP BY t1.a HAVING ((t1.a>2) AND (MAX(t1.b)>13)) OR ((t1.a<3) AND (MIN(t1.c)>1)); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : no aggregation formula pushdown @@ -112,6 +122,7 @@ HAVING (t1.a>1) AND (MAX(t1.a)<3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) @@ -119,6 +130,7 @@ FROM t1 WHERE (t1.a>1) GROUP BY t1.a HAVING (MAX(t1.a)<3); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -129,6 +141,7 @@ HAVING (t1.a>1) AND (MAX(t1.b)>13); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) @@ -136,6 +149,7 @@ FROM t1 WHERE (t1.a>1) GROUP BY t1.a HAVING (MAX(t1.b)>13); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -146,6 +160,7 @@ HAVING (t1.a=3) AND (MAX(t1.a)=3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) @@ -153,6 +168,7 @@ FROM t1 WHERE (t1.a=3) GROUP BY t1.a HAVING (MAX(t1.a)=3); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -163,6 +179,7 @@ HAVING (t1.a=2) AND (MAX(t1.b)>12); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) @@ -170,6 +187,7 @@ FROM t1 WHERE (t1.a=2) GROUP BY t1.a HAVING (MAX(t1.b)>12); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -180,6 +198,7 @@ HAVING (t1.a>1) AND (MAX(t1.b)=13); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) @@ -187,6 +206,7 @@ FROM t1 WHERE (t1.a>1) GROUP BY t1.a HAVING (MAX(t1.b)=13); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -197,6 +217,7 @@ HAVING (t1.a>1) AND (MIN(t1.c)<3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MIN(t1.c) @@ -204,6 +225,7 @@ FROM t1 WHERE (t1.a>1) GROUP BY t1.a HAVING (MIN(t1.c)<3); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -214,6 +236,7 @@ HAVING (t1.a=2) AND (MAX(t1.b)=13) AND (MIN(t1.c)=2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MIN(t1.c) @@ -221,6 +244,7 @@ FROM t1 WHERE (t1.a=2) GROUP BY t1.a HAVING (MAX(t1.b)=13) AND (MIN(t1.c)=2); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : no stored function pushdown @@ -232,6 +256,7 @@ HAVING (t1.a>1) AND (a=test.f1()); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) @@ -239,6 +264,7 @@ FROM t1 WHERE (t1.a>1) GROUP BY t1.a HAVING (a=test.f1()); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : pushdown into derived table WHERE clause @@ -251,12 +277,14 @@ HAVING (v1.a>1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT v1.a FROM t2,v1 WHERE (t2.x=v1.a) AND (v1.a>1) GROUP BY v1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : pushdown into derived table HAVING clause @@ -269,12 +297,14 @@ HAVING (v1.c>2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT v1.a,v1.c FROM t2,v1 WHERE (t2.x=v1.a) AND (v1.c>2) GROUP BY v1.c; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : pushdown into materialized IN subquery @@ -288,6 +318,7 @@ HAVING (t1.a>1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT * FROM t1 @@ -295,6 +326,7 @@ WHERE (t1.a>1) AND (t1.a,t1.b) IN (SELECT t2.x,MAX(t2.y) FROM t2 WHERE t2.x<5 GROUP BY t2.x) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : pushdown into materialized IN subquery @@ -308,6 +340,7 @@ HAVING (t1.b<14); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT * FROM t1 @@ -315,6 +348,7 @@ WHERE (t1.b<14) AND (t1.a,t1.b) IN (SELECT t2.x,MAX(t2.y) FROM t2 WHERE t2.x<5 GROUP BY t2.x) GROUP BY t1.b; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # non-standard allowed queries @@ -327,12 +361,14 @@ HAVING (t1.c=2) AND (t1.a>1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a>1) GROUP BY t1.a HAVING (t1.c=2); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -343,6 +379,7 @@ HAVING (t1.a=2) AND (t1.b=13) AND (t1.c=2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT MAX(t1.a),t1.a,t1.b,t1.c @@ -350,6 +387,7 @@ FROM t1 WHERE (t1.b=13) GROUP BY t1.b HAVING (t1.a=2) AND (t1.c=2); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # extracted AND formula : using equalities @@ -361,11 +399,13 @@ HAVING (t1.a=t1.c) AND (t1.c>1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) FROM t1 WHERE (t1.a=t1.c) AND (t1.a>1) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -376,12 +416,14 @@ HAVING (t1.a=t1.c) AND (t1.c=2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a=t1.c) AND (t1.a=2) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -392,6 +434,7 @@ HAVING ((t1.a=t1.c) AND (t1.a>1)) OR ((t1.a<3) AND (t1.c>3)); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -399,6 +442,7 @@ FROM t1 WHERE ((t1.a=t1.c) AND (t1.a>1)) OR (t1.a<3) GROUP BY t1.a HAVING ((t1.a=t1.c) AND (t1.a>1)) OR ((t1.a<3) AND (t1.c>3)); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjuctive subformula : pushdown using WHERE multiple equalities @@ -411,12 +455,14 @@ HAVING (t1.c<3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a=t1.c) AND (t1.c<3) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # extracted AND-formula : pushdown using WHERE multiple equalities @@ -429,12 +475,14 @@ HAVING (t1.a>1) AND (t1.c<3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a=t1.c) AND (t1.a>1) AND (t1.c<3) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -446,6 +494,7 @@ HAVING (((t1.a>1) AND (MAX(t1.c)<3)) OR (t1.c<4)) AND (t1.a<2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -453,6 +502,7 @@ FROM t1 WHERE (t1.a=t1.c) AND (((t1.a>1) OR (t1.c<4)) AND (t1.a<2)) GROUP BY t1.a HAVING ((t1.a>1) AND (MAX(t1.c)<3)) OR (t1.c<4); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # extracted OR-formula : pushdown using WHERE multiple equalities @@ -465,6 +515,7 @@ HAVING ((t1.a>1) AND (MAX(t1.c)<3)) OR (t1.c<4); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -472,6 +523,7 @@ FROM t1 WHERE (t1.a=t1.c) AND ((t1.a>1) OR (t1.c<4)) GROUP BY t1.a HAVING ((t1.a>1) AND (MAX(t1.c)<3)) OR (t1.c<4); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; DROP TABLE t1,t2; @@ -510,12 +562,14 @@ HAVING t1.b = 13 AND MAX(t1.c) > 2; eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 GROUP BY t1.a HAVING t1.b = 13 AND MAX(t1.c) > 2; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # extracted AND formula @@ -527,12 +581,14 @@ HAVING (t1.a = 1 OR t1.b > 10) AND (t1.b < 14); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.a = 1 OR t1.b > 10) AND (t1.b < 14) GROUP BY t1.a,t1.b; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -543,12 +599,14 @@ HAVING (t1.a = 1 OR t1.b > 10) AND (t1.b < 14 OR t1.b > 15); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.a = 1 OR t1.b > 10) AND (t1.b < 14 OR t1.b > 15) GROUP BY t1.a,t1.b; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # extracted AND formula : equality in the inner AND formula @@ -560,12 +618,14 @@ HAVING (t1.a = 1 OR t1.b > 10) AND (t1.b < 14 OR (t1.b > 15 AND t1.a = 2)); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.a = 1 OR t1.b > 10) AND (t1.b < 14 OR (t1.b > 15 AND t1.a = 2)) GROUP BY t1.a,t1.b; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # extracted OR formula @@ -577,12 +637,14 @@ HAVING (t1.a < 2) OR (t1.b = 13 AND t1.a > 2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.a < 2) OR (t1.b = 13 AND t1.a > 2) GROUP BY t1.a,t1.b; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -593,12 +655,14 @@ HAVING (t1.a < 2 AND t1.b = 14) OR (t1.a > 2 AND t1.b = 13); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.a < 2 AND t1.b = 14) OR (t1.a > 2 AND t1.b = 13) GROUP BY t1.a,t1.b; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -609,12 +673,14 @@ HAVING (t1.a < 2 AND t1.b = 14) OR (t1.a > 2 AND (t1.b = 13 OR t1.b = 14)); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.a < 2 AND t1.b = 14) OR (t1.a > 2 AND (t1.b = 13 OR t1.b = 14)) GROUP BY t1.a,t1.b; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -625,6 +691,7 @@ HAVING (t1.a < 2 AND MAX(t1.c) = 2) OR (MAX(t1.c) > 2 AND (t1.a = 1 OR t1.a = 2) eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) @@ -632,6 +699,7 @@ FROM t1 WHERE (t1.a < 2) OR (t1.a = 1 OR t1.a = 2) GROUP BY t1.a HAVING (t1.a < 2 AND MAX(t1.c) = 2) OR (MAX(t1.c) > 2 AND (t1.a = 1 OR t1.a = 2)); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -642,6 +710,7 @@ HAVING (t1.a = 2 AND MAX(t1.c) = 2) OR (MAX(t1.c) > 2 AND (t1.a = 1 OR t1.a = 2) eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) @@ -649,6 +718,7 @@ FROM t1 WHERE (t1.a = 2) OR (t1.a = 1 OR t1.a = 2) GROUP BY t1.a HAVING (t1.a = 2 AND MAX(t1.c) = 2) OR (MAX(t1.c) > 2 AND (t1.a = 1 OR t1.a = 2)); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : equality pushdown @@ -660,6 +730,7 @@ HAVING (t1.a = 1) AND (MAX(t1.c) = 3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) @@ -667,6 +738,7 @@ FROM t1 WHERE (t1.a = 1) GROUP BY t1.a HAVING (MAX(t1.c) = 3); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : equalities pushdown @@ -678,6 +750,7 @@ HAVING (t1.a = 1) AND (t1.c = 3) AND MAX(t1.b = 14); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) @@ -685,6 +758,7 @@ FROM t1 WHERE (t1.a = 1) AND (t1.c = 3) GROUP BY t1.a,t1.c HAVING (MAX(t1.b) = 14); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # conjunctive subformula : multiple equality consists of @@ -697,6 +771,7 @@ HAVING (t1.a = 1) AND (t1.c = 1) AND MAX(t1.b = 14); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) @@ -704,6 +779,7 @@ FROM t1 WHERE (t1.a = 1) AND (t1.c = 1) GROUP BY t1.a,t1.c HAVING (MAX(t1.b) = 14); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # @@ -720,12 +796,14 @@ HAVING (t1.a < 3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.b > 2) AND (t1.a < 3) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # equality : inequality in WHERE @@ -738,12 +816,14 @@ HAVING (t1.a = 3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.b > 2) AND (t1.a = 3) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # inequality : equality in WHERE @@ -756,12 +836,14 @@ HAVING (t1.a < 3); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.b = 14) AND (t1.a < 3) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # equality : equality in WHERE @@ -774,12 +856,14 @@ HAVING (t1.a = 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,t1.b,MAX(t1.c) FROM t1 WHERE (t1.b = 14) AND (t1.a = 1) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # equality : equality in WHERE, impossible WHERE @@ -792,12 +876,14 @@ HAVING (t1.a = 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.c) FROM t1 WHERE (t1.a = 3) AND (t1.a = 1) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # equality : equality in WHERE (equal through constant) @@ -810,12 +896,14 @@ HAVING (t1.a = 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.c = 1) AND (t1.a = 1) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # inequality : AND formula in WHERE @@ -828,12 +916,14 @@ HAVING (t1.a > 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.c > 0) AND (t1.c < 3) AND (t1.a > 1) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # equality : AND formula in WHERE @@ -846,12 +936,14 @@ HAVING (t1.a = 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.c > 0) AND (t1.c < 3) AND (t1.a = 1) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # equality : AND formula in WHERE, impossible WHERE @@ -864,12 +956,14 @@ HAVING (t1.a = 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a > 0) AND (t1.c < 3) AND (t1.a = 1) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -881,12 +975,14 @@ HAVING (t1.a = 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) FROM t1 WHERE (t1.a = 0) AND (t1.a = 3) AND (t1.a = 1) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -898,12 +994,14 @@ HAVING (t3.a = 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t3.a,t3.b,MAX(t3.c),t3.d FROM t3 WHERE (t3.b = 2) AND (t3.d = 1) AND (t3.a = 1) GROUP BY t3.a,t3.b,t3.d; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # inequality : OR formula in WHERE @@ -916,12 +1014,14 @@ HAVING (t1.a < 2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE ((t1.a > 1) OR (t1.c < 3)) AND (t1.a < 2) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -933,12 +1033,14 @@ HAVING (t1.a = 2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b) FROM t1 WHERE ((t1.a = 1) OR (t1.a = 3)) AND (t1.a = 2) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # AND formula : inequality in WHERE @@ -951,12 +1053,14 @@ HAVING (t1.a < 4) AND (t1.a > 0); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a > 1) AND (t1.a < 4) AND (t1.a > 0) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # AND formula : equality in WHERE @@ -969,12 +1073,14 @@ HAVING (t1.a < 4) AND (t1.a > 0); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a = 1) AND (t1.a < 4) AND (t1.a > 0) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # OR formula : inequality in WHERE @@ -987,12 +1093,14 @@ HAVING (t1.a < 4) OR (t1.a > 0); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a > 1) AND ((t1.a < 4) OR (t1.a > 0)) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # OR formula : equality in WHERE @@ -1005,12 +1113,14 @@ HAVING (t1.a < 4) OR (t1.a > 0); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a = 1) AND ((t1.a < 4) OR (t1.a > 0)) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # AND formula : AND formula in WHERE @@ -1023,6 +1133,7 @@ HAVING (t1.a < 4) AND (t1.c > 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1031,6 +1142,7 @@ WHERE ((t1.a > 1) AND (t1.c < 3)) AND (t1.a < 4) GROUP BY t1.a HAVING (t1.c > 1); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -1042,6 +1154,7 @@ HAVING (t1.a < 4) AND (t1.c > 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1049,6 +1162,7 @@ FROM t1 WHERE ((t1.a = 1) AND (t1.c < 3)) AND ((t1.a < 4) AND (t1.c > 1)) GROUP BY t1.a,t1.c; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -1060,6 +1174,7 @@ HAVING (t1.a < 4) AND (t1.c > 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1067,6 +1182,7 @@ FROM t1 WHERE ((t1.a = 1) AND (t1.c = 3)) AND ((t1.a < 4) AND (t1.c > 1)) GROUP BY t1.a,t1.c; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -1078,6 +1194,7 @@ HAVING (t3.b = 2) AND (t3.d > 0); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t3.a,t3.b,MAX(t3.c),t3.d @@ -1086,6 +1203,7 @@ WHERE (t3.a = 1) AND (t3.d = 1) AND (t3.b = 2) GROUP BY t3.a,t3.b HAVING (t3.d > 0); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -1097,6 +1215,7 @@ HAVING (t3.b = 2) AND (t3.d > 0); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t3.a,t3.b,MAX(t3.c),t3.d @@ -1104,6 +1223,7 @@ FROM t3 WHERE (t3.a = 1) AND (t3.d = 1) AND (t3.b = 2) AND (t3.d > 0) GROUP BY t3.a,t3.b,t3.d; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # AND formula : OR formula in WHERE @@ -1116,6 +1236,7 @@ HAVING (t1.a < 4) AND (t1.c > 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1124,6 +1245,7 @@ WHERE ((t1.a > 1) OR (t1.c < 3)) AND (t1.a < 4) GROUP BY t1.a HAVING (t1.c > 1); +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -1135,6 +1257,7 @@ HAVING (t1.a < 4) AND (t1.c > 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1142,6 +1265,7 @@ FROM t1 WHERE ((t1.a > 1) OR (t1.c < 3)) AND (t1.a < 4) AND (t1.c > 1) GROUP BY t1.a,t1.c; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -1153,6 +1277,7 @@ HAVING (t1.a = 4) OR (t1.c > 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1160,6 +1285,7 @@ FROM t1 WHERE ((t1.a = 1) OR (t1.a = 3)) AND ((t1.a = 4) OR (t1.c > 1)) GROUP BY t1.a,t1.c; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # equality : pushdown through equality in WHERE @@ -1172,12 +1298,14 @@ HAVING (t1.c = 1); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c FROM t1 WHERE (t1.a = 1) AND (t1.a = t1.c) AND (t1.c = 1) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # OR formula : pushdown through equality @@ -1190,6 +1318,7 @@ HAVING (t1.c = 1) OR (t1.c = 2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1197,6 +1326,7 @@ FROM t1 WHERE (t1.a = 1) AND (t1.a = t1.c) AND ((t1.c = 1) OR (t1.c = 2)) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # OR formula : pushdown through equality, impossible WHERE @@ -1209,6 +1339,7 @@ HAVING (t1.c = 3) OR (t1.c = 2); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1216,6 +1347,7 @@ FROM t1 WHERE (t1.a = 1) AND (t1.a = t1.c) AND ((t1.c = 3) OR (t1.c = 2)) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # AND formula : pushdown through equality, impossible WHERE @@ -1228,6 +1360,7 @@ HAVING (t1.c = 3) AND (t1.a > 2) AND (t1.a = t1.c); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1235,6 +1368,7 @@ FROM t1 WHERE (t1.a = 1) AND (t1.c = 3) AND (t1.a > 2) AND (t1.a = t1.c) GROUP BY t1.a,t1.c; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; let $query= @@ -1246,6 +1380,7 @@ HAVING (t1.c = 3) AND (t1.a > 2) AND (t1.a = t1.c); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t1.a,MAX(t1.b),t1.c @@ -1253,6 +1388,7 @@ FROM t1 WHERE (t1.a = 1) AND (t1.c = 3) AND (t1.a > 2) AND (t1.a = t1.c) GROUP BY t1.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # AND formula with OR subformula : AND condition in WHERE @@ -1265,6 +1401,7 @@ HAVING (t3.a = t3.d) AND ((t3.d = 1) OR (t3.d > 1)); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t3.a,MAX(t3.c),t3.d @@ -1272,6 +1409,7 @@ FROM t3 WHERE (t3.a > 1) AND ((t3.c = 3) OR (t3.c < 2)) AND (t3.a = t3.d) AND ((t3.d = 1) OR (t3.d > 1)) GROUP BY t3.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # AND formula with OR subformula : AND condition in WHERE @@ -1284,6 +1422,7 @@ HAVING (t3.a = t3.d) AND (((t3.d = t3.c) AND (t3.c < 15)) OR (t3.d > 1)); eval $no_pushdown $query; eval $query; eval explain $query; +--source include/explain-no-costs.inc eval explain format=json $query; let $query= SELECT t3.a,t3.b,MAX(t3.c),t3.d @@ -1291,6 +1430,7 @@ FROM t3 WHERE (t3.a > 1) AND ((t3.c = 3) OR (t3.c < 2)) AND (t3.a = t3.d) AND (((t3.d = t3.c) AND (t3.c < 15)) OR (t3.d > 1)) GROUP BY t3.a; +--source include/explain-no-costs.inc eval $no_pushdown explain format=json $query; --echo # prepare statement @@ -1359,6 +1499,7 @@ select d1 from t1 eval $q1; eval explain extended $q1; +--source include/explain-no-costs.inc eval explain format=json $q1; delete from t1; @@ -1371,6 +1512,7 @@ select d1 from t1 eval $q2; eval explain extended $q2; +--source include/explain-no-costs.inc eval explain format=json $q2; drop table t1; @@ -1420,6 +1562,7 @@ INSERT INTO t2 VALUES (2),(3); let $q= SELECT a FROM t1 GROUP BY a HAVING a = 8 OR a = ( SELECT MIN(c) FROM t2 ); +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q; eval $q; @@ -1427,6 +1570,7 @@ let $q= SELECT a FROM t1 GROUP BY a,b HAVING ( a = 8 OR a = ( SELECT MIN(c) FROM t2 ) ) and b < 20; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q; eval $q; @@ -1434,12 +1578,14 @@ let $q= SELECT a FROM t1 GROUP BY a HAVING ( a = 8 OR a = ( SELECT MIN(c) FROM t2 ) ) and SUM(b) > 20; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q; eval $q; let $q= SELECT a FROM t1 GROUP BY a HAVING a = ( SELECT MIN(c) FROM t2 ); +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q; eval $q; diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result index f114fc6824e..906aed4f485 100644 --- a/mysql-test/main/in_subq_cond_pushdown.result +++ b/mysql-test/main/in_subq_cond_pushdown.result @@ -51,12 +51,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c < 25 and t1.a is not null and t1.c is not null" } @@ -71,11 +73,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.g)` < 25", "temporary_table": { "nested_loop": [ @@ -84,6 +88,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -150,12 +155,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c > 55 and t1.b < 4 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -170,11 +177,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.g)` > 55 and t2.f < 4", "temporary_table": { "nested_loop": [ @@ -183,6 +192,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -251,12 +261,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.c > 60 or t1.c < 25) and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -271,11 +283,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.g)` > 60 or `MAX(t2.g)` < 25", "temporary_table": { "nested_loop": [ @@ -284,6 +298,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -350,12 +365,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.c > 60 or t1.c < 25) and t1.b > 2 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -370,11 +387,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "(`MAX(t2.g)` > 60 or `MAX(t2.g)` < 25) and t2.f > 2", "temporary_table": { "nested_loop": [ @@ -383,6 +402,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -451,12 +471,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a < 2 or t1.d > 3) and t1.b > 1 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -471,11 +493,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "t2.f > 1", "temporary_table": { "nested_loop": [ @@ -484,6 +508,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -550,12 +575,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c > 20 and t1.a is not null and t1.c is not null" } @@ -570,11 +597,13 @@ EXPLAIN "used_key_parts": ["v1_x", "MAX(v1_y)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(v1_y)` > 20", "temporary_table": { "nested_loop": [ @@ -583,6 +612,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 8, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.x > 1 and t3.x <= 3" } @@ -650,12 +680,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 8, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.y > 20 and t3.x <= 3 and t3.y is not null" } @@ -666,6 +698,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -684,11 +717,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t3.y"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.g)` > 20", "temporary_table": { "nested_loop": [ @@ -697,6 +732,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -765,12 +801,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 2 and t1.a is not null and t1.c is not null" } @@ -785,11 +823,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -797,6 +837,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e < 2" } @@ -865,12 +906,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 2 and t1.a < 5 and t1.a is not null and t1.c is not null" } @@ -885,11 +928,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -897,6 +942,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e > 2 and t2.e < 5" } @@ -967,12 +1013,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a < 2 or t1.a >= 4) and t1.a is not null and t1.c is not null" } @@ -987,11 +1035,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -999,6 +1049,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and (t2.e < 2 or t2.e >= 4)" } @@ -1065,12 +1116,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a < 2 or t1.a = 5) and t1.b > 3 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -1085,11 +1138,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1097,6 +1152,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and (t2.e < 2 or t2.e = 5) and t2.f > 3" } @@ -1163,12 +1219,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a < 2 or t1.a = 5) and t1.b > 3 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -1183,11 +1241,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1195,6 +1255,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and (t2.e < 2 or t2.e = 5) and t2.f > 3" } @@ -1261,12 +1322,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.b < 3 or t1.d > 2) and t1.a < 2 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -1281,11 +1344,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1293,6 +1358,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e < 2" } @@ -1359,12 +1425,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a = 1 and t1.d = 1 and t1.c is not null" } @@ -1379,17 +1447,20 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["const", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e = 1" } @@ -1455,12 +1526,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.d = t1.a and t1.a > 1 and t1.a is not null and t1.c is not null" } @@ -1475,11 +1548,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1487,6 +1562,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e > 1" } @@ -1551,12 +1627,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 3 and t1.a is not null and t1.c is not null" } @@ -1571,11 +1649,13 @@ EXPLAIN "used_key_parts": ["v1_x", "MAX(v1_y)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1583,6 +1663,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 8, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.x > 1 and t3.x <= 3 and t3.x < 3" } @@ -1652,12 +1733,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 8, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.x < 2 and t3.y > 30 and t3.x <= 3 and t3.x is not null" } @@ -1668,6 +1751,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -1686,11 +1770,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t3.x", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1698,6 +1784,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e <= 3" } @@ -1765,12 +1852,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.b < 3 or t1.b = 4) and t1.a < 3 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -1785,11 +1874,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "t2.f < 3 or t2.f = 4", "temporary_table": { "nested_loop": [ @@ -1798,6 +1889,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e < 3" } @@ -1864,12 +1956,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a + t1.c > 41 and t1.a is not null and t1.c is not null" } @@ -1884,11 +1978,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "t2.e + `MAX(t2.g)` > 41", "temporary_table": { "nested_loop": [ @@ -1897,6 +1993,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -1965,12 +2062,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c - t1.a < 35 and t1.a is not null and t1.c is not null" } @@ -1985,11 +2084,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.g)` - t2.e < 35", "temporary_table": { "nested_loop": [ @@ -1998,6 +2099,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -2064,12 +2166,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c * t1.a > 100 and t1.a is not null and t1.c is not null" } @@ -2084,11 +2188,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.g)` * t2.e > 100", "temporary_table": { "nested_loop": [ @@ -2097,6 +2203,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -2167,12 +2274,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c / t1.a > 30 and t1.a is not null and t1.c is not null" } @@ -2187,11 +2296,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.g)` / t2.e > 30", "temporary_table": { "nested_loop": [ @@ -2200,6 +2311,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -2266,12 +2378,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c between 50 and 100 and t1.a is not null and t1.c is not null" } @@ -2286,11 +2400,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "`MAX(t2.g)` between 50 and 100", "temporary_table": { "nested_loop": [ @@ -2299,6 +2415,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -2365,12 +2482,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a + t1.b > 5 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -2385,11 +2504,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -2397,6 +2518,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e + t2.f > 5" } @@ -2463,12 +2585,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a - t1.b > 0 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -2483,11 +2607,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -2495,6 +2621,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e - t2.f > 0" } @@ -2561,12 +2688,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a * t1.b > 6 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -2581,11 +2710,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -2593,6 +2724,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e * t2.f > 6" } @@ -2661,12 +2793,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b / t1.a > 2 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -2681,11 +2815,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -2693,6 +2829,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.f / t2.e > 2" } @@ -2765,12 +2902,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a between 1 and 3 and t1.a is not null and t1.c is not null" } @@ -2785,11 +2924,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -2797,6 +2938,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e between 1 and 3" } @@ -2867,12 +3009,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c > 3 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -2887,11 +3031,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(v2.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "v2.max_g > 3", "temporary_table": { "nested_loop": [ @@ -2900,11 +3046,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.e < 5", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_g > 25", "filesort": { "sort_key": "t2.e", @@ -2915,6 +3063,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5" } @@ -2991,12 +3140,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -3011,11 +3162,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(v2.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -3023,11 +3176,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.e < 5 and v2.e > 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_g > 25", "filesort": { "sort_key": "t2.e", @@ -3038,6 +3193,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e > 1" } @@ -3115,12 +3271,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.c < 100 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -3135,11 +3293,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(v2.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "v2.max_g < 100", "temporary_table": { "nested_loop": [ @@ -3148,11 +3308,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.e < 5 and v2.e > 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_g > 25", "filesort": { "sort_key": "t2.e", @@ -3163,6 +3325,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.e > 1" } @@ -3263,12 +3426,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -3283,11 +3448,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -3295,11 +3462,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "d_tab.e < 5 and d_tab.e > 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_g > 25 and t2.e < 5 and t2.e > 1", "filesort": { "sort_key": "t2.f", @@ -3310,6 +3479,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3428,12 +3598,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -3448,11 +3620,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -3460,11 +3634,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "d_tab.e < 5 and d_tab.e > 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_g > 25 and t2.e < 5 and t2.e > 1", "filesort": { "sort_key": "t2.f", @@ -3475,6 +3651,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3594,12 +3771,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -3614,11 +3793,13 @@ EXPLAIN "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -3626,11 +3807,13 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "d_tab.e < 5 and d_tab.e > 1", "materialized": { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "max_g > 25 and t2.e < 5 and t2.e > 1", "filesort": { "sort_key": "t2.f", @@ -3641,6 +3824,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3742,12 +3926,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 8, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.x < 5 and t3.x is not null" } @@ -3762,11 +3948,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.x"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "d_tab.max_c < 70", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 70", "filesort": { "sort_key": "t1.a", @@ -3777,6 +3965,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a < 5 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -3791,11 +3980,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "t2.f < 5", "temporary_table": { "nested_loop": [ @@ -3804,6 +3995,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e > 1 and t2.e < 5" } @@ -3927,12 +4119,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 8, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t3.x < 5 and t3.x is not null" } @@ -3947,11 +4141,13 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.x"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "d_tab.max_c < 70", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "having_condition": "max_c < 70", "filesort": { "sort_key": "t1.a", @@ -3962,6 +4158,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a > 1 and t1.a < 5 and t1.a is not null and t1.b is not null and t1.c is not null" } @@ -3976,11 +4173,13 @@ EXPLAIN "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "having_condition": "t2.f < 5", "temporary_table": { "nested_loop": [ @@ -3989,6 +4188,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e > 1 and t2.e < 5" } @@ -4065,12 +4265,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 1 and t1.b is not null and t1.c is not null" } @@ -4085,11 +4287,13 @@ EXPLAIN "used_key_parts": ["f", "MAX(t2.g) OVER (PARTITION BY t2.f)"], "ref": ["test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -4105,6 +4309,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.f > 1" } @@ -4169,12 +4374,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 16, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b > 1 and t1.b is not null and t1.c is not null" } @@ -4192,12 +4399,14 @@ EXPLAIN ], "ref": ["test.t1.b", "test.t1.c"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.c = ``.`CAST(SUM(t2.g) OVER (PARTITION BY t2.f) AS INT)`", "materialized": { "unique": 1, "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -4213,6 +4422,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.e < 5 and t2.f > 1" } diff --git a/mysql-test/main/in_subq_cond_pushdown.test b/mysql-test/main/in_subq_cond_pushdown.test index 7763201cda1..8a12a2c5977 100644 --- a/mysql-test/main/in_subq_cond_pushdown.test +++ b/mysql-test/main/in_subq_cond_pushdown.test @@ -42,6 +42,7 @@ WHERE t1.c<25 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # extracted AND formula : pushing into HAVING @@ -60,6 +61,7 @@ WHERE t1.c>55 AND t1.b<4 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # extracted OR formula : pushing into HAVING @@ -78,6 +80,7 @@ WHERE (t1.c>60 OR t1.c<25) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # extracted AND-OR formula : pushing into HAVING @@ -96,6 +99,7 @@ WHERE ((t1.c>60 OR t1.c<25) AND t1.b>2) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into HAVING @@ -114,6 +118,7 @@ WHERE ((t1.a<2 OR t1.d>3) AND t1.b>1) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # using view IN subquery defINition : pushing into HAVING @@ -132,6 +137,7 @@ WHERE t1.c>20 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # using equality : pushing into WHERE @@ -150,6 +156,7 @@ WHERE t1.c>20 AND t1.c=v1_y AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE @@ -168,6 +175,7 @@ WHERE t1.a<2 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # extracted AND formula : pushing into WHERE @@ -186,6 +194,7 @@ WHERE t1.a>2 AND t1.a<5 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # extracted OR formula : pushing into WHERE @@ -204,6 +213,7 @@ WHERE (t1.a<2 OR t1.a>=4) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # extracted AND-OR formula : pushing into WHERE @@ -222,6 +232,7 @@ WHERE ((t1.a<2 OR t1.a=5) AND t1.b>3) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # extracted AND-OR formula : pushing into WHERE @@ -240,6 +251,7 @@ WHERE ((t1.a<2 OR t1.a=5) AND t1.b>3) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE @@ -258,6 +270,7 @@ WHERE ((t1.b<3 OR t1.d>2) AND t1.a<2) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # using equalities : pushing into WHERE @@ -276,6 +289,7 @@ WHERE t1.d=1 AND t1.a=t1.d AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # using equality : pushing into WHERE @@ -294,6 +308,7 @@ WHERE t1.d>1 AND t1.a=t1.d AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # using view IN subquery definition : pushing into WHERE @@ -312,6 +327,7 @@ WHERE t1.a<3 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # using equality : pushing into WHERE @@ -330,6 +346,7 @@ WHERE t1.a=v1_x AND v1_x<2 AND v1_y>30 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE @@ -349,6 +366,7 @@ WHERE ((t1.b<3 OR t1.b=4) AND t1.a<3) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using addition : pushing into HAVING @@ -367,6 +385,7 @@ WHERE (t1.a+t1.c>41) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using substitution : pushing into HAVING @@ -385,6 +404,7 @@ WHERE (t1.c-t1.a<35) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using multiplication : pushing into HAVING @@ -403,6 +423,7 @@ WHERE (t1.c*t1.a>100) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using division : pushing into HAVING @@ -421,6 +442,7 @@ WHERE (t1.c/t1.a>30) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using BETWEEN : pushing into HAVING @@ -439,6 +461,7 @@ WHERE (t1.c BETWEEN 50 AND 100) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using addition : pushing into WHERE @@ -457,6 +480,7 @@ WHERE (t1.a+t1.b > 5) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using substitution : pushing into WHERE @@ -475,6 +499,7 @@ WHERE (t1.a-t1.b > 0) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using multiplication : pushing into WHERE @@ -493,6 +518,7 @@ WHERE (t1.a*t1.b > 6) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using division : pushing into WHERE @@ -511,6 +537,7 @@ WHERE (t1.b/t1.a > 2) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula using BETWEEN : pushing into WHERE @@ -529,6 +556,7 @@ WHERE (t1.a BETWEEN 1 AND 3) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into HAVING of the IN subquery @@ -548,6 +576,7 @@ WHERE t1.c>3 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE of the IN subquery @@ -568,6 +597,7 @@ WHERE t1.a>1 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE and HAVING @@ -589,6 +619,7 @@ WHERE t1.a>1 AND t1.c<100 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE of the IN subquery @@ -615,6 +646,7 @@ WHERE t1.a>1 AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into HAVING of the derived table @@ -640,6 +672,7 @@ WHERE d_tab.a=t3.x AND d_tab.b>2; EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE of the derived table @@ -665,6 +698,7 @@ WHERE d_tab.a=t3.x AND d_tab.a<5; EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE and HAVING @@ -692,6 +726,7 @@ WHERE d_tab.a=t3.x AND d_tab.a<5 AND d_tab.max_c<70; EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE of the derived table @@ -717,6 +752,7 @@ WHERE d_tab.a=t3.x AND d_tab.a<5; EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE @@ -735,6 +771,7 @@ WHERE (t1.b>1) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; --echo # conjunctive subformula : pushing into WHERE @@ -753,6 +790,7 @@ WHERE (t1.b>1) AND EVAL $no_pushdown $query; EVAL $query; EVAL EXPLAIN $query; +--source include/explain-no-costs.inc EVAL EXPLAIN FORMAT=JSON $query; DROP TABLE t1,t2,t3; diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff index 8a1a251e88f..d89161d1c51 100644 --- a/mysql-test/main/innodb_ext_key,off.rdiff +++ b/mysql-test/main/innodb_ext_key,off.rdiff @@ -265,7 +265,7 @@ drop table t0,t1,t2; # # MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' -@@ -769,11 +769,12 @@ +@@ -770,11 +770,12 @@ { "table": { "table_name": "t1", @@ -279,9 +279,9 @@ + "used_key_parts": ["f2"], + "ref": ["const"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, - "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", -@@ -806,8 +807,8 @@ +@@ -809,8 +810,8 @@ "access_type": "range", "possible_keys": ["k1"], "key": "k1", @@ -290,5 +290,5 @@ + "key_length": "3007", + "used_key_parts": ["pk1", "f2"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, - "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result index ad27ad6b5ea..243717353a3 100644 --- a/mysql-test/main/innodb_ext_key.result +++ b/mysql-test/main/innodb_ext_key.result @@ -759,12 +759,13 @@ PRIMARY KEY (pk1,pk2), KEY(f2) ) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); -explain format= json +explain format=json select * from t1 force index(f2) where pk1 <= 5 and pk2 <=5 and f2 = 'abc' and f1 <= '3'; EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -775,6 +776,7 @@ EXPLAIN "key_length": "3070", "used_key_parts": ["f2", "pk1"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", "attached_condition": "t1.f1 <= '3'" @@ -793,12 +795,13 @@ PRIMARY KEY (pk1,pk2), KEY k1(pk1,f2) ) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); -explain format= json +explain format=json select * from t1 force index(k1) where f2 <= 5 and pk2 <=5 and pk1 = 'abc' and f1 <= '3'; EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -809,6 +812,7 @@ EXPLAIN "key_length": "3011", "used_key_parts": ["pk1", "f2", "pk2"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", "attached_condition": "t1.f1 <= '3'" diff --git a/mysql-test/main/innodb_ext_key.test b/mysql-test/main/innodb_ext_key.test index 2b868154bd3..b14a5d5cab3 100644 --- a/mysql-test/main/innodb_ext_key.test +++ b/mysql-test/main/innodb_ext_key.test @@ -614,7 +614,8 @@ CREATE TABLE t1 ( ) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); -explain format= json +--source include/explain-no-costs.inc +explain format=json select * from t1 force index(f2) where pk1 <= 5 and pk2 <=5 and f2 = 'abc' and f1 <= '3'; drop table t1; @@ -627,7 +628,8 @@ PRIMARY KEY (pk1,pk2), KEY k1(pk1,f2) ) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); -explain format= json +--source include/explain-no-costs.inc +explain format=json select * from t1 force index(k1) where f2 <= 5 and pk2 <=5 and pk1 = 'abc' and f1 <= '3'; drop table t1; diff --git a/mysql-test/main/intersect.result b/mysql-test/main/intersect.result index 299737e794b..614fbf2951e 100644 --- a/mysql-test/main/intersect.result +++ b/mysql-test/main/intersect.result @@ -51,12 +51,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -67,12 +69,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "INTERSECT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -83,12 +87,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -115,6 +121,7 @@ ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -125,6 +132,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -138,6 +146,7 @@ ANALYZE "query_block": { "select_id": 2, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -148,6 +157,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -161,6 +171,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -171,6 +182,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -192,6 +204,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -202,6 +215,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -217,6 +231,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -227,6 +242,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -240,6 +256,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -250,6 +267,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -263,6 +281,7 @@ ANALYZE "query_block": { "select_id": 4, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -273,6 +292,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -346,12 +366,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -362,12 +384,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "INTERSECT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -377,6 +401,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -407,6 +432,7 @@ ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -417,6 +443,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -430,6 +457,7 @@ ANALYZE "query_block": { "select_id": 2, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -440,6 +468,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -454,6 +483,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -481,6 +511,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -491,6 +522,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -506,6 +538,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -516,6 +549,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -529,6 +563,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -539,6 +574,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -553,6 +589,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/intersect.test b/mysql-test/main/intersect.test index 5e811f1f56d..30f99b20aa2 100644 --- a/mysql-test/main/intersect.test +++ b/mysql-test/main/intersect.test @@ -23,6 +23,7 @@ insert into t3 values (1,1),(2,2),(5,5); EXPLAIN (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3); EXPLAIN extended (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3); EXPLAIN extended select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a; +--source include/explain-no-costs.inc EXPLAIN format=json (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3); --source include/analyze-format.inc ANALYZE format=json (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3); @@ -43,6 +44,7 @@ EXPLAIN (select a,b from t1) intersect (select c,e from t2,t3); EXPLAIN extended (select a,b from t1) intersect (select c,e from t2,t3); EXPLAIN extended select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; set @@optimizer_switch='optimize_join_buffer_size=off'; +--source include/explain-no-costs.inc EXPLAIN format=json (select a,b from t1) intersect (select c,e from t2,t3); --source include/analyze-format.inc ANALYZE format=json (select a,b from t1) intersect (select c,e from t2,t3); diff --git a/mysql-test/main/intersect_all.result b/mysql-test/main/intersect_all.result index e47a8872211..7b5bc2c2b95 100644 --- a/mysql-test/main/intersect_all.result +++ b/mysql-test/main/intersect_all.result @@ -63,12 +63,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -79,12 +81,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "INTERSECT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -95,12 +99,14 @@ EXPLAIN "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -127,6 +133,7 @@ ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -137,6 +144,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -150,6 +158,7 @@ ANALYZE "query_block": { "select_id": 2, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -160,6 +169,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -173,6 +183,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -183,6 +194,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -204,6 +216,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -214,6 +227,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -229,6 +243,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -239,6 +254,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -252,6 +268,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -262,6 +279,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -275,6 +293,7 @@ ANALYZE "query_block": { "select_id": 4, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -285,6 +304,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -377,12 +397,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 6, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -393,12 +415,14 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "INTERSECT", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -408,6 +432,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -438,6 +463,7 @@ ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -448,6 +474,7 @@ ANALYZE "r_loops": 1, "rows": 6, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -461,6 +488,7 @@ ANALYZE "query_block": { "select_id": 2, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -471,6 +499,7 @@ ANALYZE "r_loops": 1, "rows": 5, "r_rows": 5, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -485,6 +514,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 7, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -512,6 +542,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -522,6 +553,7 @@ ANALYZE "r_loops": 1, "rows": 6, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -537,6 +569,7 @@ ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -547,6 +580,7 @@ ANALYZE "r_loops": 1, "rows": 6, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -560,6 +594,7 @@ ANALYZE "query_block": { "select_id": 3, "operation": "INTERSECT", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -570,6 +605,7 @@ ANALYZE "r_loops": 1, "rows": 5, "r_rows": 5, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -584,6 +620,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 7, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/intersect_all.test b/mysql-test/main/intersect_all.test index 5d2b038fde9..769b25393dd 100644 --- a/mysql-test/main/intersect_all.test +++ b/mysql-test/main/intersect_all.test @@ -22,6 +22,7 @@ insert into t3 values (1,1),(2,2),(5,5),(2,2); EXPLAIN (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); EXPLAIN extended (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); EXPLAIN extended select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a; +--source include/explain-no-costs.inc EXPLAIN format=json (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); --source include/analyze-format.inc ANALYZE format=json (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); @@ -50,6 +51,7 @@ insert into t3 values (2,2); EXPLAIN (select a,b from t1) intersect all (select c,e from t2,t3); EXPLAIN extended (select a,b from t1) intersect all (select c,e from t2,t3); EXPLAIN extended select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a; +--source include/explain-no-costs.inc EXPLAIN format=json (select a,b from t1) intersect all (select c,e from t2,t3); --source include/analyze-format.inc ANALYZE format=json (select a,b from t1) intersect all (select c,e from t2,t3); @@ -325,4 +327,4 @@ select * from t2 where a < 5 intersect all select * from t3 where a < 5; -drop table t1,t2,t3; \ No newline at end of file +drop table t1,t2,t3; diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index 0f7ad1d23f7..f5baec125e8 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -6254,6 +6254,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -6264,6 +6265,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["a"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "a.a <= 10", "using_index": true @@ -6279,6 +6281,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["kp1", "kp2"], "rows": 836, + "cost": "COST_REPLACED", "filtered": 9.090909004, "index_condition": "b.kp2 <= 10", "attached_condition": "b.kp2 <= 10 and b.col1 + 1 < 33333" diff --git a/mysql-test/main/join_cache.test b/mysql-test/main/join_cache.test index c4401997b1d..ad2eacbe2bb 100644 --- a/mysql-test/main/join_cache.test +++ b/mysql-test/main/join_cache.test @@ -4245,6 +4245,7 @@ analyze table t3; --echo # The following must have "B.col1 + 1 < 33333" attached to table B --echo # and not to the block-nl-join node: +--source include/explain-no-costs.inc explain format=json select * from t1 a, t3 b diff --git a/mysql-test/main/multi_update.test b/mysql-test/main/multi_update.test index 54c64918e03..6ec3de6a78b 100644 --- a/mysql-test/main/multi_update.test +++ b/mysql-test/main/multi_update.test @@ -1121,12 +1121,15 @@ INSERT INTO t1 (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2); INSERT INTO t2 (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2); --echo # Expecting partition "Current" +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON UPDATE t2 JOIN t1 USING(a) SET t2.part=3 WHERE t2.part=0 AND t1.part=0; --echo # Expecting partition "Relevant" +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON UPDATE t2 JOIN t1 USING(a) SET t2.part=2 WHERE t2.part=1 AND t1.part=1; --echo # Expecting partition "Archive" +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON UPDATE t2 JOIN t1 USING(a) SET t2.part=3 WHERE t2.part=2 AND t1.part=2; DROP TABLES t1, t2; diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 70c59092dbd..5498271597c 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -10693,6 +10693,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": 1.235599899, "nested_loop": [ { "table": { @@ -10703,6 +10704,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["start_date", "end_date"], "rows": 1000, + "cost": 1.235599899, "filtered": 100, "index_condition": "t1.start_date >= '2019-02-10' and t1.end_date < '2019-04-01'" } @@ -12374,12 +12376,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": 2.30309056, "nested_loop": [ { "table": { "table_name": "three", "access_type": "ALL", "rows": 3, + "cost": 0.010504815, "filtered": 100, "attached_condition": "three.a is not null" } @@ -12402,6 +12406,7 @@ EXPLAIN "selectivity_pct": 43.12 }, "rows": 1000, + "cost": 2.292585745, "filtered": 43.11999893, "attached_condition": "t1.b < 5000 and t1.c < 1000" } @@ -12415,12 +12420,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": 1.712236739, "nested_loop": [ { "table": { "table_name": "three", "access_type": "ALL", "rows": 3, + "cost": 0.010504815, "filtered": 100 } }, @@ -12431,6 +12438,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["a", "b"], "rows": 10000, + "cost": 1.701731924, "filtered": 4.307688236, "attached_condition": "t1.b < 5000 and t1.c < 1000" }, diff --git a/mysql-test/main/opt_trace_ucs2.result b/mysql-test/main/opt_trace_ucs2.result index 558fcf4700b..63f7cf4652e 100644 --- a/mysql-test/main/opt_trace_ucs2.result +++ b/mysql-test/main/opt_trace_ucs2.result @@ -7,6 +7,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -17,6 +18,7 @@ EXPLAIN "key_length": "21", "used_key_parts": ["col1"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.col1 >= 'a'" } diff --git a/mysql-test/main/opt_trace_ucs2.test b/mysql-test/main/opt_trace_ucs2.test index 1a79ea9780e..7e06955d666 100644 --- a/mysql-test/main/opt_trace_ucs2.test +++ b/mysql-test/main/opt_trace_ucs2.test @@ -5,6 +5,7 @@ create or replace table t1 (col1 char(10) character set ucs2, filler char(100), insert into t1 values ('a', 'a'); insert into t1 values ('a', 'a'); set optimizer_trace=1; +--source include/explain-no-costs.inc explain format=json select * from t1 force index(col1) where col1 >='a'; #enable after fix MDEV-27871 --disable_view_protocol diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index cb5459532ee..f9c0d59e66a 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -1564,6 +1564,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1589,6 +1590,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 50, @@ -3455,6 +3457,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -3475,6 +3478,7 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -3804,6 +3808,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -3824,6 +3829,7 @@ ANALYZE "r_loops": 1, "rows": 100, "r_rows": 100, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -3970,6 +3976,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -3990,6 +3997,7 @@ ANALYZE "r_loops": 1, "rows": 5, "r_rows": 5, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4019,6 +4027,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -4039,6 +4048,7 @@ ANALYZE "r_loops": 1, "rows": 6, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4074,6 +4084,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -4094,6 +4105,7 @@ ANALYZE "r_loops": 1, "rows": 6, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4143,6 +4155,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -4163,6 +4176,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4325,6 +4339,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -4335,6 +4350,7 @@ ANALYZE "r_loops": 1, "rows": 50, "r_rows": 50, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4349,6 +4365,7 @@ ANALYZE "r_hit_ratio": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 50, "r_total_time_ms": "REPLACED", "filesort": { @@ -4368,6 +4385,7 @@ ANALYZE "r_loops": 50, "rows": 50, "r_rows": 50, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -4466,6 +4484,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -4476,6 +4495,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["a"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "using_index": true } @@ -4501,6 +4521,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 97, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b = 3" } @@ -4537,6 +4558,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -4547,6 +4569,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["PRIMARY"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -4573,6 +4596,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 97, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.b = 3" } diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index c336a6784a5..a292e468ef2 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -2692,6 +2692,7 @@ let $query= SELECT t1.a ORDER BY t1.a DESC; eval EXPLAIN $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; eval $query; @@ -2701,6 +2702,7 @@ let $query= SELECT t1.a, group_concat(t1.b) GROUP BY t1.a DESC; eval EXPLAIN $query; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $query; eval $query; DROP TABLE t1, t2; diff --git a/mysql-test/main/order_by_pack_big.result b/mysql-test/main/order_by_pack_big.result index 6b33d7d8202..adc7fc807a0 100644 --- a/mysql-test/main/order_by_pack_big.result +++ b/mysql-test/main/order_by_pack_big.result @@ -94,6 +94,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -114,6 +115,7 @@ ANALYZE "r_loops": 1, "rows": 10000, "r_rows": 10000, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -258,6 +260,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -279,6 +282,7 @@ ANALYZE "r_loops": 1, "rows": 10000, "r_rows": 10000, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -420,6 +424,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -440,6 +445,7 @@ ANALYZE "r_loops": 1, "rows": 10000, "r_rows": 10000, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -476,6 +482,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -496,6 +503,7 @@ ANALYZE "r_loops": 1, "rows": 10000, "r_rows": 10000, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index 34c0c27f897..c1caf85fab0 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -2424,6 +2424,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2434,6 +2435,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["a", "b"], "rows": 6, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t1.b) in (((2,3)),((3,3)),((8,8)),((7,7)))" } @@ -2488,6 +2490,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2498,6 +2501,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t1.b + t1.a) in (((4,9)),((8,8)),((7,7)))" } @@ -2518,6 +2522,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2528,6 +2533,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t1.b) in ((4,t1.a - 1),(8,t1.a + 8),(7,t1.a + 7))" } @@ -2562,6 +2568,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2580,6 +2587,7 @@ EXPLAIN "selectivity_pct": 60 }, "rows": 3, + "cost": "COST_REPLACED", "filtered": 60, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((3,3)),((7,7)),((2,2)))" @@ -2595,6 +2603,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.d"], "rows": 8, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2648,6 +2657,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2666,6 +2676,7 @@ EXPLAIN "selectivity_pct": 14.42307692 }, "rows": 8, + "cost": "COST_REPLACED", "filtered": 14.42307663, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((3,3)),((7,7)),((8,8))) and octet_length(t2.f) = 1" @@ -2681,6 +2692,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.d"], "rows": 8, + "cost": "COST_REPLACED", "filtered": 73.17073059 } } @@ -2759,6 +2771,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2777,6 +2790,7 @@ EXPLAIN "selectivity_pct": 6.730769231 }, "rows": 7, + "cost": "COST_REPLACED", "filtered": 6.730769157, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((4,4)),((7,7)),((8,8))) and octet_length(t2.f) = 1" @@ -2792,6 +2806,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.d"], "rows": 11, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2823,6 +2838,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2833,6 +2849,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["d", "e"], "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((4,4)),((7,7)),((8,8))) and octet_length(t2.f) = 1" @@ -2848,6 +2865,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.d"], "rows": 11, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2878,6 +2896,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2888,6 +2907,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 15, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a is not null" } @@ -2902,6 +2922,7 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["test.t1.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t2.e) in ((4,t1.a + 1),(7,t1.a + 1),(8,t1.a + 1)) and octet_length(t2.f) = 1" } @@ -2941,6 +2962,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2948,6 +2970,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 144, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a is not null" } @@ -2962,6 +2985,7 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["test.t1.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),((7,7)),((8,8))) and octet_length(t2.f) = 1" } @@ -2995,6 +3019,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -3005,6 +3030,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a is not null", "attached_condition": "(t1.a,2) in (((2,2)),((7,7)),((8,8))) and octet_length(t1.c) = 1" @@ -3020,6 +3046,7 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["test.t1.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "octet_length(t2.f) = 1" } @@ -3078,6 +3105,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -3101,6 +3129,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a is not null", "attached_condition": "(t1.a,1 + 1) in (((2,2)),((7,7)),((8,8))) and octet_length(t1.c) = 1" @@ -3116,6 +3145,7 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["test.t1.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "octet_length(t2.f) = 1" } diff --git a/mysql-test/main/range.test b/mysql-test/main/range.test index 2dc110c1422..c2cc794b485 100644 --- a/mysql-test/main/range.test +++ b/mysql-test/main/range.test @@ -1920,6 +1920,7 @@ insert into t1 values let $q1= select * from t1 where (a,b) IN ((2, 3),(3,3),(8,8),(7,7)); eval explain $q1; +--source include/explain-no-costs.inc eval explain format=json $q1; eval $q1; eval prepare stmt from "$q1"; @@ -1931,6 +1932,7 @@ deallocate prepare stmt; let $q2= select * from t1 where (a,b+a) IN ((4,9),(8,8),(7,7)); eval explain $q2; +--source include/explain-no-costs.inc eval explain format=json $q2; eval $q2; @@ -1938,6 +1940,7 @@ eval $q2; let $q3= select * from t1 where (a,b) IN ((4,a-1),(8,a+8),(7,a+7)); eval explain $q3; +--source include/explain-no-costs.inc eval explain format=json $q3; eval $q3; @@ -1961,6 +1964,7 @@ let $q4= select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(2,2)); eval explain $q4; +--source include/explain-no-costs.inc eval explain format=json $q4; eval $q4; @@ -1986,6 +1990,7 @@ let $q5= select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(8,8)) and length(f) = 1; eval explain $q5; +--source include/explain-no-costs.inc eval explain format=json $q5; --sorted_result eval $q5; @@ -2004,6 +2009,7 @@ let $q6= select * from t1,t2 where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; eval explain $q6; +--source include/explain-no-costs.inc eval explain format=json $q6; --sorted_result eval $q6; @@ -2016,6 +2022,7 @@ let $q7= select * from t1,t2 where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; eval explain $q7; +--source include/explain-no-costs.inc eval explain format=json $q7; eval $q7; @@ -2025,6 +2032,7 @@ let $q8= select * from t1,t2 where a = d and (a,e) in ((4,d+1),(7,d+1),(8,d+1)) and length(f) = 1; eval explain $q8; +--source include/explain-no-costs.inc eval explain format=json $q8; --sorted_result eval $q8; @@ -2035,6 +2043,7 @@ let $q9= select * from t1,t2 where a = d and (a,e) in ((e,d+1),(7,7),(8,8)) and length(f) = 1; eval explain $q9; +--source include/explain-no-costs.inc eval explain format=json $q9; --sorted_result eval $q9; @@ -2046,6 +2055,7 @@ select * from t1,t2 where a = d and (a,2) in ((2,2),(7,7),(8,8)) and length(c) = 1 and length(f) = 1; eval explain $q10; +--source include/explain-no-costs.inc eval explain format=json $q10; eval $q10; eval prepare stmt from "$q10"; @@ -2066,6 +2076,7 @@ select * from t1,t2,t3 (a,v+1) in ((2,2),(7,7),(8,8)) and length(c) = 1 and length(f) = 1; eval explain $q11; +--source include/explain-no-costs.inc eval explain format=json $q11; eval $q11; diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result index 1373faedf8e..5c746efb8f3 100644 --- a/mysql-test/main/range_mrr_icp.result +++ b/mysql-test/main/range_mrr_icp.result @@ -2427,6 +2427,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2437,6 +2438,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["a", "b"], "rows": 6, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t1.b) in (((2,3)),((3,3)),((8,8)),((7,7)))", "mrr_type": "Rowid-ordered scan" @@ -2492,6 +2494,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2502,6 +2505,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t1.b + t1.a) in (((4,9)),((8,8)),((7,7)))", "mrr_type": "Rowid-ordered scan" @@ -2523,6 +2527,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2533,6 +2538,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t1.b) in ((4,t1.a - 1),(8,t1.a + 8),(7,t1.a + 7))", "mrr_type": "Rowid-ordered scan" @@ -2568,6 +2574,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2578,6 +2585,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 60, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((3,3)),((7,7)),((2,2)))", @@ -2594,6 +2602,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.d"], "rows": 8, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2647,6 +2656,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2657,6 +2667,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "rows": 8, + "cost": "COST_REPLACED", "filtered": 14.42307663, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((3,3)),((7,7)),((8,8))) and octet_length(t2.f) = 1", @@ -2673,6 +2684,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.d"], "rows": 8, + "cost": "COST_REPLACED", "filtered": 73.17073059 } } @@ -2751,6 +2763,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2761,6 +2774,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "rows": 7, + "cost": "COST_REPLACED", "filtered": 6.730769157, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((4,4)),((7,7)),((8,8))) and octet_length(t2.f) = 1", @@ -2777,6 +2791,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.d"], "rows": 11, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2808,6 +2823,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2818,6 +2834,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["d", "e"], "rows": 5, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t2.d is not null", "attached_condition": "(t2.d,t2.e) in (((4,4)),((7,7)),((8,8))) and octet_length(t2.f) = 1", @@ -2834,6 +2851,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.d"], "rows": 11, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2864,6 +2882,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2874,6 +2893,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 15, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a is not null", "mrr_type": "Rowid-ordered scan" @@ -2889,6 +2909,7 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["test.t1.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t2.e) in ((4,t1.a + 1),(7,t1.a + 1),(8,t1.a + 1)) and octet_length(t2.f) = 1" } @@ -2928,6 +2949,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2935,6 +2957,7 @@ EXPLAIN "access_type": "ALL", "possible_keys": ["idx"], "rows": 144, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a is not null" } @@ -2949,6 +2972,7 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["test.t1.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),((7,7)),((8,8))) and octet_length(t2.f) = 1" } @@ -2982,6 +3006,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2992,6 +3017,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a is not null", "attached_condition": "(t1.a,2) in (((2,2)),((7,7)),((8,8))) and octet_length(t1.c) = 1", @@ -3008,6 +3034,7 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["test.t1.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "octet_length(t2.f) = 1" } @@ -3066,6 +3093,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -3089,6 +3117,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 12, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a is not null", "attached_condition": "(t1.a,1 + 1) in (((2,2)),((7,7)),((8,8))) and octet_length(t1.c) = 1", @@ -3105,6 +3134,7 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["test.t1.a"], "rows": 3, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "octet_length(t2.f) = 1" } diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index 0b79e5fff6a..8765b72d281 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -77,6 +77,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -95,6 +96,7 @@ EXPLAIN "selectivity_pct": 11.69025812 }, "rows": 509, + "cost": "COST_REPLACED", "filtered": 11.69025803, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -118,6 +120,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -145,6 +148,7 @@ ANALYZE "r_loops": 1, "rows": 509, "r_rows": 60, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 11.69025803, @@ -232,6 +236,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -242,6 +247,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 509, + "cost": "COST_REPLACED", "filtered": 11.69025803, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -265,6 +271,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -279,6 +286,7 @@ ANALYZE "r_loops": 1, "rows": 509, "r_rows": 510, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 11.69025803, @@ -369,6 +377,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -379,6 +388,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totalprice"], "rows": 69, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" } @@ -406,6 +416,7 @@ EXPLAIN "selectivity_pct": 1.631973356 }, "rows": 4, + "cost": "COST_REPLACED", "filtered": 1.631973386, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" } @@ -431,6 +442,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -445,6 +457,7 @@ ANALYZE "r_loops": 1, "rows": 69, "r_rows": 71, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -482,6 +495,7 @@ ANALYZE "r_loops": 71, "rows": 4, "r_rows": 0.154929577, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 1.631973386, @@ -523,6 +537,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -538,6 +553,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 98, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" } @@ -552,6 +568,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 4.599999905, "attached_condition": "orders.o_totalprice between 200000 and 230000" } @@ -577,6 +594,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -596,6 +614,7 @@ ANALYZE "r_loops": 1, "rows": 98, "r_rows": 98, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -615,6 +634,7 @@ ANALYZE "r_loops": 98, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 4.599999905, @@ -658,6 +678,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -682,6 +703,7 @@ EXPLAIN "selectivity_pct": 11.69025812 }, "rows": 509, + "cost": "COST_REPLACED", "filtered": 11.69025803, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -705,6 +727,7 @@ EXPLAIN "selectivity_pct": 9.266666667 }, "rows": 1, + "cost": "COST_REPLACED", "filtered": 9.266666412, "attached_condition": "orders.o_totalprice between 180000 and 230000" } @@ -732,6 +755,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -765,6 +789,7 @@ ANALYZE "r_loops": 1, "rows": 509, "r_rows": 60, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 11.69025803, @@ -798,6 +823,7 @@ ANALYZE "r_loops": 60, "rows": 1, "r_rows": 0.266666667, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 9.266666412, @@ -847,6 +873,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -863,6 +890,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 509, + "cost": "COST_REPLACED", "filtered": 11.69025803, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -878,6 +906,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 9.266666412, "attached_condition": "orders.o_totalprice between 180000 and 230000" } @@ -905,6 +934,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -925,6 +955,7 @@ ANALYZE "r_loops": 1, "rows": 509, "r_rows": 510, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 11.69025803, @@ -945,6 +976,7 @@ ANALYZE "r_loops": 60, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 9.266666412, @@ -1000,6 +1032,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1010,6 +1043,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totalprice"], "rows": 69, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" } @@ -1037,6 +1071,7 @@ EXPLAIN "selectivity_pct": 8.476269775 }, "rows": 4, + "cost": "COST_REPLACED", "filtered": 8.476269722, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } @@ -1062,6 +1097,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1076,6 +1112,7 @@ ANALYZE "r_loops": 1, "rows": 69, "r_rows": 71, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1113,6 +1150,7 @@ ANALYZE "r_loops": 71, "rows": 4, "r_rows": 0.521126761, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.476269722, @@ -1180,6 +1218,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1190,6 +1229,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totalprice"], "rows": 69, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" } @@ -1209,6 +1249,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 8.476269722, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } @@ -1234,6 +1275,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1248,6 +1290,7 @@ ANALYZE "r_loops": 1, "rows": 69, "r_rows": 71, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1272,6 +1315,7 @@ ANALYZE "r_loops": 71, "rows": 4, "r_rows": 6.704225352, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.476269722, @@ -1350,6 +1394,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1366,6 +1411,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, + "cost": "COST_REPLACED", "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" @@ -1381,6 +1427,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 7.466666698, "attached_condition": "orders.o_totalprice between 200000 and 250000" } @@ -1410,6 +1457,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1430,6 +1478,7 @@ ANALYZE "r_loops": 1, "rows": 18, "r_rows": 18, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 0.566194832, @@ -1450,6 +1499,7 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 7.466666698, @@ -1487,6 +1537,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1503,6 +1554,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, + "cost": "COST_REPLACED", "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" @@ -1518,6 +1570,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 7.466666698, "attached_condition": "orders.o_totalprice between 200000 and 250000" } @@ -1547,6 +1600,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1567,6 +1621,7 @@ ANALYZE "r_loops": 1, "rows": 18, "r_rows": 18, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 0.566194832, @@ -1587,6 +1642,7 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 7.466666698, @@ -1631,6 +1687,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1641,6 +1698,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 39, + "cost": "COST_REPLACED", "filtered": 3.200000048, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" @@ -1669,6 +1727,7 @@ EXPLAIN "selectivity_pct": 3.04746045 }, "rows": 4, + "cost": "COST_REPLACED", "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1698,6 +1757,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1712,6 +1772,7 @@ ANALYZE "r_loops": 1, "rows": 39, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 3.200000048, @@ -1750,6 +1811,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 3.047460556, @@ -1790,6 +1852,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1800,6 +1863,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 39, + "cost": "COST_REPLACED", "filtered": 3.200000048, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" @@ -1820,6 +1884,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1849,6 +1914,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1863,6 +1929,7 @@ ANALYZE "r_loops": 1, "rows": 39, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 3.200000048, @@ -1888,6 +1955,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 3.047460556, @@ -1931,6 +1999,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -1946,6 +2015,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 39, + "cost": "REPLACED", "filtered": "REPLACED", "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" @@ -1966,6 +2036,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "REPLACED", "filtered": "REPLACED", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1995,6 +2066,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -2014,6 +2086,7 @@ ANALYZE "r_loops": 1, "rows": 39, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -2039,6 +2112,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -2079,6 +2153,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -2094,6 +2169,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 39, + "cost": "REPLACED", "filtered": "REPLACED", "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" @@ -2114,6 +2190,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "REPLACED", "filtered": "REPLACED", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -2143,6 +2220,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -2162,6 +2240,7 @@ ANALYZE "r_loops": 1, "rows": 39, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -2187,6 +2266,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", diff --git a/mysql-test/main/rowid_filter.test b/mysql-test/main/rowid_filter.test index 8ba4cc64845..bbf0334fbbf 100644 --- a/mysql-test/main/rowid_filter.test +++ b/mysql-test/main/rowid_filter.test @@ -55,6 +55,7 @@ SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem l_quantity > 45; eval $with_filter EXPLAIN $q1; +--source include/explain-no-costs.inc eval $with_filter EXPLAIN FORMAT=JSON $q1; eval $with_filter ANALYZE $q1; --source include/analyze-format.inc @@ -63,6 +64,7 @@ eval $with_filter ANALYZE FORMAT=JSON $q1; eval $with_filter $q1; eval $without_filter EXPLAIN $q1; +--source include/explain-no-costs.inc eval $without_filter EXPLAIN FORMAT=JSON $q1; eval $without_filter ANALYZE $q1; --source include/analyze-format.inc @@ -77,6 +79,7 @@ SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice o_totalprice between 200000 and 230000; eval $with_filter EXPLAIN $q2; +--source include/explain-no-costs.inc eval $with_filter EXPLAIN FORMAT=JSON $q2; eval $with_filter ANALYZE $q2; --source include/analyze-format.inc @@ -85,6 +88,7 @@ eval $with_filter ANALYZE FORMAT=JSON $q2; eval $with_filter $q2; eval $without_filter EXPLAIN $q2; +--source include/explain-no-costs.inc eval $without_filter EXPLAIN FORMAT=JSON $q2; eval $without_filter ANALYZE $q2; --source include/analyze-format.inc @@ -100,6 +104,7 @@ SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice o_totalprice between 180000 and 230000; eval $with_filter EXPLAIN $q3; +--source include/explain-no-costs.inc eval $with_filter EXPLAIN FORMAT=JSON $q3; eval $with_filter ANALYZE $q3; --source include/analyze-format.inc @@ -108,6 +113,7 @@ eval $with_filter ANALYZE FORMAT=JSON $q3; eval $with_filter $q3; eval $without_filter EXPLAIN $q3; +--source include/explain-no-costs.inc eval $without_filter EXPLAIN FORMAT=JSON $q3; eval $without_filter ANALYZE $q3; --source include/analyze-format.inc @@ -129,6 +135,7 @@ SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice o_totalprice between 200000 and 230000; eval $with_filter EXPLAIN $q4; +--source include/explain-no-costs.inc eval $with_filter EXPLAIN FORMAT=JSON $q4; eval $with_filter ANALYZE $q4; --source include/analyze-format.inc @@ -137,6 +144,7 @@ eval $with_filter ANALYZE FORMAT=JSON $q4; eval $with_filter $q4; eval $without_filter EXPLAIN $q4; +--source include/explain-no-costs.inc eval $without_filter EXPLAIN FORMAT=JSON $q4; eval $without_filter ANALYZE $q4; --source include/analyze-format.inc @@ -162,6 +170,7 @@ WHERE o_orderkey=l_orderkey AND o_totalprice BETWEEN 200000 AND 250000; eval $with_filter EXPLAIN $q5; +--source include/explain-no-costs.inc eval $with_filter EXPLAIN FORMAT=JSON $q5; eval $with_filter ANALYZE $q5; --source include/analyze-format.inc @@ -170,6 +179,7 @@ eval $with_filter ANALYZE FORMAT=JSON $q5; eval $with_filter $q5; eval $without_filter EXPLAIN $q5; +--source include/explain-no-costs.inc eval $without_filter EXPLAIN FORMAT=JSON $q5; eval $without_filter ANALYZE $q5; --source include/analyze-format.inc @@ -195,6 +205,7 @@ WHERE o_orderkey=l_orderkey AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; eval $with_filter EXPLAIN $q6; +--source include/explain-no-costs.inc eval $with_filter EXPLAIN FORMAT=JSON $q6; eval $with_filter ANALYZE $q6; --source include/analyze-format.inc @@ -203,6 +214,7 @@ eval $with_filter ANALYZE FORMAT=JSON $q6; eval $with_filter $q6; eval $without_filter EXPLAIN $q6; +--source include/explain-no-costs.inc eval $without_filter EXPLAIN FORMAT=JSON $q6; eval $without_filter ANALYZE $q6; --source include/analyze-format.inc @@ -223,21 +235,21 @@ WHERE o_orderkey=l_orderkey AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; eval $with_filter EXPLAIN $q7; ---replace_regex /"filtered": [0-9e\.\-+]*,/"filtered": "REPLACED",/ +--source include/explain-no-costs-filtered.inc eval $with_filter EXPLAIN FORMAT=JSON $q7; --replace_column 11 # eval $with_filter ANALYZE $q7; ---replace_regex /("(r_(total|table|other)_time_ms|r_buffer_size|r_filling_time_ms|filtered)": )[^, \n]*/\1"REPLACED"/ +--source include/analyze-no-filtered.inc eval $with_filter ANALYZE FORMAT=JSON $q7; --sorted_result eval $with_filter $q7; eval $without_filter EXPLAIN $q7; ---replace_regex /"filtered": [0-9e\.\-+]*,/"filtered": "REPLACED",/ +--source include/explain-no-costs-filtered.inc eval $without_filter EXPLAIN FORMAT=JSON $q7; --replace_column 11 # eval $without_filter ANALYZE $q7; ---replace_regex /("(r_(total|table|other)_time_ms|r_buffer_size|r_filling_time_ms|filtered)": )[^, \n]*/\1"REPLACED"/ +--source include/analyze-no-filtered.inc eval $without_filter ANALYZE FORMAT=JSON $q7; --sorted_result eval $without_filter $q7; diff --git a/mysql-test/main/rowid_filter_aria.result b/mysql-test/main/rowid_filter_aria.result index 8cc3d3be008..23c6d1567fd 100644 --- a/mysql-test/main/rowid_filter_aria.result +++ b/mysql-test/main/rowid_filter_aria.result @@ -78,6 +78,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -96,6 +97,7 @@ EXPLAIN "selectivity_pct": 15.80349709 }, "rows": 482, + "cost": "COST_REPLACED", "filtered": 15.80349731, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -119,6 +121,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -146,6 +149,7 @@ ANALYZE "r_loops": 1, "rows": 482, "r_rows": 60, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 15.80349731, @@ -233,6 +237,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -243,6 +248,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 482, + "cost": "COST_REPLACED", "filtered": 15.80349731, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -266,6 +272,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -280,6 +287,7 @@ ANALYZE "r_loops": 1, "rows": 482, "r_rows": 510, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 15.80349731, @@ -370,6 +378,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -385,6 +394,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 92, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" } @@ -407,6 +417,7 @@ EXPLAIN "selectivity_pct": 7.066666667 }, "rows": 1, + "cost": "COST_REPLACED", "filtered": 7.066666603, "attached_condition": "orders.o_totalprice between 200000 and 230000" } @@ -432,6 +443,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -451,6 +463,7 @@ ANALYZE "r_loops": 1, "rows": 92, "r_rows": 98, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -483,6 +496,7 @@ ANALYZE "r_loops": 98, "rows": 1, "r_rows": 0.112244898, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 7.066666603, @@ -524,6 +538,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -539,6 +554,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 92, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" } @@ -553,6 +569,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 7.066666603, "attached_condition": "orders.o_totalprice between 200000 and 230000" } @@ -578,6 +595,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -597,6 +615,7 @@ ANALYZE "r_loops": 1, "rows": 92, "r_rows": 98, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -616,6 +635,7 @@ ANALYZE "r_loops": 98, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 7.066666603, @@ -659,6 +679,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -683,6 +704,7 @@ EXPLAIN "selectivity_pct": 15.80349709 }, "rows": 482, + "cost": "COST_REPLACED", "filtered": 15.80349731, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -706,6 +728,7 @@ EXPLAIN "selectivity_pct": 14.4 }, "rows": 1, + "cost": "COST_REPLACED", "filtered": 14.39999962, "attached_condition": "orders.o_totalprice between 180000 and 230000" } @@ -733,6 +756,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -766,6 +790,7 @@ ANALYZE "r_loops": 1, "rows": 482, "r_rows": 60, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 15.80349731, @@ -799,6 +824,7 @@ ANALYZE "r_loops": 60, "rows": 1, "r_rows": 0.266666667, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 14.39999962, @@ -848,6 +874,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -864,6 +891,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 482, + "cost": "COST_REPLACED", "filtered": 15.80349731, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -879,6 +907,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 14.39999962, "attached_condition": "orders.o_totalprice between 180000 and 230000" } @@ -906,6 +935,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -926,6 +956,7 @@ ANALYZE "r_loops": 1, "rows": 482, "r_rows": 510, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 15.80349731, @@ -946,6 +977,7 @@ ANALYZE "r_loops": 60, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 14.39999962, @@ -1001,6 +1033,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1011,6 +1044,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totalprice"], "rows": 106, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" } @@ -1038,6 +1072,7 @@ EXPLAIN "selectivity_pct": 8.026644463 }, "rows": 4, + "cost": "COST_REPLACED", "filtered": 8.026644707, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } @@ -1063,6 +1098,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1077,6 +1113,7 @@ ANALYZE "r_loops": 1, "rows": 106, "r_rows": 71, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1114,6 +1151,7 @@ ANALYZE "r_loops": 71, "rows": 4, "r_rows": 0.521126761, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.026644707, @@ -1181,6 +1219,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1191,6 +1230,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totalprice"], "rows": 106, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" } @@ -1210,6 +1250,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 8.026644707, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } @@ -1235,6 +1276,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1249,6 +1291,7 @@ ANALYZE "r_loops": 1, "rows": 106, "r_rows": 71, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1273,6 +1316,7 @@ ANALYZE "r_loops": 71, "rows": 4, "r_rows": 6.704225352, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.026644707, @@ -1351,6 +1395,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1367,6 +1412,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 17, + "cost": "COST_REPLACED", "filtered": 0.532889247, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" @@ -1382,6 +1428,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 8.466666222, "attached_condition": "orders.o_totalprice between 200000 and 250000" } @@ -1411,6 +1458,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1431,6 +1479,7 @@ ANALYZE "r_loops": 1, "rows": 17, "r_rows": 18, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 0.532889247, @@ -1451,6 +1500,7 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.466666222, @@ -1488,6 +1538,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1504,6 +1555,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 17, + "cost": "COST_REPLACED", "filtered": 0.532889247, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" @@ -1519,6 +1571,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 8.466666222, "attached_condition": "orders.o_totalprice between 200000 and 250000" } @@ -1548,6 +1601,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1568,6 +1622,7 @@ ANALYZE "r_loops": 1, "rows": 17, "r_rows": 18, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 0.532889247, @@ -1588,6 +1643,7 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.466666222, @@ -1632,6 +1688,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1642,6 +1699,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 61, + "cost": "COST_REPLACED", "filtered": 5, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" @@ -1670,6 +1728,7 @@ EXPLAIN "selectivity_pct": 2.897585346 }, "rows": 4, + "cost": "COST_REPLACED", "filtered": 2.897585392, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1699,6 +1758,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1713,6 +1773,7 @@ ANALYZE "r_loops": 1, "rows": 61, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 5, @@ -1751,6 +1812,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 2.897585392, @@ -1791,6 +1853,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1801,6 +1864,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 61, + "cost": "COST_REPLACED", "filtered": 5, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" @@ -1821,6 +1885,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 2.897585392, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1850,6 +1915,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1864,6 +1930,7 @@ ANALYZE "r_loops": 1, "rows": 61, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 5, @@ -1889,6 +1956,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 2.897585392, @@ -1932,6 +2000,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -1947,6 +2016,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 61, + "cost": "REPLACED", "filtered": "REPLACED", "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" @@ -1967,6 +2037,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "REPLACED", "filtered": "REPLACED", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1996,6 +2067,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -2015,6 +2087,7 @@ ANALYZE "r_loops": 1, "rows": 61, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -2040,6 +2113,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -2080,6 +2154,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -2095,6 +2170,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 61, + "cost": "REPLACED", "filtered": "REPLACED", "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" @@ -2115,6 +2191,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "REPLACED", "filtered": "REPLACED", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -2144,6 +2221,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -2163,6 +2241,7 @@ ANALYZE "r_loops": 1, "rows": 61, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -2188,6 +2267,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index db2e4052a21..b3b34710888 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -80,6 +80,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -98,6 +99,7 @@ EXPLAIN "selectivity_pct": 10.07493755 }, "rows": 510, + "cost": "COST_REPLACED", "filtered": 10.07493782, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -121,6 +123,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -148,6 +151,7 @@ ANALYZE "r_loops": 1, "rows": 510, "r_rows": 60, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 10.07493782, @@ -235,6 +239,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -245,6 +250,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 510, + "cost": "COST_REPLACED", "filtered": 10.07493782, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -268,6 +274,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -282,6 +289,7 @@ ANALYZE "r_loops": 1, "rows": 510, "r_rows": 510, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 10.07493782, @@ -372,6 +380,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -387,6 +396,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 98, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", "using_index": true @@ -402,6 +412,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 4.733333111, "attached_condition": "orders.o_totalprice between 200000 and 230000" } @@ -427,6 +438,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -446,6 +458,7 @@ ANALYZE "r_loops": 1, "rows": 98, "r_rows": 98, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -466,6 +479,7 @@ ANALYZE "r_loops": 98, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 4.733333111, @@ -507,6 +521,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -522,6 +537,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_shipDATE"], "rows": 98, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", "using_index": true @@ -537,6 +553,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 4.733333111, "attached_condition": "orders.o_totalprice between 200000 and 230000" } @@ -562,6 +579,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -581,6 +599,7 @@ ANALYZE "r_loops": 1, "rows": 98, "r_rows": 98, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -601,6 +620,7 @@ ANALYZE "r_loops": 98, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 4.733333111, @@ -644,6 +664,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -668,6 +689,7 @@ EXPLAIN "selectivity_pct": 10.07493755 }, "rows": 510, + "cost": "COST_REPLACED", "filtered": 10.07493782, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", "attached_condition": "lineitem.l_quantity > 45" @@ -683,6 +705,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 9.600000381, "attached_condition": "orders.o_totalprice between 180000 and 230000" } @@ -710,6 +733,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -743,6 +767,7 @@ ANALYZE "r_loops": 1, "rows": 510, "r_rows": 60, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 10.07493782, @@ -763,6 +788,7 @@ ANALYZE "r_loops": 60, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 9.600000381, @@ -812,6 +838,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -822,6 +849,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totalprice"], "rows": 144, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "orders.o_totalprice between 180000 and 230000", "using_index": true @@ -843,6 +871,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 0.855656624, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" } @@ -870,6 +899,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -884,6 +914,7 @@ ANALYZE "r_loops": 1, "rows": 144, "r_rows": 144, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -910,6 +941,7 @@ ANALYZE "r_loops": 144, "rows": 4, "r_rows": 6.625, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 0.855656624, @@ -965,6 +997,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -975,6 +1008,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totalprice"], "rows": 71, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "orders.o_totalprice between 200000 and 230000", "using_index": true @@ -995,6 +1029,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 8.492922783, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } @@ -1020,6 +1055,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1034,6 +1070,7 @@ ANALYZE "r_loops": 1, "rows": 71, "r_rows": 71, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1059,6 +1096,7 @@ ANALYZE "r_loops": 71, "rows": 4, "r_rows": 6.704225352, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.492922783, @@ -1126,6 +1164,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1136,6 +1175,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totalprice"], "rows": 71, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "orders.o_totalprice between 200000 and 230000", "using_index": true @@ -1156,6 +1196,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 8.492922783, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } @@ -1181,6 +1222,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1195,6 +1237,7 @@ ANALYZE "r_loops": 1, "rows": 71, "r_rows": 71, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -1220,6 +1263,7 @@ ANALYZE "r_loops": 71, "rows": 4, "r_rows": 6.704225352, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.492922783, @@ -1298,6 +1342,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1314,6 +1359,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, + "cost": "COST_REPLACED", "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" @@ -1329,6 +1375,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 5.666666508, "attached_condition": "orders.o_totalprice between 200000 and 250000" } @@ -1358,6 +1405,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1378,6 +1426,7 @@ ANALYZE "r_loops": 1, "rows": 18, "r_rows": 18, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 0.566194832, @@ -1398,6 +1447,7 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 5.666666508, @@ -1435,6 +1485,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1451,6 +1502,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_receiptDATE"], "rows": 18, + "cost": "COST_REPLACED", "filtered": 0.566194832, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" @@ -1466,6 +1518,7 @@ EXPLAIN "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 5.666666508, "attached_condition": "orders.o_totalprice between 200000 and 250000" } @@ -1495,6 +1548,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1515,6 +1569,7 @@ ANALYZE "r_loops": 1, "rows": 18, "r_rows": 18, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 0.566194832, @@ -1535,6 +1590,7 @@ ANALYZE "r_loops": 7, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 5.666666508, @@ -1579,6 +1635,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1589,6 +1646,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 41, + "cost": "COST_REPLACED", "filtered": 3.333333254, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" @@ -1609,6 +1667,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1638,6 +1697,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1652,6 +1712,7 @@ ANALYZE "r_loops": 1, "rows": 41, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 3.333333254, @@ -1677,6 +1738,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 3.047460556, @@ -1717,6 +1779,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -1727,6 +1790,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 41, + "cost": "COST_REPLACED", "filtered": 3.333333254, "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000" @@ -1747,6 +1811,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "COST_REPLACED", "filtered": 3.047460556, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1776,6 +1841,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1790,6 +1856,7 @@ ANALYZE "r_loops": 1, "rows": 41, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 3.333333254, @@ -1815,6 +1882,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 3.047460556, @@ -1858,6 +1926,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -1873,6 +1942,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 41, + "cost": "REPLACED", "filtered": "REPLACED", "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" @@ -1893,6 +1963,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "REPLACED", "filtered": "REPLACED", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -1922,6 +1993,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -1941,6 +2013,7 @@ ANALYZE "r_loops": 1, "rows": 41, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -1966,6 +2039,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -2006,6 +2080,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -2021,6 +2096,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["o_totaldiscount"], "rows": 41, + "cost": "REPLACED", "filtered": "REPLACED", "index_condition": "orders.o_totaldiscount between 18000 and 20000", "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" @@ -2041,6 +2117,7 @@ EXPLAIN "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], "rows": 4, + "cost": "REPLACED", "filtered": "REPLACED", "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } @@ -2070,6 +2147,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -2089,6 +2167,7 @@ ANALYZE "r_loops": 1, "rows": 41, "r_rows": 41, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -2114,6 +2193,7 @@ ANALYZE "r_loops": 1, "rows": 4, "r_rows": 6, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": "REPLACED", @@ -2199,6 +2279,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2218,6 +2299,7 @@ EXPLAIN "selectivity_pct": 1.587301587 }, "rows": 1, + "cost": "COST_REPLACED", "filtered": 1.587301612, "index_condition": "t1.f1 is null", "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" @@ -2230,6 +2312,7 @@ EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -2249,6 +2332,7 @@ EXPLAIN "selectivity_pct": 1.587301587 }, "rows": 1, + "cost": "COST_REPLACED", "filtered": 1.587301612, "index_condition": "t1.f1 is null", "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" @@ -3203,6 +3287,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -3231,6 +3316,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -3252,6 +3338,7 @@ ANALYZE "r_loops": 1, "rows": 1, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -3292,6 +3379,7 @@ ANALYZE "r_loops": 1, "rows": 24, "r_rows": 32, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 14.46428585, diff --git a/mysql-test/main/rowid_filter_innodb.test b/mysql-test/main/rowid_filter_innodb.test index 604f32cd56e..c81cfc71d28 100644 --- a/mysql-test/main/rowid_filter_innodb.test +++ b/mysql-test/main/rowid_filter_innodb.test @@ -49,6 +49,7 @@ let $q= eval $q; eval explain $q; +--source include/explain-no-costs.inc eval explain format=json $q; drop table t1; diff --git a/mysql-test/main/rowid_filter_myisam.result b/mysql-test/main/rowid_filter_myisam.result index a09f3b75d3d..2fa9f57dbd2 100644 --- a/mysql-test/main/rowid_filter_myisam.result +++ b/mysql-test/main/rowid_filter_myisam.result @@ -136,12 +136,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 101, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a2 <> t2.pk2 and t2.a2 is not null" } @@ -164,6 +166,7 @@ EXPLAIN "selectivity_pct": 87 }, "rows": 1, + "cost": "COST_REPLACED", "filtered": 87, "attached_condition": "t1.b1 <= (subquery#2)" } @@ -173,6 +176,7 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -183,6 +187,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk2"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t2.pk2 <= 1" } @@ -339,6 +344,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -353,6 +359,7 @@ ANALYZE "r_loops": 1, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 49.20000076, @@ -392,6 +399,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -406,6 +414,7 @@ ANALYZE "r_loops": 1, "rows": 1, "r_rows": 1, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 49.20000076, @@ -470,6 +479,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -498,6 +508,7 @@ ANALYZE "r_loops": 1, "rows": 55, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 1.149999976, @@ -584,6 +595,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -611,6 +623,7 @@ ANALYZE "r_loops": 1, "rows": 44, "r_rows": 0, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.630000114, @@ -650,6 +663,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -677,6 +691,7 @@ ANALYZE "r_loops": 1, "rows": 44, "r_rows": 0, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.529999733, diff --git a/mysql-test/main/rowid_filter_myisam.test b/mysql-test/main/rowid_filter_myisam.test index c340b50d9fd..e6eeed83bac 100644 --- a/mysql-test/main/rowid_filter_myisam.test +++ b/mysql-test/main/rowid_filter_myisam.test @@ -1735,6 +1735,7 @@ SELECT * FROM t1 INNER JOIN t2 ON ( pk1 <> pk2 AND pk1 = a2 ) eval $q; eval EXPLAIN EXTENDED $q; +--source include/explain-no-costs.inc eval EXPLAIN FORMAT=JSON $q; DROP TABLE t1,t2; diff --git a/mysql-test/main/set_operation.result b/mysql-test/main/set_operation.result index 977bc40c0e2..cbd3ce37085 100644 --- a/mysql-test/main/set_operation.result +++ b/mysql-test/main/set_operation.result @@ -571,12 +571,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "REPLACED", "filtered": 100 } } @@ -587,12 +589,14 @@ EXPLAIN "query_block": { "select_id": 8, "operation": "UNION", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 5, + "cost": "REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -603,12 +607,14 @@ EXPLAIN { "query_block": { "select_id": 2, + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 6, + "cost": "REPLACED", "filtered": 100 } } @@ -628,12 +634,14 @@ EXPLAIN "query_block": { "select_id": 4, "operation": "INTERSECT", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "", "access_type": "ALL", "rows": 10, + "cost": "REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -642,12 +650,14 @@ EXPLAIN { "query_block": { "select_id": 5, + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "REPLACED", "filtered": 100 } } @@ -658,12 +668,14 @@ EXPLAIN "query_block": { "select_id": 6, "operation": "UNION", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "REPLACED", "filtered": 100 } } @@ -692,12 +704,14 @@ EXPLAIN "query_block": { "select_id": 7, "operation": "EXCEPT", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 5, + "cost": "REPLACED", "filtered": 100 } } @@ -708,12 +722,14 @@ EXPLAIN "query_block": { "select_id": 9, "operation": "UNION", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 6, + "cost": "REPLACED", "filtered": 100 } } @@ -724,12 +740,14 @@ EXPLAIN "query_block": { "select_id": 10, "operation": "UNION", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 5, + "cost": "REPLACED", "filtered": 100 } } @@ -740,12 +758,14 @@ EXPLAIN "query_block": { "select_id": 11, "operation": "EXCEPT", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "REPLACED", "filtered": 100 } }, @@ -755,6 +775,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 6, + "cost": "REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -769,12 +790,14 @@ EXPLAIN "query_block": { "select_id": 12, "operation": "UNION", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 5, + "cost": "REPLACED", "filtered": 100, "attached_condition": "t1.a < 4" } @@ -785,6 +808,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 6, + "cost": "REPLACED", "filtered": 100 }, "buffer_type": "flat", @@ -799,12 +823,14 @@ EXPLAIN "query_block": { "select_id": 13, "operation": "UNION", + "cost": "REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 5, + "cost": "REPLACED", "filtered": 100 } } diff --git a/mysql-test/main/set_operation.test b/mysql-test/main/set_operation.test index c422042f371..e9f71a7e448 100644 --- a/mysql-test/main/set_operation.test +++ b/mysql-test/main/set_operation.test @@ -272,6 +272,7 @@ select * from v0 where g < 4 UNION ALL select * from t3; +--source include/analyze-format.inc EXPLAIN format=json select * from t1 UNION ALL diff --git a/mysql-test/main/show_analyze.result b/mysql-test/main/show_analyze.result index 5595fadd60b..1cda2f20514 100644 --- a/mysql-test/main/show_analyze.result +++ b/mysql-test/main/show_analyze.result @@ -405,6 +405,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { @@ -424,6 +425,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/show_analyze_json.result b/mysql-test/main/show_analyze_json.result index 8506c4b9402..38a73695e9a 100644 --- a/mysql-test/main/show_analyze_json.result +++ b/mysql-test/main/show_analyze_json.result @@ -44,6 +44,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -53,6 +54,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 1000, "r_rows": 1000, + "cost": "REPLACED", "filtered": 50, "r_filtered": 50, "attached_condition": "t1.c < 500" @@ -77,6 +79,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -86,6 +89,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 1000, "r_rows": 1000, + "cost": "REPLACED", "filtered": 10, "r_filtered": 10, "attached_condition": "t1.c < 10" @@ -111,6 +115,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -122,6 +127,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 1000, "r_rows": 1000, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 99.90000153, @@ -160,6 +166,7 @@ SHOW ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -169,6 +176,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 60, "attached_condition": "a.a <= 5" @@ -181,6 +189,7 @@ SHOW ANALYZE "query_block": { "select_id": 2, "operation": "UNION", + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -189,6 +198,7 @@ SHOW ANALYZE "r_loops": 0, "rows": 10, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null, "attached_condition": "b.a >= 9" @@ -229,6 +239,7 @@ SHOW ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -238,6 +249,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 60, "attached_condition": "a.a <= 5" @@ -250,6 +262,7 @@ SHOW ANALYZE "query_block": { "select_id": 2, "operation": "UNION", + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -259,6 +272,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 10, "attached_condition": "b.a >= 9" @@ -299,6 +313,7 @@ SHOW ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -309,6 +324,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -323,6 +339,7 @@ SHOW ANALYZE "query_block": { "select_id": 2, "operation": "UNION", + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -331,6 +348,7 @@ SHOW ANALYZE "r_loops": 0, "rows": 10, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null, "attached_condition": "b.a >= 9" @@ -371,6 +389,7 @@ SHOW ANALYZE { "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -381,6 +400,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -395,6 +415,7 @@ SHOW ANALYZE "query_block": { "select_id": 2, "operation": "UNION", + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -405,6 +426,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -441,6 +463,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -450,6 +473,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 20, "attached_condition": "a.a < 2" @@ -460,6 +484,7 @@ SHOW ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -469,6 +494,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 30, "attached_condition": "b.a > 6" @@ -501,6 +527,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -511,6 +538,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -523,6 +551,7 @@ SHOW ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -533,6 +562,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -567,6 +597,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -575,6 +606,7 @@ SHOW ANALYZE "r_loops": 0, "rows": 10, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null, "attached_condition": "a.a < 2" @@ -588,6 +620,7 @@ SHOW ANALYZE "r_loops": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -596,6 +629,7 @@ SHOW ANALYZE "r_loops": 0, "rows": 10, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null, "attached_condition": "b.a + a.a < 10" @@ -629,6 +663,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -638,6 +673,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 20, "attached_condition": "a.a < 2" @@ -651,6 +687,7 @@ SHOW ANALYZE "r_hit_ratio": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 2, "nested_loop": [ { @@ -660,6 +697,7 @@ SHOW ANALYZE "r_loops": 2, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 95, "attached_condition": "b.a + a.a < 10" @@ -693,6 +731,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -703,6 +742,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -718,6 +758,7 @@ SHOW ANALYZE "r_hit_ratio": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 2, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -728,6 +769,7 @@ SHOW ANALYZE "r_loops": 2, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -791,6 +833,7 @@ SHOW ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -799,6 +842,7 @@ SHOW ANALYZE "r_loops": 0, "rows": 10, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null, "attached_condition": "t2.a + t0.a < 3" @@ -834,6 +878,7 @@ SHOW ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -843,6 +888,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 30, "attached_condition": "t2.a + t0.a < 3" @@ -889,6 +935,7 @@ SHOW ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -897,6 +944,7 @@ SHOW ANALYZE "r_loops": 0, "rows": 10, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null, "attached_condition": "t2.a + t0.a < 3" @@ -932,6 +980,7 @@ SHOW ANALYZE { "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -941,6 +990,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 30, "attached_condition": "t2.a + t0.a < 3" @@ -974,6 +1024,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -983,6 +1034,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 3, "r_rows": 1, + "cost": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -995,6 +1047,7 @@ SHOW ANALYZE "r_hit_ratio": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "nested_loop": [ { "table": { @@ -1003,6 +1056,7 @@ SHOW ANALYZE "r_loops": 0, "rows": 10, "r_rows": null, + "cost": "REPLACED", "filtered": 100, "r_filtered": null, "attached_condition": "t2.a + t0.a < 3" @@ -1026,6 +1080,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -1035,6 +1090,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 3, "r_rows": 2, + "cost": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -1047,6 +1103,7 @@ SHOW ANALYZE "r_hit_ratio": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -1056,6 +1113,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 30, "attached_condition": "t2.a + t0.a < 3" @@ -1079,6 +1137,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -1088,6 +1147,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -1100,6 +1160,7 @@ SHOW ANALYZE "r_hit_ratio": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 2, "nested_loop": [ { @@ -1109,6 +1170,7 @@ SHOW ANALYZE "r_loops": 2, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 25, "attached_condition": "t2.a + t0.a < 3" @@ -1146,6 +1208,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "nested_loop": [ { @@ -1164,6 +1227,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -1205,6 +1269,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "temporary_table": { "nested_loop": [ @@ -1215,6 +1280,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 100 } @@ -1254,6 +1320,7 @@ SHOW ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "temporary_table": { "nested_loop": [ @@ -1264,6 +1331,7 @@ SHOW ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "filtered": 100, "r_filtered": 100 } diff --git a/mysql-test/main/show_explain_json.result b/mysql-test/main/show_explain_json.result index a5c441af5b8..1dad0ea2388 100644 --- a/mysql-test/main/show_explain_json.result +++ b/mysql-test/main/show_explain_json.result @@ -47,6 +47,7 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -57,6 +58,7 @@ SHOW EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 999, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.a < 100000", "using_index": true @@ -77,6 +79,7 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -87,6 +90,7 @@ SHOW EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a < 10" } @@ -106,6 +110,7 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -116,6 +121,7 @@ SHOW EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a < 10" } @@ -138,6 +144,7 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -148,6 +155,7 @@ SHOW EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a < 10", "mrr_type": "Rowid-ordered scan" @@ -169,6 +177,7 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -179,6 +188,7 @@ SHOW EXPLAIN "key_length": "5", "used_key_parts": ["a"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t1.a < 10", "mrr_type": "Rowid-ordered scan" @@ -210,12 +220,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "A", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -226,12 +238,14 @@ SHOW EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "B", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -266,12 +280,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "A", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -282,12 +298,14 @@ SHOW EXPLAIN "query_block": { "select_id": 2, "operation": "UNION", + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "B", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -378,12 +396,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "a", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "a.a < 1" } @@ -394,12 +414,14 @@ SHOW EXPLAIN "expression_cache": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "b", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "b.a + a.a < 10" } @@ -427,12 +449,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "a", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "a.a < 1" } @@ -443,12 +467,14 @@ SHOW EXPLAIN "expression_cache": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "b", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "b.a + a.a < 10" } @@ -476,12 +502,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "a", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "a.a < 1" } @@ -492,12 +520,14 @@ SHOW EXPLAIN "expression_cache": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "b", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "b.a + a.a < 10" } @@ -552,12 +582,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -586,12 +618,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -628,12 +662,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -662,12 +698,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -707,12 +745,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -741,12 +781,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -786,12 +828,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -820,12 +864,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -854,12 +900,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -869,12 +917,14 @@ SHOW EXPLAIN "expression_cache": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -893,12 +943,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -908,12 +960,14 @@ SHOW EXPLAIN "expression_cache": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -932,12 +986,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -947,12 +1003,14 @@ SHOW EXPLAIN "expression_cache": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -986,12 +1044,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1001,12 +1061,14 @@ SHOW EXPLAIN "expression_cache": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -1025,12 +1087,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1040,12 +1104,14 @@ SHOW EXPLAIN "expression_cache": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -1064,12 +1130,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1079,12 +1147,14 @@ SHOW EXPLAIN "expression_cache": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a + t0.a < 3" } @@ -1120,6 +1190,7 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "read_sorted_file": { @@ -1129,6 +1200,7 @@ SHOW EXPLAIN "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1169,6 +1241,7 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1176,6 +1249,7 @@ SHOW EXPLAIN "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1215,6 +1289,7 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "temporary_table": { "nested_loop": [ { @@ -1222,6 +1297,7 @@ SHOW EXPLAIN "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1264,12 +1340,14 @@ SHOW EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t0.a = (octet_length('гы'))" } diff --git a/mysql-test/main/show_explain_json.test b/mysql-test/main/show_explain_json.test index 8d2a6aa82bb..321fa46be87 100644 --- a/mysql-test/main/show_explain_json.test +++ b/mysql-test/main/show_explain_json.test @@ -118,6 +118,7 @@ send select count(*) from t1 where a < 100000; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain FORMAT=JSON for $thr2; connection con1; reap; @@ -126,6 +127,7 @@ reap; send select max(c) from t1 where a < 10; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain FORMAT=JSON for connection $thr2; connection con1; reap; @@ -134,6 +136,7 @@ reap; send select max(c) from t1 where a < 10; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain format=JSON for connection $thr2; connection con1; reap; @@ -145,6 +148,7 @@ set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_sort_keys=on'; send explain select max(c) from t1 where a < 10; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=json for $thr2; connection con1; reap; @@ -153,6 +157,7 @@ reap; send explain select max(c) from t1 where a < 10; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain format=JSON for connection $thr2; connection con1; reap; @@ -165,6 +170,7 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send explain select a from t0 A union select a+1 from t0 B; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format = JSON for $thr2; connection con1; reap; @@ -177,6 +183,7 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send explain select a from t0 A union select a+1 from t0 B; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=JSON for $thr2; connection con1; reap; @@ -234,6 +241,7 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=JSON for $thr2; connection con1; reap; @@ -245,6 +253,7 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=JSON for $thr2; connection con1; reap; @@ -256,6 +265,7 @@ SET debug_dbug='+d,show_explain_probe_join_exec_end'; send select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=JSON for $thr2; connection con1; reap; @@ -293,8 +303,10 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send update t2 set dummy=0 where (select max(a) from t0 where t2.a + t0.a <3) >3 ; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=JSON for $thr2; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=JSON for $thr2; connection con1; reap; @@ -308,8 +320,10 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send update t2 set dummy=0 where (select max(a) from t0 where t2.a + t0.a <3) >3 ; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain format=JSON for connection $thr2; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain format=JSON for connection $thr2; connection con1; reap; @@ -326,8 +340,10 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send delete from t2 where (select max(a) from t0 where t2.a + t0.a <3) >3 ; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=JSON for $thr2; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=JSON for $thr2; connection con1; reap; @@ -343,8 +359,10 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send delete from t2 where (select max(a) from t0 where t2.a + t0.a <3) >3 ; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain format=JSON for connection $thr2; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain format=JSON for connection $thr2; connection con1; reap; @@ -360,10 +378,13 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send select t2.a, ((select max(a) from t0 where t2.a + t0.a <3) >3) as SUBQ from t2; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=json for $thr2; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=json for $thr2; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=json for $thr2; connection con1; reap; @@ -380,10 +401,13 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; send select t2.a, ((select max(a) from t0 where t2.a + t0.a <3) >3) as SUBQ from t2; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain format=JSON for connection $thr2; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain format=JSON for connection $thr2; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp explain format=JSON for connection $thr2; connection con1; reap; @@ -400,6 +424,7 @@ set @show_explain_probe_select_id=1; send select * from t0 order by a; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=json for $thr2; connection con1; reap; @@ -417,6 +442,7 @@ set @show_explain_probe_select_id=1; send select distinct a from t0; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=json for $thr2; connection con1; reap; @@ -435,6 +461,7 @@ set @show_explain_probe_select_id=1; send select distinct a from t0; connection default; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=json for $thr2; connection con1; reap; @@ -461,6 +488,7 @@ select * from t0 where length(' connection default; set names utf8; --source include/wait_condition.inc +--source include/explain-no-costs.inc evalp show explain format=JSON for $thr2; set names default; diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result index 748287152b1..14d3720e06e 100644 --- a/mysql-test/main/statistics_json.result +++ b/mysql-test/main/statistics_json.result @@ -8338,12 +8338,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 18, + "cost": "COST_REPLACED", "filtered": 5.555555344, "attached_condition": "t1.a > 'y'" } diff --git a/mysql-test/main/statistics_json.test b/mysql-test/main/statistics_json.test index 5263a98fff7..b9a5c3dbea2 100644 --- a/mysql-test/main/statistics_json.test +++ b/mysql-test/main/statistics_json.test @@ -477,6 +477,7 @@ INSERT INTO t1 VALUES ('o'),('s'),('j'),('s'),('y'),('s'),('l'), set histogram_type=json_hb; analyze table t1 persistent for all; --echo # filtered must not be negative: +--source include/explain-no-costs.inc explain format=json select * from t1 where a > 'y'; drop table t1; diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index c96379ee856..2e864355afb 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -2927,6 +2927,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "duplicate_removal": { @@ -2939,6 +2940,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -2953,6 +2955,7 @@ ANALYZE "r_loops": 0, "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -2963,6 +2966,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -2975,6 +2979,7 @@ ANALYZE { "query_block": { "select_id": 3, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -2985,6 +2990,7 @@ ANALYZE "r_loops": 1, "rows": 2, "r_rows": 2, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/subselect_cache.result b/mysql-test/main/subselect_cache.result index 5c2fd3e66fc..4e8c3a46205 100644 --- a/mysql-test/main/subselect_cache.result +++ b/mysql-test/main/subselect_cache.result @@ -49,6 +49,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -59,6 +60,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -73,6 +75,7 @@ ANALYZE "r_hit_ratio": 60, "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 4, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -83,6 +86,7 @@ ANALYZE "r_loops": 4, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -106,6 +110,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -116,6 +121,7 @@ ANALYZE "r_loops": 1, "rows": 10, "r_rows": 10, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -138,6 +144,7 @@ ANALYZE { "query_block": { "select_id": 3, + "cost": "REPLACED", "r_loops": 4, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -148,6 +155,7 @@ ANALYZE "r_loops": 4, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -178,6 +186,7 @@ ANALYZE "r_hit_ratio": 60, "query_block": { "select_id": 2, + "cost": "REPLACED", "r_loops": 4, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -188,6 +197,7 @@ ANALYZE "r_loops": 4, "rows": 4, "r_rows": 4, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -208,12 +218,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -224,12 +236,14 @@ EXPLAIN "state": "uninitialized", "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t2.c" } @@ -247,12 +261,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -269,12 +285,14 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t2.c" } @@ -301,12 +319,14 @@ EXPLAIN "state": "uninitialized", "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t2", "access_type": "ALL", "rows": 4, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t1.b = t2.c" } diff --git a/mysql-test/main/subselect_cache.test b/mysql-test/main/subselect_cache.test index cf647afb994..7695b01b1ea 100644 --- a/mysql-test/main/subselect_cache.test +++ b/mysql-test/main/subselect_cache.test @@ -34,8 +34,10 @@ select a, (select d from t2 where b=c) from t1; --source include/analyze-format.inc analyze format=json select a, (select d from t2 where b=c), (select d from t2 where b=c union select 1 order by 1 limit 1) from t1; +--source include/explain-no-costs.inc explain format=json select a, (select d from t2 where b=c) from t1; +--source include/explain-no-costs.inc explain format=json select a, (select d from t2 where b=c), (select d from t2 where b=c union select 1 order by 1 limit 1) from t1; set optimizer_switch='subquery_cache=off'; diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index 07eb361b91c..d216d991f8f 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -7438,12 +7438,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -7467,12 +7469,14 @@ EXPLAIN { "query_block": { "select_id": 3, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "1 = t3.c" } diff --git a/mysql-test/main/subselect_no_semijoin.test b/mysql-test/main/subselect_no_semijoin.test index 84d312c03c8..83488829448 100644 --- a/mysql-test/main/subselect_no_semijoin.test +++ b/mysql-test/main/subselect_no_semijoin.test @@ -24,6 +24,7 @@ INSERT INTO t3 VALUES (4),(5); SET @tmp19714=@@optimizer_switch; SET optimizer_switch='subquery_cache=off'; +--source include/explain-no-costs.inc explain format=json SELECT ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; diff --git a/mysql-test/main/table_elim.result b/mysql-test/main/table_elim.result index 9e3d2ea5a7b..a6a3d4d8513 100644 --- a/mysql-test/main/table_elim.result +++ b/mysql-test/main/table_elim.result @@ -737,6 +737,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "nested_loop": [ { @@ -744,6 +745,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -769,6 +771,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "nested_loop": [ { @@ -776,6 +779,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -789,11 +793,13 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "trigcond(t1.a = v2b.b and trigcond(t1.a is not null))", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "const_condition": "1", "filesort": { "sort_key": "t11.a", @@ -804,6 +810,7 @@ EXPLAIN "table_name": "t11", "access_type": "ALL", "rows": 1000, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -831,6 +838,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "nested_loop": [ { @@ -838,6 +846,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -857,6 +866,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "const_condition": "1", "nested_loop": [ { @@ -864,6 +874,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -877,11 +888,13 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "rows": 10, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "trigcond(trigcond(t1.a is not null))", "materialized": { "query_block": { "select_id": 2, + "cost": "COST_REPLACED", "const_condition": "1", "filesort": { "sort_key": "t11.a", @@ -892,6 +905,7 @@ EXPLAIN "table_name": "t11", "access_type": "ALL", "rows": 1000, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -905,6 +919,7 @@ EXPLAIN "used_key_parts": ["pk"], "ref": ["test.t11.b"], "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "trigcond(trigcond(t11.b is not null))" } diff --git a/mysql-test/main/table_elim.test b/mysql-test/main/table_elim.test index d6bf925c2c0..26c56630784 100644 --- a/mysql-test/main/table_elim.test +++ b/mysql-test/main/table_elim.test @@ -680,6 +680,7 @@ group by t11.a; explain select t1.* from t1 left join v2b on v2b.a=t1.a; --echo # Check format JSON as well +--source include/explain-no-costs.inc explain format=JSON select t1.* from t1 left join v2b on t1.a=v2b.a; --echo # Elimination of a whole subquery @@ -692,6 +693,7 @@ explain select t1.* from t1 left join explain select t1.* from t1 left join v2b on t1.a=v2b.b; --echo # Check format JSON as well +--source include/explain-no-costs.inc explain format=JSON select t1.* from t1 left join v2b on t1.a=v2b.b; create view v2c as @@ -703,12 +705,14 @@ group by t11.a; explain select t1.* from t1 left join v2c on v2c.a=t1.a; --echo # Check format JSON as well +--source include/explain-no-costs.inc explain format=JSON select t1.* from t1 left join v2c on v2c.a=t1.a; --echo # In this case v2c cannot be eliminated (since v2c.b is not unique)! explain select t1.* from t1 left join v2c on t1.a=v2c.b; --echo # Check format JSON as well +--source include/explain-no-costs.inc explain format=JSON select t1.* from t1 left join v2c on t1.a=v2c.b; --echo # Create a view with multiple fields in the GROUP BY clause: diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test index b86244f9605..ade90400b63 100644 --- a/mysql-test/main/table_value_constr.test +++ b/mysql-test/main/table_value_constr.test @@ -833,6 +833,7 @@ deallocate prepare stmt1; explain values (1,2); +--source include/explain-no-costs.inc explain format=json values (1,2); @@ -853,16 +854,19 @@ values (5,6) union values (1,2),(3,4); +--source include/explain-no-costs.inc explain format=json select 1,2 union values (1,2),(3,4); +--source include/explain-no-costs.inc explain format=json values (1,2),(3,4) union select 1,2; +--source include/explain-no-costs.inc explain format=json values (5,6) union @@ -875,6 +879,7 @@ values (3,4) union values (1,2); +--source include/explain-no-costs.inc explain format=json select 1,2 union @@ -899,16 +904,19 @@ values (1,2) union all values (1,2),(3,4); +--source include/explain-no-costs.inc explain format=json values (1,2),(3,4) union all select 1,2; +--source include/explain-no-costs.inc explain format=json select 1,2 union values (1,2),(3,4); +--source include/explain-no-costs.inc explain format=json values (1,2) union all @@ -921,6 +929,7 @@ values (3,4) union all values (1,2); +--source include/explain-no-costs.inc explain format=json select 1,2 union all diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index 9eb7c0d6029..d2a91227723 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -1402,6 +1402,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1417,6 +1418,7 @@ EXPLAIN "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1437,6 +1439,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "window_functions_computation": { @@ -1454,6 +1457,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1474,6 +1478,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1489,6 +1494,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1511,6 +1517,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "MX in (3,5,7)", "filesort": { "sort_key": "t1.b", @@ -1529,6 +1536,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1665,6 +1673,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1680,6 +1689,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1697,6 +1707,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1712,6 +1723,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1729,6 +1741,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1744,6 +1757,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1761,6 +1775,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1776,6 +1791,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1821,6 +1837,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "row_number() over ( order by t1.s1,t1.s2) desc", "window_functions_computation": { @@ -1838,6 +1855,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 6, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1981,6 +1999,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "duplicate_removal": { "window_functions_computation": { "sorts": [ @@ -1997,6 +2016,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2161,6 +2181,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -2176,6 +2197,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2228,6 +2250,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -2243,6 +2266,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 6, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3827,6 +3851,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "window_functions_computation": { @@ -3852,6 +3877,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test index d7f52ec32e9..56663a0ad88 100644 --- a/mysql-test/main/win.test +++ b/mysql-test/main/win.test @@ -927,11 +927,13 @@ drop table t0,t1; create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +--source include/explain-no-costs.inc explain format=json select rank() over (order by a) from t0; create table t1 (a int, b int, c int); insert into t1 select a,a,a from t0; +--source include/explain-no-costs.inc explain format=json select a, @@ -939,6 +941,7 @@ select from t1 group by a; +--source include/explain-no-costs.inc explain format=json select a, @@ -952,6 +955,7 @@ order by null; --echo # select b,max(a) as MX, rank() over (order by b) from t1 group by b having MX in (3,5,7); +--source include/explain-no-costs.inc explain format=json select b,max(a) as MX, rank() over (order by b) from t1 group by b having MX in (3,5,7); @@ -1040,24 +1044,28 @@ from t1; show status like '%sort%'; # Check using EXPLAIN FORMAT=JSON +--source include/explain-no-costs.inc explain format=json select rank() over (partition by c order by a), rank() over (partition by c order by a) from t1; +--source include/explain-no-costs.inc explain format=json select rank() over (order by a), row_number() over (order by a) from t1; +--source include/explain-no-costs.inc explain format=json select rank() over (partition by c order by a), count(*) over (partition by c) from t1; +--source include/explain-no-costs.inc explain format=json select count(*) over (partition by c), @@ -1089,6 +1097,7 @@ insert into t1 values (null,'a'); insert into t1 values (2,'b'); insert into t1 values (-1,''); +--source include/explain-no-costs.inc explain format=json select *, row_number() over (order by s1, s2) as X from t1 order by X desc; select *, row_number() over (order by s1, s2) as X from t1 order by X desc; @@ -1177,6 +1186,7 @@ insert into t1 values select rank() over (partition by part_id order by a) from t1; select distinct rank() over (partition by part_id order by a) from t1; +--source include/explain-no-costs.inc explain format=json select distinct rank() over (partition by part_id order by a) from t1; @@ -1301,6 +1311,7 @@ select pk, a, d, sum(d) over (order by a ROWS BETWEEN 1 preceding and 2 following) as sum_2 from t1; +--source include/explain-no-costs.inc explain format=json select pk, a, d, sum(d) over (partition by a order by pk @@ -1336,6 +1347,7 @@ insert into t1 values (10, 5, 1000), (10, 1, 100); +--source include/explain-no-costs.inc explain format=json select a,b,c, diff --git a/mysql-test/main/win_empty_over.result b/mysql-test/main/win_empty_over.result index 4fa53bb4eae..acb83724d72 100644 --- a/mysql-test/main/win_empty_over.result +++ b/mysql-test/main/win_empty_over.result @@ -36,6 +36,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -54,6 +55,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk"], "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "using_index": true } @@ -68,6 +70,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -86,6 +89,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk"], "rows": 11, + "cost": "COST_REPLACED", "filtered": 100, "using_index": true } diff --git a/mysql-test/main/win_empty_over.test b/mysql-test/main/win_empty_over.test index 91344d76865..dff15a41e30 100644 --- a/mysql-test/main/win_empty_over.test +++ b/mysql-test/main/win_empty_over.test @@ -21,7 +21,9 @@ insert into t1 values (11, 2, 10, NULL, 0.9, NULL); select pk, row_number() over () from t1; +--source include/explain-no-costs.inc explain FORMAT=JSON select pk, row_number() over () from t1; +--source include/explain-no-costs.inc explain FORMAT=JSON select row_number() over (), pk from t1; select row_number() over () from (select 4) as t; diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index 6fde6d2a41f..b75334d8c31 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -1408,6 +1408,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1423,6 +1424,7 @@ EXPLAIN "table_name": "t0", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1443,6 +1445,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "t1.a", "window_functions_computation": { @@ -1460,6 +1463,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1480,6 +1484,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1495,6 +1500,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1517,6 +1523,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "having_condition": "MX in (3,5,7)", "filesort": { "sort_key": "t1.b", @@ -1535,6 +1542,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 10, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1671,6 +1679,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1686,6 +1695,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1703,6 +1713,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1718,6 +1729,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1735,6 +1747,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1750,6 +1763,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1767,6 +1781,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -1782,6 +1797,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 3, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1827,6 +1843,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "filesort": { "sort_key": "row_number() over ( order by t1.s1,t1.s2) desc", "window_functions_computation": { @@ -1844,6 +1861,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 6, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -1987,6 +2005,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "duplicate_removal": { "window_functions_computation": { "sorts": [ @@ -2003,6 +2022,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 9, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2167,6 +2187,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -2182,6 +2203,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 11, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -2234,6 +2256,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "window_functions_computation": { "sorts": [ { @@ -2249,6 +2272,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "rows": 6, + "cost": "COST_REPLACED", "filtered": 100 } } @@ -3833,6 +3857,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "window_functions_computation": { @@ -3858,6 +3883,7 @@ ANALYZE "r_loops": 1, "rows": 3, "r_rows": 3, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 0b008c34601..92436e1ac64 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -160,12 +160,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t3", "access_type": "ALL", "rows": 7, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -179,6 +181,7 @@ EXPLAIN "used_key_parts": ["name"], "ref": ["federated.t3.name"], "rows": 2, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { "query_block": { @@ -231,6 +234,7 @@ ANALYZE }, "query_block": { "select_id": 1, + "cost": "REPLACED", "r_loops": 1, "r_total_time_ms": "REPLACED", "nested_loop": [ @@ -241,6 +245,7 @@ ANALYZE "r_loops": 1, "rows": 7, "r_rows": 7, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -259,6 +264,7 @@ ANALYZE "r_loops": 7, "rows": 2, "r_rows": 0, + "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, @@ -364,12 +370,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "t5", "access_type": "ALL", "rows": 2, + "cost": "COST_REPLACED", "filtered": 100 } }, @@ -379,6 +387,7 @@ EXPLAIN "table_name": "", "access_type": "ALL", "rows": 5, + "cost": "COST_REPLACED", "filtered": 100 }, "buffer_type": "flat", diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test index f827c141f3d..566aee6a0d6 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.test +++ b/mysql-test/suite/federated/federatedx_create_handlers.test @@ -76,6 +76,7 @@ SELECT id FROM federated.t1 WHERE id < 5; EXPLAIN EXTENDED SELECT id FROM federated.t1 WHERE id < 5; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT id FROM federated.t1 WHERE id < 5; @@ -103,6 +104,7 @@ SELECT * FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t WHERE federated.t3.name=t.name; +--source include/explain-no-costs.inc EXPLAIN FORMAT=JSON SELECT * FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t @@ -177,6 +179,7 @@ explain select * from federated.t1 where name in (select name from federated.t2); +--source include/explain-no-costs.inc explain format=json select * from federated.t1 where name in (select name from federated.t2); @@ -196,6 +199,7 @@ select * from t5, where name in (select name from federated.t2) or name like 'foo%') as TQ; --echo # Must not show elements with select_id=3 +--source include/explain-no-costs.inc explain format=json select * from t5, (select id from federated.t1 diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result index 44957352865..3eefaa72c1d 100644 --- a/mysql-test/suite/json/r/json_table.result +++ b/mysql-test/suite/json/r/json_table.result @@ -211,12 +211,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "tt", "access_type": "ALL", "rows": 40, + "cost": "COST_REPLACED", "filtered": 100, "table_function": "json_table" } diff --git a/mysql-test/suite/json/r/json_table_mysql.result b/mysql-test/suite/json/r/json_table_mysql.result index cdca41b3a24..44ca370f01f 100644 --- a/mysql-test/suite/json/r/json_table_mysql.result +++ b/mysql-test/suite/json/r/json_table_mysql.result @@ -189,12 +189,14 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { "table_name": "tt", "access_type": "ALL", "rows": 40, + "cost": "COST_REPLACED", "filtered": 100, "table_function": "json_table" } diff --git a/mysql-test/suite/json/t/json_table.test b/mysql-test/suite/json/t/json_table.test index 492be2d48bf..982922ff595 100644 --- a/mysql-test/suite/json/t/json_table.test +++ b/mysql-test/suite/json/t/json_table.test @@ -145,6 +145,7 @@ create view v2 as select * from json_table('[{"co\\\\lor": "blue", "price": 50 select * from v2; drop view v2; +--source include/explain-no-costs.inc explain format=json select * from json_table('[{"a": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}]', '$[*]' COLUMNS( a INT PATH '$.a')) as tt; explain select * from diff --git a/mysql-test/suite/json/t/json_table_mysql.test b/mysql-test/suite/json/t/json_table_mysql.test index 9f77ad964f3..3b0fb556260 100644 --- a/mysql-test/suite/json/t/json_table_mysql.test +++ b/mysql-test/suite/json/t/json_table_mysql.test @@ -167,6 +167,7 @@ select * from #eval $query; #eval explain $query; +--source include/explain-no-costs.inc explain format=json select * from json_table( diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index b4adfe8546c..fd5f675add5 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -1033,6 +1033,9 @@ void Explain_select::print_explain_json(Explain_query *query, writer->add_member("select_id").add_ll(select_id); add_linkage(writer); + if (cost != 0.0) + writer->add_member("cost").add_double(cost); + if (is_analyze && time_tracker.get_loops()) { writer->add_member("r_loops").add_ll(time_tracker.get_loops()); @@ -1942,7 +1945,13 @@ void Explain_table_access::print_explain_json(Explain_query *query, else writer->add_null(); } + } + if (cost != 0.0) + writer->add_member("cost").add_double(cost); + + if (is_analyze) + { if (op_tracker.get_loops()) { double total_time= op_tracker.get_time_ms(); diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 42a1c360e5b..9e560c0be23 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -216,6 +216,7 @@ public: message(NULL), having(NULL), having_value(Item::COND_UNDEF), using_temporary(false), using_filesort(false), + cost(0.0), time_tracker(is_analyze), aggr_tree(NULL) {} @@ -249,9 +250,10 @@ public: bool using_temporary; bool using_filesort; + double cost; /* ANALYZE members */ Time_and_counter_tracker time_tracker; - + /* Part of query plan describing sorting, temp.table usage, and duplicate removal @@ -824,6 +826,9 @@ public: ha_rows rows; double filtered; + /* Total cost incurred during one execution of this select */ + double cost; + /* Contents of the 'Extra' column. Some are converted into strings, some have parameters, values for which are stored below. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c7ed2ebd810..17ae0cf079e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12021,6 +12021,7 @@ bool JOIN::get_best_combination() j->records_init= j->records_out= j->records_read; j->records= (ha_rows) j->records_read; j->cond_selectivity= 1.0; + j->join_read_time= 0.0; /* Not saved currently */ JOIN_TAB *jt; JOIN_TAB_RANGE *jt_range; if (!(jt= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*sjm->tables)) || @@ -12081,6 +12082,7 @@ bool JOIN::get_best_combination() j->records_init= cur_pos->records_init; j->records_read= cur_pos->records_read; j->records_out= cur_pos->records_out; + j->join_read_time= cur_pos->read_time; loop_end: j->cond_selectivity= cur_pos->cond_selectivity; @@ -28585,6 +28587,7 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, explain_plan= eta; eta->key.clear(); eta->quick_info= NULL; + eta->cost= join_read_time; SQL_SELECT *tab_select; /* @@ -29198,6 +29201,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, table_map used_tables=0; join->select_lex->set_explain_type(true); + xpl_sel->cost= best_read; xpl_sel->select_id= join->select_lex->select_number; xpl_sel->select_type= join->select_lex->type; xpl_sel->linkage= select_lex->get_linkage(); diff --git a/sql/sql_select.h b/sql/sql_select.h index ce2ed623406..3956651c57b 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -350,6 +350,12 @@ typedef struct st_join_table { /* Copy of POSITION::records_out, set by get_best_combination() */ double records_out; + /* + Copy of POSITION::read_time, set by get_best_combination(). The cost of + accessing the table in course of the join execution. + */ + double join_read_time; + /* The selectivity of the conditions that can be pushed to the table */ double cond_selectivity; diff --git a/storage/rocksdb/mysql-test/rocksdb/include/rocksdb_icp.inc b/storage/rocksdb/mysql-test/rocksdb/include/rocksdb_icp.inc index c76b52d4cc1..bf593ec9b0c 100644 --- a/storage/rocksdb/mysql-test/rocksdb/include/rocksdb_icp.inc +++ b/storage/rocksdb/mysql-test/rocksdb/include/rocksdb_icp.inc @@ -49,7 +49,7 @@ insert into t3 select a,a/10,a,a from t1; explain select * from t3 where kp1=3 and kp2 like '%foo%'; ---replace_column 9 # +--source include/explain-no-costs.inc explain format=json select * from t3 where kp1 between 2 and 4 and mod(kp1,3)=0 and kp2 like '%foo%'; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result index f9e3129c73f..7443909b1ac 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result @@ -47,6 +47,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -57,6 +58,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["kp1"], "rows": 1000, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t3.kp1 between 2 and 4 and t3.kp1 MOD 3 = 0", "attached_condition": "t3.kp2 like '%foo%'" diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result index 3634f8c023e..ece58586d8b 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result @@ -47,6 +47,7 @@ EXPLAIN { "query_block": { "select_id": 1, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { @@ -57,6 +58,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["kp1"], "rows": 1000, + "cost": "COST_REPLACED", "filtered": 100, "index_condition": "t3.kp1 between 2 and 4 and t3.kp1 MOD 3 = 0", "attached_condition": "t3.kp2 like '%foo%'" From 6c4076fac4ade864eda7f09bd9770de3c640feb0 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 21 Nov 2022 18:17:14 +0300 Subject: [PATCH 077/123] MDEV-30032: EXPLAIN FORMAT=JSON output: part #2: print 'loops'. --- mysql-test/main/analyze_format_json.result | 29 + mysql-test/main/analyze_stmt_orderby.result | 16 + mysql-test/main/brackets.result | 8 + mysql-test/main/cte_recursive.result | 28 + mysql-test/main/derived_cond_pushdown.result | 687 ++++++++++++++++++ mysql-test/main/derived_view.result | 21 + mysql-test/main/except.result | 20 + mysql-test/main/except_all.result | 22 + mysql-test/main/explain_json.result | 79 ++ .../explain_json_format_partitions.result | 2 + mysql-test/main/explain_json_innodb.result | 3 + mysql-test/main/fetch_first.result | 1 + mysql-test/main/having_cond_pushdown.result | 154 ++++ mysql-test/main/in_subq_cond_pushdown.result | 126 ++++ mysql-test/main/innodb_ext_key,off.rdiff | 6 +- mysql-test/main/innodb_ext_key.result | 2 + mysql-test/main/intersect.result | 20 + mysql-test/main/intersect_all.result | 20 + mysql-test/main/join_cache.result | 2 + mysql-test/main/opt_trace.result | 5 + mysql-test/main/opt_trace_ucs2.result | 1 + mysql-test/main/order_by.result | 13 + mysql-test/main/order_by_pack_big.result | 4 + mysql-test/main/range.result | 19 + mysql-test/main/range_mrr_icp.result | 19 + mysql-test/main/rowid_filter.result | 52 ++ mysql-test/main/rowid_filter_aria.result | 52 ++ mysql-test/main/rowid_filter_innodb.result | 57 ++ mysql-test/main/rowid_filter_myisam.result | 8 + mysql-test/main/set_operation.result | 14 + mysql-test/main/show_analyze.result | 1 + mysql-test/main/show_analyze_json.result | 34 + mysql-test/main/show_explain_json.result | 39 + mysql-test/main/statistics_json.result | 1 + mysql-test/main/subselect4.result | 3 + mysql-test/main/subselect_cache.result | 10 + mysql-test/main/subselect_no_semijoin.result | 2 + mysql-test/main/table_elim.result | 9 + mysql-test/main/win.result | 13 + mysql-test/main/win_empty_over.result | 2 + .../encryption/r/tempfiles_encrypted.result | 13 + .../federatedx_create_handlers.result | 6 + mysql-test/suite/json/r/json_table.result | 1 + .../suite/json/r/json_table_mysql.result | 1 + sql/opt_subselect.h | 3 +- sql/sql_explain.cc | 3 + sql/sql_explain.h | 3 + sql/sql_select.cc | 6 +- sql/sql_select.h | 3 + .../mysql-test/rocksdb/r/rocksdb_icp.result | 1 + .../rocksdb/r/rocksdb_icp_rev.result | 1 + 51 files changed, 1641 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/analyze_format_json.result b/mysql-test/main/analyze_format_json.result index 32e6ae0a67e..34761fb51b4 100644 --- a/mysql-test/main/analyze_format_json.result +++ b/mysql-test/main/analyze_format_json.result @@ -18,6 +18,7 @@ ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -56,6 +57,7 @@ ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -76,6 +78,7 @@ ANALYZE "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t0.a"], + "loops": 10, "r_loops": 0, "rows": 1, "r_rows": null, @@ -109,6 +112,7 @@ ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -129,6 +133,7 @@ ANALYZE "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t0.a"], + "loops": 10, "r_loops": 10, "rows": 1, "r_rows": 1, @@ -165,6 +170,7 @@ ANALYZE "table": { "table_name": "tbl1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 100, "r_rows": 100, @@ -181,6 +187,7 @@ ANALYZE "table": { "table_name": "tbl2", "access_type": "ALL", + "loops": 100, "r_loops": 1, "rows": 100, "r_rows": 100, @@ -218,6 +225,7 @@ ANALYZE "table": { "table_name": "tbl1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 100, "r_rows": 100, @@ -234,6 +242,7 @@ ANALYZE "table": { "table_name": "tbl2", "access_type": "ALL", + "loops": 100, "r_loops": 1, "rows": 100, "r_rows": 100, @@ -280,6 +289,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -300,6 +310,7 @@ ANALYZE "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 10, "r_loops": 10, "rows": 2, "r_rows": 0.2, @@ -344,6 +355,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -414,6 +426,7 @@ ANALYZE "key": "PRIMARY", "key_length": "4", "used_key_parts": ["pk"], + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -492,6 +505,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 5, "r_rows": 5, @@ -519,6 +533,7 @@ ANALYZE "table_name": "t2", "access_type": "ALL", "possible_keys": ["key1", "key2", "key3", "key4"], + "loops": 5, "r_loops": 5, "rows": 1010, "r_rows": 203.8, @@ -565,6 +580,7 @@ ANALYZE "table": { "table_name": "tbl1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -591,6 +607,7 @@ ANALYZE "table": { "table_name": "tbl2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -650,6 +667,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 256, "r_rows": 256, @@ -691,6 +709,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 256, "r_rows": 256, @@ -746,6 +765,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 256, "r_rows": 256, @@ -785,6 +805,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -800,6 +821,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 2, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -831,6 +853,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -897,6 +920,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -912,6 +936,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 2, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -943,6 +968,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 0, "rows": 2, "r_rows": null, @@ -956,6 +982,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 2, "r_loops": 0, "rows": 2, "r_rows": null, @@ -1007,6 +1034,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -1041,6 +1069,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 0, "rows": 10, "r_rows": null, diff --git a/mysql-test/main/analyze_stmt_orderby.result b/mysql-test/main/analyze_stmt_orderby.result index 80c630217ca..c3a3f2c562e 100644 --- a/mysql-test/main/analyze_stmt_orderby.result +++ b/mysql-test/main/analyze_stmt_orderby.result @@ -191,6 +191,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -206,6 +207,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t0.a"], + "loops": 10, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -242,6 +244,7 @@ ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -262,6 +265,7 @@ ANALYZE "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t0.a"], + "loops": 10, "r_loops": 10, "rows": 1, "r_rows": 0.4, @@ -300,6 +304,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -317,6 +322,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t0.a"], + "loops": 10, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -352,6 +358,7 @@ ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -374,6 +381,7 @@ ANALYZE "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t0.a"], + "loops": 10, "r_loops": 10, "rows": 1, "r_rows": 0.4, @@ -425,6 +433,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 1000, "r_rows": 1000, @@ -483,6 +492,7 @@ ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -498,6 +508,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 10, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -570,6 +581,7 @@ ANALYZE "table": { "table_name": "t6", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 5, "r_rows": 5, @@ -586,6 +598,7 @@ ANALYZE "table": { "table_name": "t5", "access_type": "ALL", + "loops": 5, "r_loops": 1, "rows": 7, "r_rows": 7, @@ -630,6 +643,7 @@ EXPLAIN "table": { "table_name": "t6", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -641,6 +655,7 @@ EXPLAIN "table": { "table_name": "t5", "access_type": "ALL", + "loops": 5, "rows": 7, "cost": "COST_REPLACED", "filtered": 100 @@ -700,6 +715,7 @@ ANALYZE "key": "idx", "key_length": "5", "used_key_parts": ["col1"], + "loops": 1, "r_loops": 1, "rows": 7, "r_rows": 20, diff --git a/mysql-test/main/brackets.result b/mysql-test/main/brackets.result index 73917dd635b..0403ce81d1d 100644 --- a/mysql-test/main/brackets.result +++ b/mysql-test/main/brackets.result @@ -270,6 +270,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -302,6 +303,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -339,6 +341,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -358,6 +361,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -397,6 +401,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -416,6 +421,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -466,6 +472,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -486,6 +493,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index 6356d94f933..189689fa463 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -1345,6 +1345,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 24, "cost": "COST_REPLACED", "filtered": 100, @@ -1363,6 +1364,7 @@ EXPLAIN "table": { "table_name": "folks", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1382,6 +1384,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1401,6 +1404,7 @@ EXPLAIN "table": { "table_name": "folks", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1421,6 +1425,7 @@ EXPLAIN "table_name": "folks", "access_type": "ALL", "possible_keys": ["PRIMARY"], + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100 @@ -1431,6 +1436,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 12, "rows": 12, "cost": "COST_REPLACED", "filtered": 100 @@ -1463,6 +1469,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 24, "cost": "COST_REPLACED", "filtered": 100, @@ -1518,6 +1525,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1536,6 +1544,7 @@ EXPLAIN "table": { "table_name": "v", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1551,6 +1560,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["id"], "ref": ["test.v.father"], + "loops": 12, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -1565,6 +1575,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["id"], "ref": ["test.v.mother"], + "loops": 12, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -1583,6 +1594,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1598,6 +1610,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["id"], "ref": ["a.father"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -1612,6 +1625,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["id"], "ref": ["a.mother"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -1853,6 +1867,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -1871,6 +1886,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1889,6 +1905,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -2497,6 +2514,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 10, @@ -2533,6 +2551,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 10, "rows": 2, "r_rows": 1, @@ -3910,6 +3929,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -3930,6 +3950,7 @@ ANALYZE "key_length": "23", "used_key_parts": ["a2"], "ref": ["test.t1.a1"], + "loops": 3, "r_loops": 3, "rows": 1, "r_rows": 0.333333333, @@ -3986,6 +4007,7 @@ ANALYZE "table_name": "tt2", "access_type": "ALL", "possible_keys": ["b1"], + "loops": 1, "r_loops": 1, "rows": 14, "r_rows": 14, @@ -4006,6 +4028,7 @@ ANALYZE "key_length": "23", "used_key_parts": ["a2"], "ref": ["test.tt2.b1"], + "loops": 14, "r_loops": 14, "rows": 1, "r_rows": 0.071428571, @@ -4192,6 +4215,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -4219,6 +4243,7 @@ ANALYZE "table": { "table_name": "s", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -4244,6 +4269,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -4264,6 +4290,7 @@ ANALYZE "key_length": "9", "used_key_parts": ["a"], "ref": ["test.t1.c"], + "loops": 4, "r_loops": 4, "rows": 2, "r_rows": 0.5, @@ -4354,6 +4381,7 @@ ANALYZE "table": { "table_name": "tt", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index ab0e09cbec6..5eae44eb028 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -128,6 +128,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -138,6 +139,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -160,6 +162,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -219,6 +222,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -234,6 +238,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -251,6 +256,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -313,6 +319,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -323,6 +330,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -345,6 +353,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -396,6 +405,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -406,6 +416,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -428,6 +439,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -468,6 +480,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -478,6 +491,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -500,6 +514,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -550,6 +565,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -560,6 +576,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -582,6 +599,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -653,6 +671,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -663,6 +682,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -685,6 +705,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -749,6 +770,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -759,6 +781,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -781,6 +804,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -831,6 +855,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -841,6 +866,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -863,6 +889,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -906,6 +933,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -916,6 +944,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -938,6 +967,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -992,6 +1022,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -1007,6 +1038,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1024,6 +1056,7 @@ EXPLAIN "table": { "table_name": "t1_double", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -1066,6 +1099,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -1081,6 +1115,7 @@ EXPLAIN "key_length": "3", "used_key_parts": ["a"], "ref": ["test.t.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1098,6 +1133,7 @@ EXPLAIN "table": { "table_name": "t1_decimal", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -1163,6 +1199,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -1173,6 +1210,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1195,6 +1233,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1267,6 +1306,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -1277,6 +1317,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1299,6 +1340,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1360,6 +1402,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -1370,6 +1413,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1392,6 +1436,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1442,6 +1487,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -1452,6 +1498,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1474,6 +1521,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1534,6 +1582,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -1544,6 +1593,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1566,6 +1616,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -1592,6 +1643,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -1602,6 +1654,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1624,6 +1677,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -1666,6 +1720,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -1681,6 +1736,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t2.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1698,6 +1754,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1736,6 +1793,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -1751,6 +1809,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["max_c"], "ref": ["test.t2.d"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1768,6 +1827,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1813,6 +1873,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -1828,6 +1889,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1844,6 +1906,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1880,6 +1943,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -1895,6 +1959,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["a", "b"], "ref": ["test.t2.a", "test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1911,6 +1976,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -1952,6 +2018,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -1967,6 +2034,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["max_c"], "ref": ["test.t2.c"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1983,6 +2051,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -2020,6 +2089,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2031,6 +2101,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -2049,6 +2120,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -2085,6 +2157,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2096,6 +2169,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -2114,6 +2188,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -2156,6 +2231,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2173,6 +2249,7 @@ EXPLAIN "table": { "table_name": "t1_char", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2191,6 +2268,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 12, "rows": 12, "cost": "COST_REPLACED", "filtered": 100 @@ -2244,6 +2322,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2259,6 +2338,7 @@ EXPLAIN "key_length": "6", "used_key_parts": ["a", "b"], "ref": ["test.t.b", "test.t.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -2275,6 +2355,7 @@ EXPLAIN "table": { "table_name": "t1_decimal", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2328,6 +2409,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2339,6 +2421,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -2360,6 +2443,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -2402,6 +2486,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2417,6 +2502,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["a", "max_c"], "ref": ["test.t2.a", "test.t2.c"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -2433,6 +2519,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -2487,6 +2574,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2498,6 +2586,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -2519,6 +2608,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -2562,6 +2652,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2577,6 +2668,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["max_c"], "ref": ["test.t2.d"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -2594,6 +2686,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -2637,6 +2730,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2652,6 +2746,7 @@ EXPLAIN "key_length": "18", "used_key_parts": ["b", "c"], "ref": ["test.t.c", "test.t.c"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -2669,6 +2764,7 @@ EXPLAIN "table": { "table_name": "t1_double", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2717,6 +2813,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2732,6 +2829,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["c"], "ref": ["test.t.c"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -2749,6 +2847,7 @@ EXPLAIN "table": { "table_name": "t1_double", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2828,6 +2927,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2845,6 +2945,7 @@ EXPLAIN "table": { "table_name": "t1_decimal", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2863,6 +2964,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 9, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -2907,6 +3009,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2922,6 +3025,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["a", "b"], "ref": ["test.t2.a", "test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -2939,6 +3043,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -2988,6 +3093,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -2999,6 +3105,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3019,6 +3126,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3060,6 +3168,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -3075,6 +3184,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["a", "b"], "ref": ["test.t2.a", "test.t2.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -3091,6 +3201,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3146,6 +3257,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -3156,6 +3268,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3177,6 +3290,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3256,6 +3370,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -3266,6 +3381,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3287,6 +3403,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3338,6 +3455,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -3349,6 +3467,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3370,6 +3489,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3420,6 +3540,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -3435,6 +3556,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -3451,6 +3573,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3472,6 +3595,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 18, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -3489,6 +3613,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -3559,6 +3684,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -3570,6 +3696,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3591,6 +3718,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3612,6 +3740,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["v1.b"], + "loops": 180, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -3629,6 +3758,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -3679,6 +3809,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -3689,6 +3820,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3710,6 +3842,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3727,6 +3860,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 180, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3748,6 +3882,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -3802,6 +3937,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -3812,6 +3948,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -3833,6 +3970,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -3850,6 +3988,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 180, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -3872,6 +4011,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -3917,6 +4057,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -3932,6 +4073,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["a", "b"], "ref": ["test.t2.a", "test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -3948,6 +4090,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -3970,6 +4113,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 18, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -3987,6 +4131,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4029,6 +4174,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -4039,6 +4185,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4061,6 +4208,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4083,6 +4231,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["v1.b"], + "loops": 180, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -4099,6 +4248,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4152,6 +4302,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -4169,6 +4320,7 @@ EXPLAIN "table": { "table_name": "t1_char", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -4187,6 +4339,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 12, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -4264,6 +4417,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -4279,6 +4433,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -4296,6 +4451,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4314,6 +4470,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 18, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4335,6 +4492,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -4352,6 +4510,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 360, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4374,6 +4533,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4434,6 +4594,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -4449,6 +4610,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t2.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -4466,6 +4628,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4488,6 +4651,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["v1.a"], + "loops": 18, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -4505,6 +4669,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4598,6 +4763,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -4608,6 +4774,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4630,6 +4797,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4652,6 +4820,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["v1.a"], + "loops": 180, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -4669,6 +4838,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4691,6 +4861,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["v1.b"], + "loops": 360, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -4708,6 +4879,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4776,6 +4948,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -4786,6 +4959,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4808,6 +4982,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4862,6 +5037,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -4877,6 +5053,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -4894,6 +5071,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -4955,6 +5133,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -4970,6 +5149,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t2.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -4987,6 +5167,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5013,6 +5194,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -5024,6 +5206,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5045,6 +5228,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5129,6 +5313,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -5140,6 +5325,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5161,6 +5347,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5187,6 +5374,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -5197,6 +5385,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5219,6 +5408,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -5314,6 +5504,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -5324,6 +5515,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5346,6 +5538,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5372,6 +5565,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -5382,6 +5576,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5404,6 +5599,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -5500,6 +5696,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -5511,6 +5708,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5533,6 +5731,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5559,6 +5758,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -5570,6 +5770,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5592,6 +5793,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5618,6 +5820,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -5633,6 +5836,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["max_c"], "ref": ["test.t2.c"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -5650,6 +5854,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5712,6 +5917,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -5722,6 +5928,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 40, "cost": "COST_REPLACED", "filtered": 100, @@ -5749,6 +5956,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5774,6 +5982,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5841,6 +6050,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -5851,6 +6061,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 40, "cost": "COST_REPLACED", "filtered": 100, @@ -5879,6 +6090,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5904,6 +6116,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -5958,6 +6171,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -5969,6 +6183,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 40, "cost": "COST_REPLACED", "filtered": 100, @@ -5996,6 +6211,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6021,6 +6237,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6073,6 +6290,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -6088,6 +6306,7 @@ EXPLAIN "key_length": "2", "used_key_parts": ["a"], "ref": ["test.t.a"], + "loops": 12, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -6105,6 +6324,7 @@ EXPLAIN "table": { "table_name": "t1_char", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -6161,6 +6381,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -6172,6 +6393,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6193,6 +6415,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6211,6 +6434,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 180, "rows": 40, "cost": "COST_REPLACED", "filtered": 100, @@ -6239,6 +6463,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6264,6 +6489,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6327,6 +6553,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -6342,6 +6569,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 6, "cost": "COST_REPLACED", "filtered": 100, @@ -6365,6 +6593,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6390,6 +6619,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6415,6 +6645,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6523,6 +6754,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -6538,6 +6770,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -6557,6 +6790,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6576,6 +6810,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6662,6 +6897,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -6677,6 +6913,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -6696,6 +6933,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6715,6 +6953,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6769,6 +7008,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -6784,6 +7024,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -6803,6 +7044,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6822,6 +7064,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6873,6 +7116,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -6888,6 +7132,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -6911,6 +7156,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -6932,6 +7178,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7002,6 +7249,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -7017,6 +7265,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -7040,6 +7289,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7061,6 +7311,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7133,6 +7384,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7149,6 +7401,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7166,6 +7419,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7191,6 +7445,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 20, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7212,6 +7467,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7262,6 +7518,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -7277,6 +7534,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -7292,6 +7550,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7309,6 +7568,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7338,6 +7598,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 18, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -7355,6 +7616,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7407,6 +7669,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -7422,6 +7685,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -7439,6 +7703,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7456,6 +7721,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7485,6 +7751,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 18, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -7502,6 +7769,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7639,6 +7907,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -7649,6 +7918,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7670,6 +7940,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7687,6 +7958,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7716,6 +7988,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["v4.a"], + "loops": 180, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -7733,6 +8006,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -7778,6 +8052,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7795,6 +8070,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7812,6 +8088,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7837,6 +8114,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 20, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -7857,6 +8135,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7904,6 +8183,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7921,6 +8201,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7938,6 +8219,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -7967,6 +8249,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["v4.a"], + "loops": 20, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -7983,6 +8266,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8030,6 +8314,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8046,6 +8331,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8063,6 +8349,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8092,6 +8379,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["v4.a"], + "loops": 20, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -8108,6 +8396,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8155,6 +8444,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8171,6 +8461,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8188,6 +8479,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8217,6 +8509,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["v4.a"], + "loops": 20, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -8233,6 +8526,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8288,6 +8582,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8305,6 +8600,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8322,6 +8618,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8351,6 +8648,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["max_c"], "ref": ["v4.min_c"], + "loops": 20, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -8367,6 +8665,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8421,6 +8720,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -8436,6 +8736,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["min_c"], "ref": ["test.t2.c"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -8453,6 +8754,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8470,6 +8772,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8495,6 +8798,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 18, "rows": 20, "cost": "COST_REPLACED", "filtered": 100 @@ -8515,6 +8819,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -8686,6 +8991,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 50, @@ -8709,6 +9015,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["c"], "ref": ["func"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -8721,6 +9028,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -8790,6 +9098,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 50, @@ -8813,6 +9122,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "ref": ["func"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -8829,6 +9139,7 @@ EXPLAIN "table": { "table_name": "t4", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -8891,6 +9202,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -8904,6 +9216,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -8950,6 +9263,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -8964,6 +9278,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t1.a"], + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -8977,6 +9292,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -9010,6 +9326,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9023,6 +9340,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9075,6 +9393,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9097,6 +9416,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk2"], "ref": ["func"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9109,6 +9429,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -9143,6 +9464,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9165,6 +9487,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk2"], "ref": ["func"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9177,6 +9500,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -9233,6 +9557,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9246,6 +9571,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9295,6 +9621,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -9312,6 +9639,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -9377,6 +9705,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9390,6 +9719,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9448,6 +9778,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9461,6 +9792,7 @@ EXPLAIN "table": { "table_name": "t", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9477,6 +9809,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -9498,6 +9831,7 @@ EXPLAIN "key": "PRIMARY", "key_length": "4", "used_key_parts": ["pk"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -9555,6 +9889,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9568,6 +9903,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9626,6 +9962,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9639,6 +9976,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9692,6 +10030,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9705,6 +10044,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9758,6 +10098,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9771,6 +10112,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9826,6 +10168,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9839,6 +10182,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9892,6 +10236,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9905,6 +10250,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9958,6 +10304,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -9971,6 +10318,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -10007,6 +10355,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10020,6 +10369,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10106,6 +10456,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10119,6 +10470,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10141,6 +10493,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10173,6 +10526,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10186,6 +10540,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -10207,6 +10562,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 128, "cost": "COST_REPLACED", "filtered": 100, @@ -10355,6 +10711,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -10370,6 +10727,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t1.a"], + "loops": 7, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10385,6 +10743,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -10420,6 +10779,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -10435,6 +10795,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t1.a"], + "loops": 7, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10450,6 +10811,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -10488,6 +10850,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -10503,6 +10866,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t1.a"], + "loops": 7, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10516,6 +10880,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -10550,6 +10915,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -10565,6 +10931,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["m"], "ref": ["test.t1.a"], + "loops": 7, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10581,6 +10948,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -10618,6 +10986,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10632,6 +11001,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -10675,6 +11045,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["i1"], "ref": ["const"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -10686,6 +11057,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10703,6 +11075,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10743,6 +11116,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -10757,6 +11131,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -10802,6 +11177,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -10817,6 +11193,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["id2"], "ref": ["test.t1.id2"], + "loops": 4, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10834,6 +11211,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -10906,6 +11284,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -10917,6 +11296,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 2, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -10935,6 +11315,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -10996,6 +11377,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -11007,6 +11389,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 2, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -11025,6 +11408,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -11118,6 +11502,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -11133,6 +11518,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["e", "max_f"], "ref": ["test.t1.a", "test.t1.b"], + "loops": 5, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -11149,6 +11535,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -11221,6 +11608,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -11236,6 +11624,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["e", "max_f"], "ref": ["test.t1.a", "test.t1.b"], + "loops": 5, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -11252,6 +11641,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -11323,6 +11713,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -11338,6 +11729,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "max_f"], "ref": ["test.t1.a", "test.t1.b"], + "loops": 5, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -11352,6 +11744,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -11368,6 +11761,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -11446,6 +11840,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -11461,6 +11856,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "max_f"], "ref": ["test.t1.a", "test.t1.b"], + "loops": 5, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -11475,6 +11871,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -11492,6 +11889,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -11561,6 +11959,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -11578,6 +11977,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -11622,6 +12022,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -11639,6 +12040,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -11683,6 +12085,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -11699,6 +12102,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -11742,6 +12146,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -11758,6 +12163,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -11821,6 +12227,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -11836,6 +12243,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -11851,6 +12259,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -11894,6 +12303,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -11909,6 +12319,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -11924,6 +12335,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -12030,6 +12442,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -12046,6 +12459,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -12080,6 +12494,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -12095,6 +12510,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["c"], "ref": ["test.t2.a"], + "loops": 5, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -12111,6 +12527,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -12148,6 +12565,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -12157,6 +12575,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 5, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -12170,6 +12589,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -12227,6 +12647,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -12244,6 +12665,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -12288,6 +12710,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -12305,6 +12728,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -12349,6 +12773,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -12366,6 +12791,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -12410,6 +12836,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -12426,6 +12853,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -12491,6 +12919,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 144, "cost": "COST_REPLACED", "filtered": 100, @@ -12504,6 +12933,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -12516,6 +12946,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100 @@ -12531,6 +12962,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 12, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -12581,6 +13013,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -12594,6 +13027,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100, @@ -12609,6 +13043,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["f"], "ref": ["test.t1.f"], + "loops": 8, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -12621,6 +13056,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100, @@ -12673,6 +13109,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -12688,6 +13125,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["f2"], "ref": ["test.t1.f2"], + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -12700,6 +13138,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -12733,6 +13172,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -12748,6 +13188,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["f2"], "ref": ["test.t1.f2"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -12761,6 +13202,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -12818,6 +13260,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -13026,6 +13469,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -13048,6 +13492,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["const"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -13071,6 +13516,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["const"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -13116,6 +13562,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -13133,6 +13580,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -13173,6 +13621,7 @@ EXPLAIN "table": { "table_name": "t4", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -13188,6 +13637,7 @@ EXPLAIN "key_length": "23", "used_key_parts": ["a", "f1(a)", "sum(b)"], "ref": ["test.t4.a", "test.t4.b", "test.t4.c"], + "loops": 3, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -13204,6 +13654,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -13275,6 +13726,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -13290,6 +13742,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -13312,6 +13765,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13337,6 +13791,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13384,6 +13839,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -13395,6 +13851,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13422,6 +13879,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13447,6 +13905,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13493,6 +13952,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -13504,6 +13964,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13531,6 +13992,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13556,6 +14018,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13604,6 +14067,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -13619,6 +14083,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -13642,6 +14107,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13667,6 +14133,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13716,6 +14183,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -13731,6 +14199,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -13754,6 +14223,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13779,6 +14249,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13829,6 +14300,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -13844,6 +14316,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -13867,6 +14340,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13892,6 +14366,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -13948,6 +14423,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -13963,6 +14439,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -13986,6 +14463,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14011,6 +14489,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14089,6 +14568,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -14099,6 +14579,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14127,6 +14608,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14152,6 +14634,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14259,6 +14742,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -14274,6 +14758,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t2.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -14297,6 +14782,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14322,6 +14808,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14381,6 +14868,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -14396,6 +14884,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -14418,6 +14907,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14443,6 +14933,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14492,6 +14983,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -14503,6 +14995,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14530,6 +15023,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14555,6 +15049,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14603,6 +15098,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -14614,6 +15110,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14641,6 +15138,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14666,6 +15164,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14718,6 +15217,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -14733,6 +15233,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -14756,6 +15257,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14781,6 +15283,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14830,6 +15333,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -14845,6 +15349,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -14868,6 +15373,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14893,6 +15399,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -14945,6 +15452,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -14960,6 +15468,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -14983,6 +15492,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15008,6 +15518,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15064,6 +15575,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -15079,6 +15591,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -15102,6 +15615,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15127,6 +15641,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15203,6 +15718,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -15213,6 +15729,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 9, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15241,6 +15758,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15266,6 +15784,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15369,6 +15888,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -15384,6 +15904,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t2.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -15407,6 +15928,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15432,6 +15954,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15493,6 +16016,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -15508,6 +16032,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -15531,6 +16056,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15552,6 +16078,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15575,6 +16102,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15600,6 +16128,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15670,6 +16199,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -15685,6 +16215,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -15708,6 +16239,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15733,6 +16265,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15758,6 +16291,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15817,6 +16351,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -15832,6 +16367,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -15855,6 +16391,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15880,6 +16417,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15905,6 +16443,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -15966,6 +16505,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -15981,6 +16521,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -16004,6 +16545,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16029,6 +16571,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16054,6 +16597,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16113,6 +16657,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -16128,6 +16673,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -16151,6 +16697,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16176,6 +16723,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16201,6 +16749,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16260,6 +16809,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -16275,6 +16825,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -16298,6 +16849,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16319,6 +16871,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16342,6 +16895,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16367,6 +16921,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16439,6 +16994,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -16454,6 +17010,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -16477,6 +17034,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16498,6 +17056,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16521,6 +17080,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16546,6 +17106,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16580,6 +17141,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16640,6 +17202,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -16655,6 +17218,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -16672,6 +17236,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16695,6 +17260,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16720,6 +17286,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16787,6 +17354,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -16802,6 +17370,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -16819,6 +17388,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16842,6 +17412,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16867,6 +17438,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16930,6 +17502,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -16945,6 +17518,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -16968,6 +17542,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -16993,6 +17568,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -17049,6 +17625,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -17064,6 +17641,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -17087,6 +17665,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -17112,6 +17691,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -17170,6 +17750,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -17185,6 +17766,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -17208,6 +17790,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -17233,6 +17816,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -17293,6 +17877,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -17308,6 +17893,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 9, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -17331,6 +17917,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -17356,6 +17943,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -17381,6 +17969,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 100, @@ -17446,6 +18035,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -17461,6 +18051,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t2.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -17478,6 +18069,7 @@ EXPLAIN "key": "i1", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -17530,6 +18122,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -17545,6 +18138,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t2.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -17568,6 +18162,7 @@ EXPLAIN "key": "i1", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -17591,6 +18186,7 @@ EXPLAIN "key": "i1", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -17647,6 +18243,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -17662,6 +18259,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t2.b"], + "loops": 9, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -17685,6 +18283,7 @@ EXPLAIN "key": "i1", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -17708,6 +18307,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -17787,6 +18387,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -17810,6 +18411,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 80, @@ -17906,6 +18508,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 32, "cost": "COST_REPLACED", "filtered": 100, @@ -17933,6 +18536,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 80, @@ -17964,6 +18568,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 80, @@ -18020,6 +18625,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100, @@ -18035,6 +18641,7 @@ EXPLAIN "key_length": "24", "used_key_parts": ["a", "c"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 8, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -18056,6 +18663,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -18165,6 +18773,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 48, "cost": "COST_REPLACED", "filtered": 100, @@ -18192,6 +18801,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 80, @@ -18223,6 +18833,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 80, @@ -18249,6 +18860,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 80, @@ -18322,6 +18934,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -18345,6 +18958,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 80, @@ -18414,6 +19028,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -18437,6 +19052,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 80, @@ -18506,6 +19122,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -18533,6 +19150,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 20, "cost": "COST_REPLACED", "filtered": 100, @@ -18629,6 +19247,7 @@ EXPLAIN "key": "idx_b", "key_length": "5", "used_key_parts": ["b"], + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -18645,6 +19264,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 4, "rows": 2, "cost": "COST_REPLACED", "filtered": 50, @@ -18664,6 +19284,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -18752,6 +19373,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "possible_keys": ["idx_b"], + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 83.33333588, @@ -18767,6 +19389,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 10, "rows": 2, "cost": "COST_REPLACED", "filtered": 50, @@ -18786,6 +19409,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -18871,6 +19495,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100 @@ -18885,6 +19510,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 12, "rows": 2, "cost": "COST_REPLACED", "filtered": 50, @@ -18905,6 +19531,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -18982,6 +19609,7 @@ EXPLAIN "key": "idx_b", "key_length": "5", "used_key_parts": ["b"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -18998,6 +19626,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -19017,6 +19646,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -19073,6 +19703,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "possible_keys": ["idx_b"], + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 83.33333588, @@ -19088,6 +19719,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], + "loops": 10, "rows": 2, "cost": "COST_REPLACED", "filtered": 50, @@ -19107,6 +19739,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -19166,6 +19799,7 @@ EXPLAIN "key": "idx_b", "key_length": "5", "used_key_parts": ["b"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -19182,6 +19816,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -19201,6 +19836,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -19257,6 +19893,7 @@ EXPLAIN "table_name": "t3", "access_type": "ALL", "possible_keys": ["idx_b"], + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 83.33333588, @@ -19272,6 +19909,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], + "loops": 10, "rows": 2, "cost": "COST_REPLACED", "filtered": 50, @@ -19291,6 +19929,7 @@ EXPLAIN "key_length": "133", "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -19361,6 +20000,7 @@ EXPLAIN "key": "idx", "key_length": "133", "used_key_parts": ["c", "b"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -19377,6 +20017,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -19392,6 +20033,7 @@ EXPLAIN "key_length": "128", "used_key_parts": ["c"], "ref": ["test.t3.c"], + "loops": 3, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -19411,6 +20053,7 @@ EXPLAIN "key_length": "128", "used_key_parts": ["c"], "ref": ["test.t3.c"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -19523,6 +20166,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 90, "cost": "COST_REPLACED", "filtered": 60, @@ -19538,6 +20182,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 53.99999991, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -19553,6 +20198,7 @@ EXPLAIN "key_length": "128", "used_key_parts": ["c"], "ref": ["test.t3.c"], + "loops": 80.99999987, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -19569,6 +20215,7 @@ EXPLAIN "table_name": "t4", "access_type": "ALL", "possible_keys": ["idx_c"], + "loops": 1, "rows": 160, "cost": "COST_REPLACED", "filtered": 100 @@ -19645,6 +20292,7 @@ EXPLAIN "key": "idx", "key_length": "133", "used_key_parts": ["c", "b"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -19661,6 +20309,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -19676,6 +20325,7 @@ EXPLAIN "key_length": "128", "used_key_parts": ["c"], "ref": ["test.t3.c"], + "loops": 3, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -19704,6 +20354,7 @@ EXPLAIN "key_length": "128", "used_key_parts": ["c"], "ref": ["test.t3.c"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -20058,6 +20709,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 90, "cost": "COST_REPLACED", "filtered": 60, @@ -20073,6 +20725,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.a"], + "loops": 53.99999991, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -20088,6 +20741,7 @@ EXPLAIN "key_length": "128", "used_key_parts": ["c"], "ref": ["test.t3.c"], + "loops": 80.99999987, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -20110,6 +20764,7 @@ EXPLAIN "table_name": "t4", "access_type": "ALL", "possible_keys": ["idx_c"], + "loops": 1, "rows": 160, "cost": "COST_REPLACED", "filtered": 100 @@ -20185,6 +20840,7 @@ EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -20201,6 +20857,7 @@ EXPLAIN "key_length": "128", "used_key_parts": ["c"], "ref": ["test.t4.c"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 50, @@ -20222,6 +20879,7 @@ EXPLAIN "key_length": "128", "used_key_parts": ["c"], "ref": ["test.t4.c"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -20247,6 +20905,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -20257,6 +20916,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 3, "rows": 4, "cost": "COST_REPLACED", "filtered": 100 @@ -20359,6 +21019,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "possible_keys": ["PRIMARY"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -20374,6 +21035,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk2"], "ref": ["test.t1.pk1"], + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -20392,6 +21054,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk2"], "ref": ["test.t1.pk1"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -20808,6 +21471,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 2, @@ -20836,6 +21500,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -20919,6 +21584,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -20934,6 +21600,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t3.id"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -20959,6 +21626,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 1007, "cost": "COST_REPLACED", "filtered": 100 @@ -20978,6 +21646,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t3.id"], + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -20993,6 +21662,7 @@ EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -21034,6 +21704,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -21049,6 +21720,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t3.id"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -21074,6 +21746,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 1007, "cost": "COST_REPLACED", "filtered": 100 @@ -21093,6 +21766,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t3.id"], + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -21112,6 +21786,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t1.a"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -21257,6 +21932,7 @@ EXPLAIN "key": "t1_id", "key_length": "5", "used_key_parts": ["t1_id"], + "loops": 1, "rows": 47, "cost": "COST_REPLACED", "filtered": 100, @@ -21273,6 +21949,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["id"], "ref": ["test.t3.t1_id"], + "loops": 47, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -21288,6 +21965,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["t1_id"], "ref": ["test.t3.t1_id"], + "loops": 47, "rows": 2, "cost": "COST_REPLACED", "filtered": 50, @@ -21306,6 +21984,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["t1_id"], "ref": ["test.t1.id"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 34.55045319, @@ -21505,6 +22184,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["to_ledger_id"], "ref": ["const"], + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100 @@ -21519,6 +22199,7 @@ EXPLAIN "key_length": "17", "used_key_parts": ["ledger_id", "charge_id"], "ref": ["test.charges.from_ledger_id", "test.charges.id"], + "loops": 8, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -21537,6 +22218,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["charge_id"], "ref": ["test.charges.id"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -21551,6 +22233,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["id"], "ref": ["test.transaction_items.transaction_id"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -21704,6 +22387,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["to_ledger_id"], "ref": ["const"], + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -21718,6 +22402,7 @@ EXPLAIN "key_length": "18", "used_key_parts": ["ledger_id", "charge_id"], "ref": ["test.charges.from_ledger_id", "test.charges.id"], + "loops": 10, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -21736,6 +22421,7 @@ EXPLAIN "key_length": "9", "used_key_parts": ["charge_id"], "ref": ["test.charges.id"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -21750,6 +22436,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["id"], "ref": ["test.transaction_items.transaction_id"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index 3329fb7552d..d1816e93009 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -387,6 +387,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -402,6 +403,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["f1"], "ref": ["test.t2.f2"], + "loops": 11, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -417,6 +419,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -496,6 +499,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -511,6 +515,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -527,6 +532,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -583,6 +589,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -599,6 +606,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -621,6 +629,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["f1"], "ref": ["tt.f1"], + "loops": 11, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -636,6 +645,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -731,6 +741,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -747,6 +758,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -763,6 +775,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -792,6 +805,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["f1"], "ref": ["x.f1"], + "loops": 11, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -807,6 +821,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -823,6 +838,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -888,6 +904,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -904,6 +921,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -978,6 +996,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -993,6 +1012,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["f1"], "ref": ["test.t2.f2"], + "loops": 11, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1008,6 +1028,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result index 416c7eab8d4..ec7d085c70f 100644 --- a/mysql-test/main/except.result +++ b/mysql-test/main/except.result @@ -43,6 +43,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "REPLACED", "filtered": 100 @@ -61,6 +62,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "REPLACED", "filtered": 100 @@ -97,6 +99,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -122,6 +125,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -155,6 +159,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 1, @@ -182,6 +187,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -207,6 +213,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -301,6 +308,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "REPLACED", "filtered": 100 @@ -311,6 +319,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 2, "rows": 2, "cost": "REPLACED", "filtered": 100 @@ -333,6 +342,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "REPLACED", "filtered": 100 @@ -343,6 +353,7 @@ EXPLAIN "table": { "table_name": "t4", "access_type": "ALL", + "loops": 2, "rows": 2, "cost": "REPLACED", "filtered": 100 @@ -383,6 +394,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -398,6 +410,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 2, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -429,6 +442,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -444,6 +458,7 @@ ANALYZE "table": { "table_name": "t4", "access_type": "ALL", + "loops": 2, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -484,6 +499,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 3, @@ -511,6 +527,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -526,6 +543,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 2, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -557,6 +575,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -572,6 +591,7 @@ ANALYZE "table": { "table_name": "t4", "access_type": "ALL", + "loops": 2, "r_loops": 1, "rows": 2, "r_rows": 2, diff --git a/mysql-test/main/except_all.result b/mysql-test/main/except_all.result index 522ed7cedfc..f79f35ee932 100644 --- a/mysql-test/main/except_all.result +++ b/mysql-test/main/except_all.result @@ -71,6 +71,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100 @@ -89,6 +90,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100 @@ -132,6 +134,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 7, "r_rows": 4, @@ -159,6 +162,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 7, "r_rows": 7, @@ -184,6 +188,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 7, "r_rows": 7, @@ -222,6 +227,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 7, "r_rows": 4, @@ -249,6 +255,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 7, "r_rows": 7, @@ -274,6 +281,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 7, "r_rows": 7, @@ -409,6 +417,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100, @@ -427,6 +436,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -437,6 +447,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 3, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -459,6 +470,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -469,6 +481,7 @@ EXPLAIN "table": { "table_name": "t4", "access_type": "ALL", + "loops": 2, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -514,6 +527,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -529,6 +543,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 3, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -560,6 +575,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -575,6 +591,7 @@ ANALYZE "table": { "table_name": "t4", "access_type": "ALL", + "loops": 2, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -614,6 +631,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 9, "r_rows": 7, @@ -641,6 +659,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -656,6 +675,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 3, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -687,6 +707,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -702,6 +723,7 @@ ANALYZE "table": { "table_name": "t4", "access_type": "ALL", + "loops": 2, "r_loops": 1, "rows": 3, "r_rows": 3, diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index e2ebe9fbc9b..b53b5241077 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -12,6 +12,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -41,6 +42,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -69,6 +71,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -84,6 +87,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t0.a"], + "loops": 10, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -110,6 +114,7 @@ EXPLAIN "key": "a1", "key_length": "5", "used_key_parts": ["a1"], + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -148,6 +153,7 @@ EXPLAIN } ] }, + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -186,6 +192,7 @@ EXPLAIN } ] }, + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -225,6 +232,7 @@ EXPLAIN } ] }, + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -246,6 +254,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -261,6 +270,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["b1", "b2"], "ref": ["test.t0.a", "const"], + "loops": 10, "rows": 1, "cost": "COST_REPLACED", "filtered": 100 @@ -290,6 +300,7 @@ EXPLAIN "table": { "table_name": "A", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -308,6 +319,7 @@ EXPLAIN "table": { "table_name": "B", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -335,6 +347,7 @@ EXPLAIN "table": { "table_name": "A", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -353,6 +366,7 @@ EXPLAIN "table": { "table_name": "B", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -381,6 +395,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -399,6 +414,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -425,6 +441,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -444,6 +461,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -475,6 +493,7 @@ EXPLAIN "table": { "table_name": "tbl1", "access_type": "ALL", + "loops": 1, "rows": 100, "cost": "COST_REPLACED", "filtered": 100, @@ -486,6 +505,7 @@ EXPLAIN "table": { "table_name": "tbl2", "access_type": "ALL", + "loops": 100, "rows": 100, "cost": "COST_REPLACED", "filtered": 100, @@ -581,6 +601,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -611,6 +632,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -628,6 +650,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -656,6 +679,7 @@ EXPLAIN "table": { "table_name": "tbl2", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -671,6 +695,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["cnt"], "ref": ["test.tbl2.a"], + "loops": 10, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -687,6 +712,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -717,6 +743,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -732,6 +759,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["max(a)"], "ref": ["test.t1.a"], + "loops": 10, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -746,6 +774,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -777,6 +806,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -806,6 +836,7 @@ EXPLAIN "key": "PRIMARY", "key_length": "8", "used_key_parts": ["seq"], + "loops": 1, "rows": 100, "cost": "COST_REPLACED", "filtered": 100, @@ -822,6 +853,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 10, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -854,6 +886,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -864,6 +897,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 10, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -900,6 +934,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -912,6 +947,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 10, "rows": 10, "cost": "COST_REPLACED", "filtered": 10 @@ -951,6 +987,7 @@ EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -975,6 +1012,7 @@ EXPLAIN "table": { "table_name": "tbl1", "access_type": "ALL", + "loops": 1, "rows": 100, "cost": "COST_REPLACED", "filtered": 100 @@ -987,6 +1025,7 @@ EXPLAIN "table_name": "tbl2", "access_type": "ALL", "possible_keys": ["a"], + "loops": 100, "rows": 100, "cost": "COST_REPLACED", "filtered": 100 @@ -1019,6 +1058,7 @@ EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1044,6 +1084,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["func"], + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -1057,6 +1098,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 3, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -1097,6 +1139,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1113,6 +1156,7 @@ EXPLAIN "table": { "table_name": "tbl1", "access_type": "ALL", + "loops": 1, "rows": 100, "cost": "COST_REPLACED", "filtered": 100 @@ -1123,6 +1167,7 @@ EXPLAIN "table": { "table_name": "tbl2", "access_type": "ALL", + "loops": 100, "rows": 100, "cost": "COST_REPLACED", "filtered": 100 @@ -1159,6 +1204,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1177,6 +1223,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1226,6 +1273,7 @@ EXPLAIN "key": "a", "key_length": "10", "used_key_parts": ["a", "b"], + "loops": 1, "rows": 101, "cost": "COST_REPLACED", "filtered": 100, @@ -1254,6 +1302,7 @@ ANALYZE "key": "a", "key_length": "10", "used_key_parts": ["a", "b"], + "loops": 1, "r_loops": 1, "rows": 101, "r_rows": 100, @@ -1341,6 +1390,7 @@ EXPLAIN "key": "idx_t1_2", "key_length": "147", "used_key_parts": ["a1", "a2", "b"], + "loops": 1, "rows": 17, "cost": "COST_REPLACED", "filtered": 100, @@ -1365,6 +1415,7 @@ EXPLAIN "key": "idx_t1_1", "key_length": "163", "used_key_parts": ["a1", "a2", "b", "c"], + "loops": 1, "rows": 128, "cost": "COST_REPLACED", "filtered": 0.198364258, @@ -1390,6 +1441,7 @@ EXPLAIN "key": "idx_t1_1", "key_length": "147", "used_key_parts": ["a1", "a2", "b"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1417,6 +1469,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1443,6 +1496,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1482,6 +1536,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 256, "cost": "COST_REPLACED", "filtered": 100 @@ -1507,6 +1562,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 256, "cost": "COST_REPLACED", "filtered": 100 @@ -1543,6 +1599,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 256, "cost": "COST_REPLACED", "filtered": 100 @@ -1630,6 +1687,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -1669,6 +1727,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -1700,6 +1759,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -1714,6 +1774,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk"], "ref": ["test.t1.a"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1742,6 +1803,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -1761,6 +1823,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["pk"], "ref": ["test.t1.a"], + "loops": 2, "r_loops": 2, "rows": 1, "r_rows": 1, @@ -1796,6 +1859,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1811,6 +1875,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk"], "ref": ["test.t1.a"], + "loops": 2, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1840,6 +1905,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -1860,6 +1926,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["pk"], "ref": ["test.t1.a"], + "loops": 2, "r_loops": 2, "rows": 1, "r_rows": 1, @@ -1907,6 +1974,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -1923,6 +1991,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t3.a"], + "loops": 10, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1954,6 +2023,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -1975,6 +2045,7 @@ ANALYZE "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t3.a"], + "loops": 10, "r_loops": 1, "rows": 1, "r_rows": 10, @@ -2018,6 +2089,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -2037,6 +2109,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -2070,6 +2143,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -2094,6 +2168,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -2118,6 +2193,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -2147,6 +2223,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -2159,6 +2236,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 2, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -2174,6 +2252,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 4, "rows": 2, "cost": "COST_REPLACED", "filtered": 25 diff --git a/mysql-test/main/explain_json_format_partitions.result b/mysql-test/main/explain_json_format_partitions.result index e2cf420c906..858b2539eb0 100644 --- a/mysql-test/main/explain_json_format_partitions.result +++ b/mysql-test/main/explain_json_format_partitions.result @@ -19,6 +19,7 @@ EXPLAIN "table_name": "t1", "partitions": ["p0"], "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -45,6 +46,7 @@ ANALYZE "table_name": "t1", "partitions": ["p0"], "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, diff --git a/mysql-test/main/explain_json_innodb.result b/mysql-test/main/explain_json_innodb.result index 04b05a4b8c0..d59b8aac0c9 100644 --- a/mysql-test/main/explain_json_innodb.result +++ b/mysql-test/main/explain_json_innodb.result @@ -22,6 +22,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -38,6 +39,7 @@ EXPLAIN "table": { "table_name": "tbl_alias1", "access_type": "ALL", + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -56,6 +58,7 @@ EXPLAIN "test.tbl_alias1.column_name_2", "test.tbl_alias1.column_name_1" ], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/fetch_first.result b/mysql-test/main/fetch_first.result index 1e1bb358e97..dde04bfb05b 100644 --- a/mysql-test/main/fetch_first.result +++ b/mysql-test/main/fetch_first.result @@ -465,6 +465,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 8, "r_rows": 8, diff --git a/mysql-test/main/having_cond_pushdown.result b/mysql-test/main/having_cond_pushdown.result index 576183d1d8b..15b49b7ba2f 100644 --- a/mysql-test/main/having_cond_pushdown.result +++ b/mysql-test/main/having_cond_pushdown.result @@ -43,6 +43,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -71,6 +72,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -115,6 +117,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -138,6 +141,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -185,6 +189,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -213,6 +218,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -264,6 +270,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -294,6 +301,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -345,6 +353,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -375,6 +384,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -423,6 +433,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -453,6 +464,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -500,6 +512,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -530,6 +543,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -574,6 +588,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -599,6 +614,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -641,6 +657,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -666,6 +683,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -711,6 +729,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -741,6 +760,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -790,6 +810,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -820,6 +841,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -864,6 +886,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -889,6 +912,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -935,6 +959,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -965,6 +990,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1020,6 +1046,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -1035,6 +1062,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.x"], + "loops": 4, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1050,6 +1078,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1085,6 +1114,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -1100,6 +1130,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.x"], + "loops": 4, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1115,6 +1146,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1177,6 +1209,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -1192,6 +1225,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.x"], + "loops": 4, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1209,6 +1243,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -1243,6 +1278,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -1258,6 +1294,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.x"], + "loops": 4, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -1275,6 +1312,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -1337,6 +1375,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1352,6 +1391,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["x", "MAX(t2.y)"], "ref": ["test.t1.a", "test.t1.b"], + "loops": 5, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1366,6 +1406,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -1401,6 +1442,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1416,6 +1458,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["x", "MAX(t2.y)"], "ref": ["test.t1.a", "test.t1.b"], + "loops": 5, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1430,6 +1473,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -1490,6 +1534,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1505,6 +1550,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["x", "MAX(t2.y)"], "ref": ["test.t1.a", "test.t1.b"], + "loops": 5, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1520,6 +1566,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -1555,6 +1602,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1570,6 +1618,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["x", "MAX(t2.y)"], "ref": ["test.t1.a", "test.t1.b"], + "loops": 5, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1585,6 +1634,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -1640,6 +1690,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1669,6 +1720,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1713,6 +1765,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1738,6 +1791,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1783,6 +1837,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1810,6 +1865,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1853,6 +1909,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1876,6 +1933,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1921,6 +1979,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -1951,6 +2010,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2004,6 +2064,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2032,6 +2093,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2083,6 +2145,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2111,6 +2174,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2162,6 +2226,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2192,6 +2257,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2246,6 +2312,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2276,6 +2343,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2346,6 +2414,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -2374,6 +2443,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -2422,6 +2492,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2450,6 +2521,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2500,6 +2572,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2528,6 +2601,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2577,6 +2651,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2605,6 +2680,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2656,6 +2732,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2684,6 +2761,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2732,6 +2810,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2760,6 +2839,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2810,6 +2890,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2838,6 +2919,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2885,6 +2967,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2915,6 +2998,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2964,6 +3048,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2994,6 +3079,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3039,6 +3125,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3064,6 +3151,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3107,6 +3195,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3132,6 +3221,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3174,6 +3264,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3199,6 +3290,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3253,6 +3345,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3281,6 +3374,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3329,6 +3423,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3352,6 +3447,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3401,6 +3497,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3429,6 +3526,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3477,6 +3575,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3500,6 +3599,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3593,6 +3693,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3616,6 +3717,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3667,6 +3769,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3695,6 +3798,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3743,6 +3847,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3766,6 +3871,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3813,6 +3919,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3836,6 +3943,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -3927,6 +4035,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -3950,6 +4059,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -3999,6 +4109,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4027,6 +4138,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4126,6 +4238,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4154,6 +4267,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4203,6 +4317,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4226,6 +4341,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4277,6 +4393,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4305,6 +4422,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4354,6 +4472,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4377,6 +4496,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4429,6 +4549,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4460,6 +4581,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4509,6 +4631,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4538,6 +4661,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4586,6 +4710,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4610,6 +4735,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4656,6 +4782,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -4682,6 +4809,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -4728,6 +4856,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -4752,6 +4881,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -4804,6 +4934,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4835,6 +4966,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4889,6 +5021,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4918,6 +5051,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -4972,6 +5106,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -5001,6 +5136,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -5049,6 +5185,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -5072,6 +5209,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -5118,6 +5256,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -5142,6 +5281,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -5332,6 +5472,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -5361,6 +5502,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -5410,6 +5552,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -5439,6 +5582,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -5529,6 +5673,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -5573,6 +5718,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -5650,6 +5796,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -5667,6 +5814,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -5698,6 +5846,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -5715,6 +5864,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -5747,6 +5897,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -5764,6 +5915,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -5792,6 +5944,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100, @@ -5809,6 +5962,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result index 906aed4f485..195d9db22de 100644 --- a/mysql-test/main/in_subq_cond_pushdown.result +++ b/mysql-test/main/in_subq_cond_pushdown.result @@ -57,6 +57,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -72,6 +73,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -87,6 +89,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -161,6 +164,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -176,6 +180,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -191,6 +196,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -267,6 +273,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -282,6 +289,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -297,6 +305,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -371,6 +380,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -386,6 +396,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -401,6 +412,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -477,6 +489,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -492,6 +505,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -507,6 +521,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -581,6 +596,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -596,6 +612,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["v1_x", "MAX(v1_y)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -611,6 +628,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100, @@ -686,6 +704,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100, @@ -697,6 +716,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 8, "rows": 16, "cost": "COST_REPLACED", "filtered": 100 @@ -716,6 +736,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t3.y"], + "loops": 128, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -731,6 +752,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -807,6 +829,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -822,6 +845,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -836,6 +860,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -912,6 +937,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -927,6 +953,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -941,6 +968,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1019,6 +1047,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -1034,6 +1063,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1048,6 +1078,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1122,6 +1153,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -1137,6 +1169,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1151,6 +1184,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1225,6 +1259,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -1240,6 +1275,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1254,6 +1290,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1328,6 +1365,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -1343,6 +1381,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1357,6 +1396,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1431,6 +1471,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -1446,6 +1487,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["const", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1459,6 +1501,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1532,6 +1575,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -1547,6 +1591,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1561,6 +1606,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1633,6 +1679,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -1648,6 +1695,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["v1_x", "MAX(v1_y)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1662,6 +1710,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100, @@ -1739,6 +1788,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100, @@ -1750,6 +1800,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 8, "rows": 16, "cost": "COST_REPLACED", "filtered": 100 @@ -1769,6 +1820,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t3.x", "test.t1.c"], + "loops": 128, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1783,6 +1835,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1858,6 +1911,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -1873,6 +1927,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1888,6 +1943,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -1962,6 +2018,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -1977,6 +2034,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -1992,6 +2050,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2068,6 +2127,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -2083,6 +2143,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -2098,6 +2159,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2172,6 +2234,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -2187,6 +2250,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -2202,6 +2266,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2280,6 +2345,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -2295,6 +2361,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -2310,6 +2377,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2384,6 +2452,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -2399,6 +2468,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -2414,6 +2484,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2488,6 +2559,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -2503,6 +2575,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -2517,6 +2590,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2591,6 +2665,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -2606,6 +2681,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -2620,6 +2696,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2694,6 +2771,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -2709,6 +2787,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -2723,6 +2802,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2799,6 +2879,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -2814,6 +2895,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -2828,6 +2910,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -2908,6 +2991,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -2923,6 +3007,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["e", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -2937,6 +3022,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3015,6 +3101,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -3030,6 +3117,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "MAX(v2.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -3045,6 +3133,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3062,6 +3151,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3146,6 +3236,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -3161,6 +3252,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "MAX(v2.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -3175,6 +3267,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3192,6 +3285,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3277,6 +3371,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -3292,6 +3387,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "MAX(v2.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -3307,6 +3403,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3324,6 +3421,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3432,6 +3530,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -3447,6 +3546,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -3461,6 +3561,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3478,6 +3579,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100 @@ -3604,6 +3706,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -3619,6 +3722,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -3633,6 +3737,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3650,6 +3755,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100 @@ -3777,6 +3883,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -3792,6 +3899,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -3806,6 +3914,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3823,6 +3932,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100 @@ -3932,6 +4042,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100, @@ -3947,6 +4058,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t3.x"], + "loops": 8, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -3964,6 +4076,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -3979,6 +4092,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -3994,6 +4108,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -4125,6 +4240,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 100, @@ -4140,6 +4256,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t3.x"], + "loops": 8, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -4157,6 +4274,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -4172,6 +4290,7 @@ EXPLAIN "key_length": "12", "used_key_parts": ["e", "f", "MAX(t2.g)"], "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -4187,6 +4306,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -4271,6 +4391,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -4286,6 +4407,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["f", "MAX(t2.g) OVER (PARTITION BY t2.f)"], "ref": ["test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -4308,6 +4430,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -4380,6 +4503,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 16, "cost": "COST_REPLACED", "filtered": 100, @@ -4398,6 +4522,7 @@ EXPLAIN "CAST(SUM(t2.g) OVER (PARTITION BY t2.f) AS INT)" ], "ref": ["test.t1.b", "test.t1.c"], + "loops": 16, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -4421,6 +4546,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff index d89161d1c51..8c702e82bb1 100644 --- a/mysql-test/main/innodb_ext_key,off.rdiff +++ b/mysql-test/main/innodb_ext_key,off.rdiff @@ -265,7 +265,7 @@ drop table t0,t1,t2; # # MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' -@@ -770,11 +770,12 @@ +@@ -770,12 +770,13 @@ { "table": { "table_name": "t1", @@ -278,10 +278,11 @@ + "key_length": "3066", + "used_key_parts": ["f2"], + "ref": ["const"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, -@@ -809,8 +810,8 @@ +@@ -809,9 +810,9 @@ "access_type": "range", "possible_keys": ["k1"], "key": "k1", @@ -289,6 +290,7 @@ - "used_key_parts": ["pk1", "f2", "pk2"], + "key_length": "3007", + "used_key_parts": ["pk1", "f2"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result index 243717353a3..5a5704a8837 100644 --- a/mysql-test/main/innodb_ext_key.result +++ b/mysql-test/main/innodb_ext_key.result @@ -775,6 +775,7 @@ EXPLAIN "key": "f2", "key_length": "3070", "used_key_parts": ["f2", "pk1"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -811,6 +812,7 @@ EXPLAIN "key": "k1", "key_length": "3011", "used_key_parts": ["pk1", "f2", "pk2"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/intersect.result b/mysql-test/main/intersect.result index 614fbf2951e..83a607f4e45 100644 --- a/mysql-test/main/intersect.result +++ b/mysql-test/main/intersect.result @@ -57,6 +57,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -75,6 +76,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -93,6 +95,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -129,6 +132,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -154,6 +158,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -179,6 +184,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -212,6 +218,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 1, @@ -239,6 +246,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -264,6 +272,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -289,6 +298,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -372,6 +382,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -390,6 +401,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -400,6 +412,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 3, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -440,6 +453,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -465,6 +479,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -480,6 +495,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 3, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -519,6 +535,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 1, @@ -546,6 +563,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -571,6 +589,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -586,6 +605,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 3, "r_loops": 1, "rows": 3, "r_rows": 3, diff --git a/mysql-test/main/intersect_all.result b/mysql-test/main/intersect_all.result index 7b5bc2c2b95..8f826a193aa 100644 --- a/mysql-test/main/intersect_all.result +++ b/mysql-test/main/intersect_all.result @@ -69,6 +69,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100 @@ -87,6 +88,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100 @@ -105,6 +107,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100 @@ -141,6 +144,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -166,6 +170,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -191,6 +196,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -224,6 +230,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 2, @@ -251,6 +258,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -276,6 +284,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -301,6 +310,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -403,6 +413,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 6, "cost": "COST_REPLACED", "filtered": 100 @@ -421,6 +432,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 @@ -431,6 +443,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 5, "rows": 7, "cost": "COST_REPLACED", "filtered": 100 @@ -471,6 +484,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 6, "r_rows": 6, @@ -496,6 +510,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 5, "r_rows": 5, @@ -511,6 +526,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 5, "r_loops": 1, "rows": 7, "r_rows": 7, @@ -550,6 +566,7 @@ ANALYZE "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 6, "r_rows": 3, @@ -577,6 +594,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 6, "r_rows": 6, @@ -602,6 +620,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 5, "r_rows": 5, @@ -617,6 +636,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 5, "r_loops": 1, "rows": 7, "r_rows": 7, diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index f5baec125e8..b5ed58e4382 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -6264,6 +6264,7 @@ EXPLAIN "key": "PRIMARY", "key_length": "4", "used_key_parts": ["a"], + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -6280,6 +6281,7 @@ EXPLAIN "key": "kp1", "key_length": "10", "used_key_parts": ["kp1", "kp2"], + "loops": 10, "rows": 836, "cost": "COST_REPLACED", "filtered": 9.090909004, diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 5498271597c..23db7732e69 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -10703,6 +10703,7 @@ EXPLAIN "key": "start_date", "key_length": "8", "used_key_parts": ["start_date", "end_date"], + "loops": 1, "rows": 1000, "cost": 1.235599899, "filtered": 100, @@ -12382,6 +12383,7 @@ EXPLAIN "table": { "table_name": "three", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": 0.010504815, "filtered": 100, @@ -12405,6 +12407,7 @@ EXPLAIN "rows": 4312, "selectivity_pct": 43.12 }, + "loops": 3, "rows": 1000, "cost": 2.292585745, "filtered": 43.11999893, @@ -12426,6 +12429,7 @@ EXPLAIN "table": { "table_name": "three", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": 0.010504815, "filtered": 100 @@ -12437,6 +12441,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "possible_keys": ["a", "b"], + "loops": 3, "rows": 10000, "cost": 1.701731924, "filtered": 4.307688236, diff --git a/mysql-test/main/opt_trace_ucs2.result b/mysql-test/main/opt_trace_ucs2.result index 63f7cf4652e..ff63f976a36 100644 --- a/mysql-test/main/opt_trace_ucs2.result +++ b/mysql-test/main/opt_trace_ucs2.result @@ -17,6 +17,7 @@ EXPLAIN "key": "col1", "key_length": "21", "used_key_parts": ["col1"], + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index f9c0d59e66a..db7bb521c10 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -1587,6 +1587,7 @@ ANALYZE "key_length": "10", "used_key_parts": ["a", "c"], "ref": ["const", "const"], + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 1, @@ -3475,6 +3476,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 100, "r_rows": 100, @@ -3826,6 +3828,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 100, "r_rows": 100, @@ -3994,6 +3997,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 5, "r_rows": 5, @@ -4045,6 +4049,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 6, "r_rows": 6, @@ -4102,6 +4107,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 6, "r_rows": 6, @@ -4173,6 +4179,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -4347,6 +4354,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 50, "r_rows": 50, @@ -4382,6 +4390,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 50, "rows": 50, "r_rows": 50, @@ -4494,6 +4503,7 @@ EXPLAIN "key": "PRIMARY", "key_length": "4", "used_key_parts": ["a"], + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -4520,6 +4530,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 97, "cost": "COST_REPLACED", "filtered": 100, @@ -4568,6 +4579,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "possible_keys": ["PRIMARY"], + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -4595,6 +4607,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 97, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/order_by_pack_big.result b/mysql-test/main/order_by_pack_big.result index adc7fc807a0..09b4b729de1 100644 --- a/mysql-test/main/order_by_pack_big.result +++ b/mysql-test/main/order_by_pack_big.result @@ -112,6 +112,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10000, "r_rows": 10000, @@ -279,6 +280,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10000, "r_rows": 10000, @@ -442,6 +444,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10000, "r_rows": 10000, @@ -500,6 +503,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10000, "r_rows": 10000, diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index c1caf85fab0..d735f5e1175 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -2434,6 +2434,7 @@ EXPLAIN "key": "idx", "key_length": "10", "used_key_parts": ["a", "b"], + "loops": 1, "rows": 6, "cost": "COST_REPLACED", "filtered": 100, @@ -2500,6 +2501,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2532,6 +2534,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2586,6 +2589,7 @@ EXPLAIN "rows": 12, "selectivity_pct": 60 }, + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 60, @@ -2602,6 +2606,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], + "loops": 1.8, "rows": 8, "cost": "COST_REPLACED", "filtered": 100 @@ -2675,6 +2680,7 @@ EXPLAIN "rows": 15, "selectivity_pct": 14.42307692 }, + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 14.42307663, @@ -2691,6 +2697,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], + "loops": 1.153846154, "rows": 8, "cost": "COST_REPLACED", "filtered": 73.17073059 @@ -2789,6 +2796,7 @@ EXPLAIN "rows": 7, "selectivity_pct": 6.730769231 }, + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 6.730769157, @@ -2805,6 +2813,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], + "loops": 0.471153846, "rows": 11, "cost": "COST_REPLACED", "filtered": 100 @@ -2848,6 +2857,7 @@ EXPLAIN "key": "idx3", "key_length": "10", "used_key_parts": ["d", "e"], + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2864,6 +2874,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], + "loops": 5, "rows": 11, "cost": "COST_REPLACED", "filtered": 100 @@ -2906,6 +2917,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 15, "cost": "COST_REPLACED", "filtered": 100, @@ -2921,6 +2933,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "ref": ["test.t1.a"], + "loops": 15, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -2969,6 +2982,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 144, "cost": "COST_REPLACED", "filtered": 100, @@ -2984,6 +2998,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "ref": ["test.t1.a"], + "loops": 144, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -3029,6 +3044,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3045,6 +3061,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "ref": ["test.t1.a"], + "loops": 12, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -3128,6 +3145,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3144,6 +3162,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "ref": ["test.t1.a"], + "loops": 12, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result index 5c746efb8f3..b6db00842ea 100644 --- a/mysql-test/main/range_mrr_icp.result +++ b/mysql-test/main/range_mrr_icp.result @@ -2437,6 +2437,7 @@ EXPLAIN "key": "idx", "key_length": "10", "used_key_parts": ["a", "b"], + "loops": 1, "rows": 6, "cost": "COST_REPLACED", "filtered": 100, @@ -2504,6 +2505,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2537,6 +2539,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2584,6 +2587,7 @@ EXPLAIN "key": "idx1", "key_length": "5", "used_key_parts": ["d"], + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 60, @@ -2601,6 +2605,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], + "loops": 1.8, "rows": 8, "cost": "COST_REPLACED", "filtered": 100 @@ -2666,6 +2671,7 @@ EXPLAIN "key": "idx1", "key_length": "5", "used_key_parts": ["d"], + "loops": 1, "rows": 8, "cost": "COST_REPLACED", "filtered": 14.42307663, @@ -2683,6 +2689,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], + "loops": 1.153846154, "rows": 8, "cost": "COST_REPLACED", "filtered": 73.17073059 @@ -2773,6 +2780,7 @@ EXPLAIN "key": "idx1", "key_length": "5", "used_key_parts": ["d"], + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 6.730769157, @@ -2790,6 +2798,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], + "loops": 0.471153846, "rows": 11, "cost": "COST_REPLACED", "filtered": 100 @@ -2833,6 +2842,7 @@ EXPLAIN "key": "idx3", "key_length": "10", "used_key_parts": ["d", "e"], + "loops": 1, "rows": 5, "cost": "COST_REPLACED", "filtered": 100, @@ -2850,6 +2860,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], + "loops": 5, "rows": 11, "cost": "COST_REPLACED", "filtered": 100 @@ -2892,6 +2903,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 15, "cost": "COST_REPLACED", "filtered": 100, @@ -2908,6 +2920,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "ref": ["test.t1.a"], + "loops": 15, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -2956,6 +2969,7 @@ EXPLAIN "table_name": "t1", "access_type": "ALL", "possible_keys": ["idx"], + "loops": 1, "rows": 144, "cost": "COST_REPLACED", "filtered": 100, @@ -2971,6 +2985,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "ref": ["test.t1.a"], + "loops": 144, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -3016,6 +3031,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3033,6 +3049,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "ref": ["test.t1.a"], + "loops": 12, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, @@ -3116,6 +3133,7 @@ EXPLAIN "key": "idx", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 12, "cost": "COST_REPLACED", "filtered": 100, @@ -3133,6 +3151,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["d"], "ref": ["test.t1.a"], + "loops": 12, "rows": 3, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index 8765b72d281..aceaf0f98ab 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -95,6 +95,7 @@ EXPLAIN "rows": 702, "selectivity_pct": 11.69025812 }, + "loops": 1, "rows": 509, "cost": "COST_REPLACED", "filtered": 11.69025803, @@ -145,6 +146,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1, "r_loops": 1, "rows": 509, "r_rows": 60, @@ -246,6 +248,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 509, "cost": "COST_REPLACED", "filtered": 11.69025803, @@ -283,6 +286,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 509, "r_rows": 510, @@ -387,6 +391,7 @@ EXPLAIN "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "rows": 69, "cost": "COST_REPLACED", "filtered": 100, @@ -415,6 +420,7 @@ EXPLAIN "rows": 98, "selectivity_pct": 1.631973356 }, + "loops": 69, "rows": 4, "cost": "COST_REPLACED", "filtered": 1.631973386, @@ -454,6 +460,7 @@ ANALYZE "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "r_loops": 1, "rows": 69, "r_rows": 71, @@ -492,6 +499,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 69, "r_loops": 71, "rows": 4, "r_rows": 0.154929577, @@ -552,6 +560,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 98, "cost": "COST_REPLACED", "filtered": 100, @@ -567,6 +576,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 98, "rows": 1, "cost": "COST_REPLACED", "filtered": 4.599999905, @@ -611,6 +621,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 98, "r_rows": 98, @@ -631,6 +642,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 98, "r_loops": 98, "rows": 1, "r_rows": 1, @@ -702,6 +714,7 @@ EXPLAIN "rows": 702, "selectivity_pct": 11.69025812 }, + "loops": 1, "rows": 509, "cost": "COST_REPLACED", "filtered": 11.69025803, @@ -726,6 +739,7 @@ EXPLAIN "rows": 139, "selectivity_pct": 9.266666667 }, + "loops": 59.50341382, "rows": 1, "cost": "COST_REPLACED", "filtered": 9.266666412, @@ -786,6 +800,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1, "r_loops": 1, "rows": 509, "r_rows": 60, @@ -820,6 +835,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 59.50341382, "r_loops": 60, "rows": 1, "r_rows": 0.266666667, @@ -889,6 +905,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 509, "cost": "COST_REPLACED", "filtered": 11.69025803, @@ -905,6 +922,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 59.50341382, "rows": 1, "cost": "COST_REPLACED", "filtered": 9.266666412, @@ -952,6 +970,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 509, "r_rows": 510, @@ -973,6 +992,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 59.50341382, "r_loops": 60, "rows": 1, "r_rows": 1, @@ -1042,6 +1062,7 @@ EXPLAIN "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "rows": 69, "cost": "COST_REPLACED", "filtered": 100, @@ -1070,6 +1091,7 @@ EXPLAIN "rows": 509, "selectivity_pct": 8.476269775 }, + "loops": 69, "rows": 4, "cost": "COST_REPLACED", "filtered": 8.476269722, @@ -1109,6 +1131,7 @@ ANALYZE "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "r_loops": 1, "rows": 69, "r_rows": 71, @@ -1147,6 +1170,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 69, "r_loops": 71, "rows": 4, "r_rows": 0.521126761, @@ -1228,6 +1252,7 @@ EXPLAIN "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "rows": 69, "cost": "COST_REPLACED", "filtered": 100, @@ -1248,6 +1273,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 69, "rows": 4, "cost": "COST_REPLACED", "filtered": 8.476269722, @@ -1287,6 +1313,7 @@ ANALYZE "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "r_loops": 1, "rows": 69, "r_rows": 71, @@ -1312,6 +1339,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 69, "r_loops": 71, "rows": 4, "r_rows": 6.704225352, @@ -1410,6 +1438,7 @@ EXPLAIN "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 0.566194832, @@ -1426,6 +1455,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.101915071, "rows": 1, "cost": "COST_REPLACED", "filtered": 7.466666698, @@ -1475,6 +1505,7 @@ ANALYZE "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "r_loops": 1, "rows": 18, "r_rows": 18, @@ -1496,6 +1527,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.101915071, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -1553,6 +1585,7 @@ EXPLAIN "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 0.566194832, @@ -1569,6 +1602,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.101915071, "rows": 1, "cost": "COST_REPLACED", "filtered": 7.466666698, @@ -1618,6 +1652,7 @@ ANALYZE "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "r_loops": 1, "rows": 18, "r_rows": 18, @@ -1639,6 +1674,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.101915071, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -1697,6 +1733,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 39, "cost": "COST_REPLACED", "filtered": 3.200000048, @@ -1726,6 +1763,7 @@ EXPLAIN "rows": 183, "selectivity_pct": 3.04746045 }, + "loops": 1.248, "rows": 4, "cost": "COST_REPLACED", "filtered": 3.047460556, @@ -1769,6 +1807,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 39, "r_rows": 41, @@ -1808,6 +1847,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1.248, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -1862,6 +1902,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 39, "cost": "COST_REPLACED", "filtered": 3.200000048, @@ -1883,6 +1924,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.248, "rows": 4, "cost": "COST_REPLACED", "filtered": 3.047460556, @@ -1926,6 +1968,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 39, "r_rows": 41, @@ -1952,6 +1995,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.248, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -2014,6 +2058,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 39, "cost": "REPLACED", "filtered": "REPLACED", @@ -2035,6 +2080,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 0.760448, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2083,6 +2129,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 39, "r_rows": 41, @@ -2109,6 +2156,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 0.760448, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -2168,6 +2216,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 39, "cost": "REPLACED", "filtered": "REPLACED", @@ -2189,6 +2238,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 0.760448, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2237,6 +2287,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 39, "r_rows": 41, @@ -2263,6 +2314,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 0.760448, "r_loops": 1, "rows": 4, "r_rows": 6, diff --git a/mysql-test/main/rowid_filter_aria.result b/mysql-test/main/rowid_filter_aria.result index 23c6d1567fd..d0db583168c 100644 --- a/mysql-test/main/rowid_filter_aria.result +++ b/mysql-test/main/rowid_filter_aria.result @@ -96,6 +96,7 @@ EXPLAIN "rows": 949, "selectivity_pct": 15.80349709 }, + "loops": 1, "rows": 482, "cost": "COST_REPLACED", "filtered": 15.80349731, @@ -146,6 +147,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1, "r_loops": 1, "rows": 482, "r_rows": 60, @@ -247,6 +249,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 482, "cost": "COST_REPLACED", "filtered": 15.80349731, @@ -284,6 +287,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 482, "r_rows": 510, @@ -393,6 +397,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 92, "cost": "COST_REPLACED", "filtered": 100, @@ -416,6 +421,7 @@ EXPLAIN "rows": 106, "selectivity_pct": 7.066666667 }, + "loops": 92, "rows": 1, "cost": "COST_REPLACED", "filtered": 7.066666603, @@ -460,6 +466,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 92, "r_rows": 98, @@ -493,6 +500,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 92, "r_loops": 98, "rows": 1, "r_rows": 0.112244898, @@ -553,6 +561,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 92, "cost": "COST_REPLACED", "filtered": 100, @@ -568,6 +577,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 92, "rows": 1, "cost": "COST_REPLACED", "filtered": 7.066666603, @@ -612,6 +622,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 92, "r_rows": 98, @@ -632,6 +643,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 92, "r_loops": 98, "rows": 1, "r_rows": 1, @@ -703,6 +715,7 @@ EXPLAIN "rows": 949, "selectivity_pct": 15.80349709 }, + "loops": 1, "rows": 482, "cost": "COST_REPLACED", "filtered": 15.80349731, @@ -727,6 +740,7 @@ EXPLAIN "rows": 216, "selectivity_pct": 14.4 }, + "loops": 76.17285595, "rows": 1, "cost": "COST_REPLACED", "filtered": 14.39999962, @@ -787,6 +801,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1, "r_loops": 1, "rows": 482, "r_rows": 60, @@ -821,6 +836,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 76.17285595, "r_loops": 60, "rows": 1, "r_rows": 0.266666667, @@ -890,6 +906,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 482, "cost": "COST_REPLACED", "filtered": 15.80349731, @@ -906,6 +923,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 76.17285595, "rows": 1, "cost": "COST_REPLACED", "filtered": 14.39999962, @@ -953,6 +971,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 482, "r_rows": 510, @@ -974,6 +993,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 76.17285595, "r_loops": 60, "rows": 1, "r_rows": 1, @@ -1043,6 +1063,7 @@ EXPLAIN "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "rows": 106, "cost": "COST_REPLACED", "filtered": 100, @@ -1071,6 +1092,7 @@ EXPLAIN "rows": 482, "selectivity_pct": 8.026644463 }, + "loops": 106, "rows": 4, "cost": "COST_REPLACED", "filtered": 8.026644707, @@ -1110,6 +1132,7 @@ ANALYZE "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "r_loops": 1, "rows": 106, "r_rows": 71, @@ -1148,6 +1171,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 106, "r_loops": 71, "rows": 4, "r_rows": 0.521126761, @@ -1229,6 +1253,7 @@ EXPLAIN "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "rows": 106, "cost": "COST_REPLACED", "filtered": 100, @@ -1249,6 +1274,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 106, "rows": 4, "cost": "COST_REPLACED", "filtered": 8.026644707, @@ -1288,6 +1314,7 @@ ANALYZE "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "r_loops": 1, "rows": 106, "r_rows": 71, @@ -1313,6 +1340,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 106, "r_loops": 71, "rows": 4, "r_rows": 6.704225352, @@ -1411,6 +1439,7 @@ EXPLAIN "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "rows": 17, "cost": "COST_REPLACED", "filtered": 0.532889247, @@ -1427,6 +1456,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.090591174, "rows": 1, "cost": "COST_REPLACED", "filtered": 8.466666222, @@ -1476,6 +1506,7 @@ ANALYZE "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "r_loops": 1, "rows": 17, "r_rows": 18, @@ -1497,6 +1528,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.090591174, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -1554,6 +1586,7 @@ EXPLAIN "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "rows": 17, "cost": "COST_REPLACED", "filtered": 0.532889247, @@ -1570,6 +1603,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.090591174, "rows": 1, "cost": "COST_REPLACED", "filtered": 8.466666222, @@ -1619,6 +1653,7 @@ ANALYZE "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "r_loops": 1, "rows": 17, "r_rows": 18, @@ -1640,6 +1675,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.090591174, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -1698,6 +1734,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 61, "cost": "COST_REPLACED", "filtered": 5, @@ -1727,6 +1764,7 @@ EXPLAIN "rows": 174, "selectivity_pct": 2.897585346 }, + "loops": 3.05, "rows": 4, "cost": "COST_REPLACED", "filtered": 2.897585392, @@ -1770,6 +1808,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 61, "r_rows": 41, @@ -1809,6 +1848,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 3.05, "r_loops": 1, "rows": 4, "r_rows": 4, @@ -1863,6 +1903,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 61, "cost": "COST_REPLACED", "filtered": 5, @@ -1884,6 +1925,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 3.05, "rows": 4, "cost": "COST_REPLACED", "filtered": 2.897585392, @@ -1927,6 +1969,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 61, "r_rows": 41, @@ -1953,6 +1996,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 3.05, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -2015,6 +2059,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 61, "cost": "REPLACED", "filtered": "REPLACED", @@ -2036,6 +2081,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.779166667, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2084,6 +2130,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 61, "r_rows": 41, @@ -2110,6 +2157,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.779166667, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -2169,6 +2217,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 61, "cost": "REPLACED", "filtered": "REPLACED", @@ -2190,6 +2239,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.779166667, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2238,6 +2288,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 61, "r_rows": 41, @@ -2264,6 +2315,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.779166667, "r_loops": 1, "rows": 4, "r_rows": 6, diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index b3b34710888..dadd1280e5f 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -98,6 +98,7 @@ EXPLAIN "rows": 605, "selectivity_pct": 10.07493755 }, + "loops": 1, "rows": 510, "cost": "COST_REPLACED", "filtered": 10.07493782, @@ -148,6 +149,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1, "r_loops": 1, "rows": 510, "r_rows": 60, @@ -249,6 +251,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 510, "cost": "COST_REPLACED", "filtered": 10.07493782, @@ -286,6 +289,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 510, "r_rows": 510, @@ -395,6 +399,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 98, "cost": "COST_REPLACED", "filtered": 100, @@ -411,6 +416,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 98, "rows": 1, "cost": "COST_REPLACED", "filtered": 4.733333111, @@ -455,6 +461,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 98, "r_rows": 98, @@ -476,6 +483,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 98, "r_loops": 98, "rows": 1, "r_rows": 1, @@ -536,6 +544,7 @@ EXPLAIN "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "rows": 98, "cost": "COST_REPLACED", "filtered": 100, @@ -552,6 +561,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 98, "rows": 1, "cost": "COST_REPLACED", "filtered": 4.733333111, @@ -596,6 +606,7 @@ ANALYZE "key": "i_l_shipdate", "key_length": "4", "used_key_parts": ["l_shipDATE"], + "loops": 1, "r_loops": 1, "rows": 98, "r_rows": 98, @@ -617,6 +628,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 98, "r_loops": 98, "rows": 1, "r_rows": 1, @@ -688,6 +700,7 @@ EXPLAIN "rows": 605, "selectivity_pct": 10.07493755 }, + "loops": 1, "rows": 510, "cost": "COST_REPLACED", "filtered": 10.07493782, @@ -704,6 +717,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 51.38218152, "rows": 1, "cost": "COST_REPLACED", "filtered": 9.600000381, @@ -764,6 +778,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1, "r_loops": 1, "rows": 510, "r_rows": 60, @@ -785,6 +800,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 51.38218152, "r_loops": 60, "rows": 1, "r_rows": 1, @@ -848,6 +864,7 @@ EXPLAIN "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "rows": 144, "cost": "COST_REPLACED", "filtered": 100, @@ -870,6 +887,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 144, "rows": 4, "cost": "COST_REPLACED", "filtered": 0.855656624, @@ -911,6 +929,7 @@ ANALYZE "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "r_loops": 1, "rows": 144, "r_rows": 144, @@ -938,6 +957,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 144, "r_loops": 144, "rows": 4, "r_rows": 6.625, @@ -1007,6 +1027,7 @@ EXPLAIN "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "rows": 71, "cost": "COST_REPLACED", "filtered": 100, @@ -1028,6 +1049,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 71, "rows": 4, "cost": "COST_REPLACED", "filtered": 8.492922783, @@ -1067,6 +1089,7 @@ ANALYZE "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "r_loops": 1, "rows": 71, "r_rows": 71, @@ -1093,6 +1116,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 71, "r_loops": 71, "rows": 4, "r_rows": 6.704225352, @@ -1174,6 +1198,7 @@ EXPLAIN "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "rows": 71, "cost": "COST_REPLACED", "filtered": 100, @@ -1195,6 +1220,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 71, "rows": 4, "cost": "COST_REPLACED", "filtered": 8.492922783, @@ -1234,6 +1260,7 @@ ANALYZE "key": "i_o_totalprice", "key_length": "9", "used_key_parts": ["o_totalprice"], + "loops": 1, "r_loops": 1, "rows": 71, "r_rows": 71, @@ -1260,6 +1287,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 71, "r_loops": 71, "rows": 4, "r_rows": 6.704225352, @@ -1358,6 +1386,7 @@ EXPLAIN "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 0.566194832, @@ -1374,6 +1403,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.101915071, "rows": 1, "cost": "COST_REPLACED", "filtered": 5.666666508, @@ -1423,6 +1453,7 @@ ANALYZE "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "r_loops": 1, "rows": 18, "r_rows": 18, @@ -1444,6 +1475,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.101915071, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -1501,6 +1533,7 @@ EXPLAIN "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 0.566194832, @@ -1517,6 +1550,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.101915071, "rows": 1, "cost": "COST_REPLACED", "filtered": 5.666666508, @@ -1566,6 +1600,7 @@ ANALYZE "key": "i_l_receiptdate", "key_length": "4", "used_key_parts": ["l_receiptDATE"], + "loops": 1, "r_loops": 1, "rows": 18, "r_rows": 18, @@ -1587,6 +1622,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], + "loops": 0.101915071, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -1645,6 +1681,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 41, "cost": "COST_REPLACED", "filtered": 3.333333254, @@ -1666,6 +1703,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.366666667, "rows": 4, "cost": "COST_REPLACED", "filtered": 3.047460556, @@ -1709,6 +1747,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 41, "r_rows": 41, @@ -1735,6 +1774,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.366666667, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -1789,6 +1829,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 41, "cost": "COST_REPLACED", "filtered": 3.333333254, @@ -1810,6 +1851,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.366666667, "rows": 4, "cost": "COST_REPLACED", "filtered": 3.047460556, @@ -1853,6 +1895,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 41, "r_rows": 41, @@ -1879,6 +1922,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 1.366666667, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -1941,6 +1985,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 41, "cost": "REPLACED", "filtered": "REPLACED", @@ -1962,6 +2007,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 0.849155556, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2010,6 +2056,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 41, "r_rows": 41, @@ -2036,6 +2083,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 0.849155556, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -2095,6 +2143,7 @@ EXPLAIN "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "rows": 41, "cost": "REPLACED", "filtered": "REPLACED", @@ -2116,6 +2165,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 0.849155556, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2164,6 +2214,7 @@ ANALYZE "key": "i_o_totaldiscount", "key_length": "9", "used_key_parts": ["o_totaldiscount"], + "loops": 1, "r_loops": 1, "rows": 41, "r_rows": 41, @@ -2190,6 +2241,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], + "loops": 0.849155556, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -2298,6 +2350,7 @@ EXPLAIN "rows": 1, "selectivity_pct": 1.587301587 }, + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 1.587301612, @@ -2331,6 +2384,7 @@ EXPLAIN "rows": 1, "selectivity_pct": 1.587301587 }, + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 1.587301612, @@ -3313,6 +3367,7 @@ ANALYZE } ] }, + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 3, @@ -3335,6 +3390,7 @@ ANALYZE "key_length": "8", "used_key_parts": ["aclid"], "ref": ["test.t.id"], + "loops": 2, "r_loops": 1, "rows": 1, "r_rows": 3, @@ -3376,6 +3432,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 3.5384, "r_loops": 1, "rows": 24, "r_rows": 32, diff --git a/mysql-test/main/rowid_filter_myisam.result b/mysql-test/main/rowid_filter_myisam.result index 2fa9f57dbd2..0a56f87f25f 100644 --- a/mysql-test/main/rowid_filter_myisam.result +++ b/mysql-test/main/rowid_filter_myisam.result @@ -142,6 +142,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 101, "cost": "COST_REPLACED", "filtered": 100, @@ -165,6 +166,7 @@ EXPLAIN "rows": 87, "selectivity_pct": 87 }, + "loops": 101, "rows": 1, "cost": "COST_REPLACED", "filtered": 87, @@ -186,6 +188,7 @@ EXPLAIN "key": "PRIMARY", "key_length": "4", "used_key_parts": ["pk2"], + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, @@ -356,6 +359,7 @@ ANALYZE "key": "idx1", "key_length": "35", "used_key_parts": ["nm"], + "loops": 1, "r_loops": 1, "rows": 1, "r_rows": 1, @@ -411,6 +415,7 @@ ANALYZE "key": "idx1", "key_length": "35", "used_key_parts": ["nm"], + "loops": 1, "r_loops": 1, "rows": 1, "r_rows": 1, @@ -505,6 +510,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1, "r_loops": 1, "rows": 55, "r_rows": 2, @@ -620,6 +626,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1, "r_loops": 1, "rows": 44, "r_rows": 0, @@ -688,6 +695,7 @@ ANALYZE "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, + "loops": 1, "r_loops": 1, "rows": 44, "r_rows": 0, diff --git a/mysql-test/main/set_operation.result b/mysql-test/main/set_operation.result index cbd3ce37085..f01b68357a2 100644 --- a/mysql-test/main/set_operation.result +++ b/mysql-test/main/set_operation.result @@ -577,6 +577,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "REPLACED", "filtered": 100 @@ -595,6 +596,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "REPLACED", "filtered": 100, @@ -613,6 +615,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 6, "cost": "REPLACED", "filtered": 100 @@ -640,6 +643,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "REPLACED", "filtered": 100, @@ -656,6 +660,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "REPLACED", "filtered": 100 @@ -674,6 +679,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "REPLACED", "filtered": 100 @@ -710,6 +716,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "REPLACED", "filtered": 100 @@ -728,6 +735,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 6, "cost": "REPLACED", "filtered": 100 @@ -746,6 +754,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "REPLACED", "filtered": 100 @@ -764,6 +773,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "REPLACED", "filtered": 100 @@ -774,6 +784,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 5, "rows": 6, "cost": "REPLACED", "filtered": 100 @@ -796,6 +807,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "REPLACED", "filtered": 100, @@ -807,6 +819,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 5, "rows": 6, "cost": "REPLACED", "filtered": 100 @@ -829,6 +842,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 5, "cost": "REPLACED", "filtered": 100 diff --git a/mysql-test/main/show_analyze.result b/mysql-test/main/show_analyze.result index 1cda2f20514..2cc18e40d94 100644 --- a/mysql-test/main/show_analyze.result +++ b/mysql-test/main/show_analyze.result @@ -422,6 +422,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, diff --git a/mysql-test/main/show_analyze_json.result b/mysql-test/main/show_analyze_json.result index 38a73695e9a..87f2ea9a655 100644 --- a/mysql-test/main/show_analyze_json.result +++ b/mysql-test/main/show_analyze_json.result @@ -51,6 +51,7 @@ SHOW ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 1000, "r_rows": 1000, @@ -86,6 +87,7 @@ SHOW ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 1000, "r_rows": 1000, @@ -124,6 +126,7 @@ SHOW ANALYZE "table_name": "t1", "access_type": "ALL", "possible_keys": ["a"], + "loops": 1, "r_loops": 1, "rows": 1000, "r_rows": 1000, @@ -173,6 +176,7 @@ SHOW ANALYZE "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -195,6 +199,7 @@ SHOW ANALYZE "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "r_loops": 0, "rows": 10, "r_rows": null, @@ -246,6 +251,7 @@ SHOW ANALYZE "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -269,6 +275,7 @@ SHOW ANALYZE "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -321,6 +328,7 @@ SHOW ANALYZE "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -345,6 +353,7 @@ SHOW ANALYZE "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "r_loops": 0, "rows": 10, "r_rows": null, @@ -397,6 +406,7 @@ SHOW ANALYZE "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -423,6 +433,7 @@ SHOW ANALYZE "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -470,6 +481,7 @@ SHOW ANALYZE "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -491,6 +503,7 @@ SHOW ANALYZE "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -535,6 +548,7 @@ SHOW ANALYZE "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -559,6 +573,7 @@ SHOW ANALYZE "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -603,6 +618,7 @@ SHOW ANALYZE "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "r_loops": 0, "rows": 10, "r_rows": null, @@ -626,6 +642,7 @@ SHOW ANALYZE "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "r_loops": 0, "rows": 10, "r_rows": null, @@ -670,6 +687,7 @@ SHOW ANALYZE "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -694,6 +712,7 @@ SHOW ANALYZE "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "r_loops": 2, "rows": 10, "r_rows": 10, @@ -739,6 +758,7 @@ SHOW ANALYZE "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -766,6 +786,7 @@ SHOW ANALYZE "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "r_loops": 2, "rows": 10, "r_rows": 10, @@ -839,6 +860,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 0, "rows": 10, "r_rows": null, @@ -885,6 +907,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -941,6 +964,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 0, "rows": 10, "r_rows": null, @@ -987,6 +1011,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -1031,6 +1056,7 @@ SHOW ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 1, @@ -1053,6 +1079,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 0, "rows": 10, "r_rows": null, @@ -1087,6 +1114,7 @@ SHOW ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 2, @@ -1110,6 +1138,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -1144,6 +1173,7 @@ SHOW ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, @@ -1167,6 +1197,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 2, "rows": 10, "r_rows": 10, @@ -1224,6 +1255,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -1277,6 +1309,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -1328,6 +1361,7 @@ SHOW ANALYZE "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, diff --git a/mysql-test/main/show_explain_json.result b/mysql-test/main/show_explain_json.result index 1dad0ea2388..4a21528e41d 100644 --- a/mysql-test/main/show_explain_json.result +++ b/mysql-test/main/show_explain_json.result @@ -57,6 +57,7 @@ SHOW EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 999, "cost": "COST_REPLACED", "filtered": 100, @@ -89,6 +90,7 @@ SHOW EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -120,6 +122,7 @@ SHOW EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -154,6 +157,7 @@ SHOW EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -187,6 +191,7 @@ SHOW EXPLAIN "key": "a", "key_length": "5", "used_key_parts": ["a"], + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -226,6 +231,7 @@ SHOW EXPLAIN "table": { "table_name": "A", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -244,6 +250,7 @@ SHOW EXPLAIN "table": { "table_name": "B", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -286,6 +293,7 @@ SHOW EXPLAIN "table": { "table_name": "A", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -304,6 +312,7 @@ SHOW EXPLAIN "table": { "table_name": "B", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -402,6 +411,7 @@ SHOW EXPLAIN "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -420,6 +430,7 @@ SHOW EXPLAIN "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -455,6 +466,7 @@ SHOW EXPLAIN "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -473,6 +485,7 @@ SHOW EXPLAIN "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -508,6 +521,7 @@ SHOW EXPLAIN "table": { "table_name": "a", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -526,6 +540,7 @@ SHOW EXPLAIN "table": { "table_name": "b", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -588,6 +603,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -624,6 +640,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -668,6 +685,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -704,6 +722,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -751,6 +770,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -787,6 +807,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -834,6 +855,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -870,6 +892,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -906,6 +929,7 @@ SHOW EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -923,6 +947,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -949,6 +974,7 @@ SHOW EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -966,6 +992,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -992,6 +1019,7 @@ SHOW EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1009,6 +1037,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -1050,6 +1079,7 @@ SHOW EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1067,6 +1097,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -1093,6 +1124,7 @@ SHOW EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1110,6 +1142,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -1136,6 +1169,7 @@ SHOW EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1153,6 +1187,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -1199,6 +1234,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1248,6 +1284,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1296,6 +1333,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1346,6 +1384,7 @@ SHOW EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result index 14d3720e06e..a4cf71f9806 100644 --- a/mysql-test/main/statistics_json.result +++ b/mysql-test/main/statistics_json.result @@ -8344,6 +8344,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 18, "cost": "COST_REPLACED", "filtered": 5.555555344, diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index 2e864355afb..c4e945c2d10 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -2937,6 +2937,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -2963,6 +2964,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, @@ -2987,6 +2989,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 2, "r_rows": 2, diff --git a/mysql-test/main/subselect_cache.result b/mysql-test/main/subselect_cache.result index 4e8c3a46205..10bb54cbb14 100644 --- a/mysql-test/main/subselect_cache.result +++ b/mysql-test/main/subselect_cache.result @@ -57,6 +57,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -83,6 +84,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 4, "rows": 4, "r_rows": 4, @@ -118,6 +120,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 10, "r_rows": 10, @@ -152,6 +155,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 4, "rows": 4, "r_rows": 4, @@ -194,6 +198,7 @@ ANALYZE "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "r_loops": 4, "rows": 4, "r_rows": 4, @@ -224,6 +229,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -242,6 +248,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -267,6 +274,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -291,6 +299,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, @@ -325,6 +334,7 @@ EXPLAIN "table": { "table_name": "t2", "access_type": "ALL", + "loops": 1, "rows": 4, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index d216d991f8f..d56be525db6 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -7444,6 +7444,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -7475,6 +7476,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/table_elim.result b/mysql-test/main/table_elim.result index a6a3d4d8513..a9602d90249 100644 --- a/mysql-test/main/table_elim.result +++ b/mysql-test/main/table_elim.result @@ -744,6 +744,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -778,6 +779,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -792,6 +794,7 @@ EXPLAIN "key_length": "8", "used_key_parts": ["b"], "ref": ["test.t1.a"], + "loops": 10, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -809,6 +812,7 @@ EXPLAIN "table": { "table_name": "t11", "access_type": "ALL", + "loops": 1, "rows": 1000, "cost": "COST_REPLACED", "filtered": 100 @@ -845,6 +849,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -873,6 +878,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -887,6 +893,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["b"], "ref": ["test.t1.a"], + "loops": 10, "rows": 10, "cost": "COST_REPLACED", "filtered": 100, @@ -904,6 +911,7 @@ EXPLAIN "table": { "table_name": "t11", "access_type": "ALL", + "loops": 1, "rows": 1000, "cost": "COST_REPLACED", "filtered": 100 @@ -918,6 +926,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk"], "ref": ["test.t11.b"], + "loops": 1000, "rows": 1, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index d2a91227723..04fa4c0bf16 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -1417,6 +1417,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1456,6 +1457,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1493,6 +1495,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1535,6 +1538,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1688,6 +1692,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1722,6 +1727,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1756,6 +1762,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1790,6 +1797,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1854,6 +1862,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 6, "cost": "COST_REPLACED", "filtered": 100 @@ -2015,6 +2024,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -2196,6 +2206,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100 @@ -2265,6 +2276,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 6, "cost": "COST_REPLACED", "filtered": 100 @@ -3874,6 +3886,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, diff --git a/mysql-test/main/win_empty_over.result b/mysql-test/main/win_empty_over.result index acb83724d72..2f75f80c6ad 100644 --- a/mysql-test/main/win_empty_over.result +++ b/mysql-test/main/win_empty_over.result @@ -54,6 +54,7 @@ EXPLAIN "key": "PRIMARY", "key_length": "4", "used_key_parts": ["pk"], + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, @@ -88,6 +89,7 @@ EXPLAIN "key": "PRIMARY", "key_length": "4", "used_key_parts": ["pk"], + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index b75334d8c31..103d8740087 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -1423,6 +1423,7 @@ EXPLAIN "table": { "table_name": "t0", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1462,6 +1463,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1499,6 +1501,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1541,6 +1544,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 10, "cost": "COST_REPLACED", "filtered": 100 @@ -1694,6 +1698,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1728,6 +1733,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1762,6 +1768,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1796,6 +1803,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 3, "cost": "COST_REPLACED", "filtered": 100 @@ -1860,6 +1868,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 6, "cost": "COST_REPLACED", "filtered": 100 @@ -2021,6 +2030,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 9, "cost": "COST_REPLACED", "filtered": 100 @@ -2202,6 +2212,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100 @@ -2271,6 +2282,7 @@ EXPLAIN "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "rows": 6, "cost": "COST_REPLACED", "filtered": 100 @@ -3880,6 +3892,7 @@ ANALYZE "table": { "table_name": "t1", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 3, "r_rows": 3, diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 92436e1ac64..59ca0bb2fec 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -166,6 +166,7 @@ EXPLAIN "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "rows": 7, "cost": "COST_REPLACED", "filtered": 100 @@ -180,6 +181,7 @@ EXPLAIN "key_length": "18", "used_key_parts": ["name"], "ref": ["federated.t3.name"], + "loops": 7, "rows": 2, "cost": "COST_REPLACED", "filtered": 100, @@ -242,6 +244,7 @@ ANALYZE "table": { "table_name": "t3", "access_type": "ALL", + "loops": 1, "r_loops": 1, "rows": 7, "r_rows": 7, @@ -261,6 +264,7 @@ ANALYZE "key_length": "18", "used_key_parts": ["name"], "ref": ["federated.t3.name"], + "loops": 7, "r_loops": 7, "rows": 2, "r_rows": 0, @@ -376,6 +380,7 @@ EXPLAIN "table": { "table_name": "t5", "access_type": "ALL", + "loops": 1, "rows": 2, "cost": "COST_REPLACED", "filtered": 100 @@ -386,6 +391,7 @@ EXPLAIN "table": { "table_name": "", "access_type": "ALL", + "loops": 2, "rows": 5, "cost": "COST_REPLACED", "filtered": 100 diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result index 3eefaa72c1d..900348d8a13 100644 --- a/mysql-test/suite/json/r/json_table.result +++ b/mysql-test/suite/json/r/json_table.result @@ -217,6 +217,7 @@ EXPLAIN "table": { "table_name": "tt", "access_type": "ALL", + "loops": 1, "rows": 40, "cost": "COST_REPLACED", "filtered": 100, diff --git a/mysql-test/suite/json/r/json_table_mysql.result b/mysql-test/suite/json/r/json_table_mysql.result index 44ca370f01f..0be40a8a5c8 100644 --- a/mysql-test/suite/json/r/json_table_mysql.result +++ b/mysql-test/suite/json/r/json_table_mysql.result @@ -195,6 +195,7 @@ EXPLAIN "table": { "table_name": "tt", "access_type": "ALL", + "loops": 1, "rows": 40, "cost": "COST_REPLACED", "filtered": 100, diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h index f59ce0dbb85..1f121855d93 100644 --- a/sql/opt_subselect.h +++ b/sql/opt_subselect.h @@ -294,11 +294,12 @@ public: } } - void save_to_position(JOIN_TAB *tab, POSITION *pos) + void save_to_position(JOIN_TAB *tab, double record_count, POSITION *pos) { pos->read_time= best_loose_scan_cost; if (best_loose_scan_cost != DBL_MAX) { + pos->loops= record_count; pos->records_read= best_loose_scan_records; pos->records_init= pos->records_out= pos->records_read; pos->key= best_loose_scan_start_key; diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index fd5f675add5..5cfe3082b35 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -1916,6 +1916,9 @@ void Explain_table_access::print_explain_json(Explain_query *query, rowid_filter->print_explain_json(query, writer, is_analyze); } + if (loops != 0.0) + writer->add_member("loops").add_double(loops); + /* r_loops (not present in tabular output) */ if (is_analyze) { diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 9e560c0be23..67abfe2e9da 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -758,6 +758,8 @@ public: Explain_table_access(MEM_ROOT *root, bool timed) : derived_select_number(0), non_merged_sjm_number(0), + cost(0.0), + loops(0.0), extra_tags(root), range_checked_fer(NULL), full_scan_on_null_key(false), @@ -829,6 +831,7 @@ public: /* Total cost incurred during one execution of this select */ double cost; + double loops; /* Contents of the 'Extra' column. Some are converted into strings, some have parameters, values for which are stored below. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 17ae0cf079e..72df1e6e2de 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8116,6 +8116,7 @@ best_access_path(JOIN *join, best.uses_jbuf= FALSE; best.spl_plan= 0; + pos->loops= record_count; disable_jbuf= disable_jbuf || idx == join->const_tables; trace_wrapper.add_table_name(s); @@ -9239,7 +9240,7 @@ best_access_path(JOIN *join, pos->key_dependent= (best.type == JT_EQ_REF ? (table_map) 0 : key_dependent & remaining_tables); - loose_scan_opt.save_to_position(s, loose_scan_pos); + loose_scan_opt.save_to_position(s, record_count, loose_scan_pos); if (!best.key && idx == join->const_tables && // First table @@ -12022,6 +12023,7 @@ bool JOIN::get_best_combination() j->records= (ha_rows) j->records_read; j->cond_selectivity= 1.0; j->join_read_time= 0.0; /* Not saved currently */ + j->join_loops= 0.0; JOIN_TAB *jt; JOIN_TAB_RANGE *jt_range; if (!(jt= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*sjm->tables)) || @@ -12083,6 +12085,7 @@ bool JOIN::get_best_combination() j->records_read= cur_pos->records_read; j->records_out= cur_pos->records_out; j->join_read_time= cur_pos->read_time; + j->join_loops= cur_pos->loops; loop_end: j->cond_selectivity= cur_pos->cond_selectivity; @@ -28588,6 +28591,7 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, eta->key.clear(); eta->quick_info= NULL; eta->cost= join_read_time; + eta->loops= join_loops; SQL_SELECT *tab_select; /* diff --git a/sql/sql_select.h b/sql/sql_select.h index 3956651c57b..73e8739f960 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -355,6 +355,7 @@ typedef struct st_join_table { accessing the table in course of the join execution. */ double join_read_time; + double join_loops; /* The selectivity of the conditions that can be pushed to the table */ double cond_selectivity; @@ -1018,6 +1019,8 @@ public: */ double read_time; + double loops; + double prefix_record_count; /* Cost for the join prefix */ diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result index 7443909b1ac..a4717570450 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result @@ -57,6 +57,7 @@ EXPLAIN "key": "kp1", "key_length": "5", "used_key_parts": ["kp1"], + "loops": 1, "rows": 1000, "cost": "COST_REPLACED", "filtered": 100, diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result index ece58586d8b..07bce244792 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result @@ -57,6 +57,7 @@ EXPLAIN "key": "kp1", "key_length": "5", "used_key_parts": ["kp1"], + "loops": 1, "rows": 1000, "cost": "COST_REPLACED", "filtered": 100, From 01760333e82e2f4364a31343eefa5837ae44b8f5 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 25 Nov 2022 15:25:44 +0200 Subject: [PATCH 078/123] Do not give warnings about #rocksdb directory information_schema "select * from information_schema.tables limit 1" was giving the following warning in the log: [ERROR] Invalid (old?) table or database name '#rocksdb' --- sql/handler.cc | 2 +- sql/table.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/handler.cc b/sql/handler.cc index 0d66da589f2..03445e9ed06 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6580,7 +6580,7 @@ bool Discovered_table_list::add_file(const char *fname) { bool is_temp= strncmp(fname, STRING_WITH_LEN(tmp_file_prefix)) == 0; - if (is_temp && !with_temps) + if ((is_temp && !with_temps) || !strncmp(fname,STRING_WITH_LEN(ROCKSDB_DIRECTORY_NAME))) return 0; char tname[SAFE_NAME_LEN + 1]; diff --git a/sql/table.h b/sql/table.h index 218fb0e8104..e725dd1152e 100644 --- a/sql/table.h +++ b/sql/table.h @@ -92,6 +92,7 @@ typedef ulonglong nested_join_map; #define tmp_file_prefix "#sql" /**< Prefix for tmp tables */ #define tmp_file_prefix_length 4 #define TMP_TABLE_KEY_EXTRA 8 +#define ROCKSDB_DIRECTORY_NAME "#rocksdb" /** Enumerate possible types of a table from re-execution From 0bab5481374b473b9335f50d271a54987154e64a Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 25 Nov 2022 16:48:53 +0200 Subject: [PATCH 079/123] Remove strlen() from Item::cleanup --- sql/item.cc | 11 ++++------- sql/item.h | 2 +- sql/sql_view.cc | 10 +++++----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index aa0553228b3..6e93a46445c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -411,7 +411,7 @@ int Item::save_str_value_in_field(Field *field, String *result) Item::Item(THD *thd): - name(null_clex_str), orig_name(0), is_expensive_cache(-1) + name(null_clex_str), orig_name(null_clex_str), is_expensive_cache(-1) { DBUG_ASSERT(thd); base_flags= item_base_t::FIXED; @@ -444,7 +444,7 @@ Item::Item(THD *thd): */ Item::Item(): - name(null_clex_str), orig_name(0), is_expensive_cache(-1) + name(null_clex_str), orig_name(null_clex_str), is_expensive_cache(-1) { DBUG_ASSERT(!mysqld_server_started); // Created early base_flags= item_base_t::FIXED; @@ -552,11 +552,8 @@ void Item::cleanup() DBUG_PRINT("enter", ("this: %p", this)); marker= MARKER_UNUSED; join_tab_idx= MAX_TABLES; - if (orig_name) - { - name.str= orig_name; - name.length= strlen(orig_name); - } + if (orig_name.str) + name= orig_name; DBUG_VOID_RETURN; } diff --git a/sql/item.h b/sql/item.h index 5c7ae944f19..e15d454c65f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1035,7 +1035,7 @@ public: LEX_CSTRING name; /* Name of item */ /* Original item name (if it was renamed)*/ - const char *orig_name; + LEX_CSTRING orig_name; /* All common bool variables for an Item is stored here */ item_base_t base_flags; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 30fba1bcf98..89251e33f7f 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -67,8 +67,8 @@ static void make_unique_view_field_name(THD *thd, Item *target, List &item_list, Item *last_element) { - const char *name= (target->orig_name ? - target->orig_name : + const char *name= (target->orig_name.str ? + target->orig_name.str : target->name.str); size_t name_len; uint attempt; @@ -100,8 +100,8 @@ static void make_unique_view_field_name(THD *thd, Item *target, itc.rewind(); } - if (!target->orig_name) - target->orig_name= target->name.str; + if (!target->orig_name.str) + target->orig_name= target->name; target->set_name(thd, buff, name_len, system_charset_info); } @@ -186,7 +186,7 @@ void make_valid_column_names(THD *thd, List &item_list) if (item->is_explicit_name() || !check_column_name(item->name.str)) continue; name_len= my_snprintf(buff, NAME_LEN, "Name_exp_%u", column_no); - item->orig_name= item->name.str; + item->orig_name= item->name; item->set_name(thd, buff, name_len, system_charset_info); } From 02f6ba571e930493c51b92b8c23e2e7fadcedbe0 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 28 Nov 2022 15:02:34 +0200 Subject: [PATCH 080/123] Changed some startup warnings to notes - Changed 'WARNING' of type "You need to use --log-bin to make ... work" to 'Note' - Only print startup Notes if log_warnings >= 4 --- .../suite/binlog/t/binlog_expire_warnings.opt | 1 + sql/mysqld.cc | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 mysql-test/suite/binlog/t/binlog_expire_warnings.opt diff --git a/mysql-test/suite/binlog/t/binlog_expire_warnings.opt b/mysql-test/suite/binlog/t/binlog_expire_warnings.opt new file mode 100644 index 00000000000..c85ef7d3e04 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_expire_warnings.opt @@ -0,0 +1 @@ +--log-warnings=4 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 738a606f072..25c9696a32d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5004,12 +5004,12 @@ static int init_server_components() /* need to configure logging before initializing storage engines */ if (!opt_bin_log_used && !WSREP_ON) { - if (opt_log_slave_updates && (global_system_variables.log_warnings > 1)) - sql_print_warning("You need to use --log-bin to make " - "--log-slave-updates work."); - if (binlog_format_used && (global_system_variables.log_warnings > 1)) - sql_print_warning("You need to use --log-bin to make " - "--binlog-format work."); + if (opt_log_slave_updates && (global_system_variables.log_warnings >= 4)) + sql_print_information("You need to use --log-bin to make " + "--log-slave-updates work."); + if (binlog_format_used && (global_system_variables.log_warnings >= 4)) + sql_print_information("You need to use --log-bin to make " + "--binlog-format work."); } /* Check that we have not let the format to unspecified at this point */ @@ -5497,9 +5497,9 @@ static int init_server_components() } else { - if (binlog_expire_logs_seconds && (global_system_variables.log_warnings > 1)) - sql_print_warning("You need to use --log-bin to make --expire-logs-days " - "or --binlog-expire-logs-seconds work."); + if (binlog_expire_logs_seconds && (global_system_variables.log_warnings >= 4)) + sql_print_information("You need to use --log-bin to make --expire-logs-days " + "or --binlog-expire-logs-seconds work."); } #endif From 8b7c0d69d2503cd3d98aae8c4b62d2df1e7975d3 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 2 Dec 2022 17:18:50 +0200 Subject: [PATCH 081/123] In best_access_path() change record_count to 1.0 if its less than 1.0. In essence this means that we expect the user query to have at least one matching row in the end. This change will not affect the estimated rows for the plan, but will ensure that the cost for adding a table is not neglected because of record count being too low. The reasons for this is that if we have table combination that together has a very high selectivity then join record_count could become very low (close to 0) This would cause costs for all future tables to be so small that they are irrelevant for the rest of the plan. This has been shown to be the case in some performance benchmarks and in a few mtr tests. There is also still a problem in selectivity calculations as joining two tables in different order causes a different estimation of total rows. This can be seen in selectivity_innodb.test, test 'Q20' where joining nation,supplier is expecting 1.111 rows_out while joining supplier,nation is expecting 0.04 rows_out. The reason for 0.04 is that the optimizer estimates 'supplier' to have 10 matching rows, and joining with nation (eq_ref) has 1 row. However selectivity of n_name = 'UNITED STATES' makes the optimizer things that there will be only 0.04 matching rows. This patch avoids this "too low row count" to affect cost caclulations. --- mysql-test/main/innodb_ext_key,off.rdiff | 6 ++--- mysql-test/main/range.result | 2 +- mysql-test/main/range_mrr_icp.result | 2 +- mysql-test/main/rowid_filter.result | 16 ++++++------ mysql-test/main/rowid_filter_aria.result | 8 +++--- mysql-test/main/rowid_filter_innodb.result | 16 ++++++------ mysql-test/main/selectivity_innodb.result | 30 +++++++++++----------- mysql-test/main/subselect_sj.result | 4 +-- mysql-test/main/subselect_sj_jcl6.result | 4 +-- sql/sql_select.cc | 8 ++++++ 10 files changed, 51 insertions(+), 45 deletions(-) diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff index 8c702e82bb1..ef11f9c05bc 100644 --- a/mysql-test/main/innodb_ext_key,off.rdiff +++ b/mysql-test/main/innodb_ext_key,off.rdiff @@ -265,7 +265,7 @@ drop table t0,t1,t2; # # MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' -@@ -770,12 +770,13 @@ +@@ -770,11 +770,12 @@ { "table": { "table_name": "t1", @@ -281,8 +281,7 @@ "loops": 1, "rows": 1, "cost": "COST_REPLACED", - "filtered": 100, -@@ -809,9 +810,9 @@ +@@ -810,8 +811,8 @@ "access_type": "range", "possible_keys": ["k1"], "key": "k1", @@ -293,4 +292,3 @@ "loops": 1, "rows": 1, "cost": "COST_REPLACED", - "filtered": 100, diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index d735f5e1175..6d9f2d8b1c3 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -2813,7 +2813,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], - "loops": 0.471153846, + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100 diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result index b6db00842ea..ba81a6c4cba 100644 --- a/mysql-test/main/range_mrr_icp.result +++ b/mysql-test/main/range_mrr_icp.result @@ -2798,7 +2798,7 @@ EXPLAIN "key_length": "5", "used_key_parts": ["a"], "ref": ["test.t2.d"], - "loops": 0.471153846, + "loops": 1, "rows": 11, "cost": "COST_REPLACED", "filtered": 100 diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index aceaf0f98ab..2312fb593d1 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -1455,7 +1455,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.101915071, + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 7.466666698, @@ -1527,7 +1527,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.101915071, + "loops": 1, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -1602,7 +1602,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.101915071, + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 7.466666698, @@ -1674,7 +1674,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.101915071, + "loops": 1, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -2080,7 +2080,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "loops": 0.760448, + "loops": 1, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2156,7 +2156,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "loops": 0.760448, + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -2238,7 +2238,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "loops": 0.760448, + "loops": 1, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2314,7 +2314,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "loops": 0.760448, + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 6, diff --git a/mysql-test/main/rowid_filter_aria.result b/mysql-test/main/rowid_filter_aria.result index d0db583168c..2478e787a6d 100644 --- a/mysql-test/main/rowid_filter_aria.result +++ b/mysql-test/main/rowid_filter_aria.result @@ -1456,7 +1456,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.090591174, + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 8.466666222, @@ -1528,7 +1528,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.090591174, + "loops": 1, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -1603,7 +1603,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.090591174, + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 8.466666222, @@ -1675,7 +1675,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.090591174, + "loops": 1, "r_loops": 7, "rows": 1, "r_rows": 1, diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index dadd1280e5f..78fc80e6ad7 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -1403,7 +1403,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.101915071, + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 5.666666508, @@ -1475,7 +1475,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.101915071, + "loops": 1, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -1550,7 +1550,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.101915071, + "loops": 1, "rows": 1, "cost": "COST_REPLACED", "filtered": 5.666666508, @@ -1622,7 +1622,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 0.101915071, + "loops": 1, "r_loops": 7, "rows": 1, "r_rows": 1, @@ -2007,7 +2007,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "loops": 0.849155556, + "loops": 1, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2083,7 +2083,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "loops": 0.849155556, + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 6, @@ -2165,7 +2165,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "loops": 0.849155556, + "loops": 1, "rows": 4, "cost": "REPLACED", "filtered": "REPLACED", @@ -2241,7 +2241,7 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "loops": 0.849155556, + "loops": 1, "r_loops": 1, "rows": 4, "r_rows": 6, diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index 617aa350206..8e2188d74b9 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -599,15 +599,15 @@ and n_name = 'UNITED STATES' order by s_name limit 10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 100.00 Using where; Using filesort -1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 4.00 Using where -1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70 100.00 Using where -1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 35.71 Using where; FirstMatch(nation) +1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort +1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 +1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 7.03 Using where +1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 7.11 Using where; FirstMatch(supplier) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.40 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 -Note 1003 /* select#1 */ select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_name` = 'UNITED STATES' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`partsupp`.`ps_availqty` > <`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((/* select#4 */ select 0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`) from `dbt3_s001`.`lineitem` where `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`lineitem`.`l_shipDATE` >= (cast('1993-01-01' as date)) and `dbt3_s001`.`lineitem`.`l_shipDATE` < (cast('1993-01-01' as date) + interval '1' year))) and `dbt3_s001`.`part`.`p_name` like 'g%' order by `dbt3_s001`.`supplier`.`s_name` limit 10 +Note 1003 /* select#1 */ select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where `dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey` and `dbt3_s001`.`nation`.`n_name` = 'UNITED STATES' and `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`partsupp`.`ps_availqty` > <`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((/* select#4 */ select 0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`) from `dbt3_s001`.`lineitem` where `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`lineitem`.`l_shipDATE` >= (cast('1993-01-01' as date)) and `dbt3_s001`.`lineitem`.`l_shipDATE` < (cast('1993-01-01' as date) + interval '1' year))) and `dbt3_s001`.`part`.`p_name` like 'g%' order by `dbt3_s001`.`supplier`.`s_name` limit 10 select sql_calc_found_rows s_name, s_address from supplier, nation @@ -654,15 +654,15 @@ and n_name = 'UNITED STATES' order by s_name limit 10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 100.00 Using where; Using filesort -1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 4.00 Using where -1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70 100.00 Using where -1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 35.71 Using where; FirstMatch(nation) +1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort +1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 +1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 7.81 Using where +1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 6.40 Using where; FirstMatch(supplier) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.40 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 -Note 1003 /* select#1 */ select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_name` = 'UNITED STATES' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`partsupp`.`ps_availqty` > <`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((/* select#4 */ select 0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`) from `dbt3_s001`.`lineitem` where `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`lineitem`.`l_shipDATE` >= (cast('1993-01-01' as date)) and `dbt3_s001`.`lineitem`.`l_shipDATE` < (cast('1993-01-01' as date) + interval '1' year))) and `dbt3_s001`.`part`.`p_name` like 'g%' order by `dbt3_s001`.`supplier`.`s_name` limit 10 +Note 1003 /* select#1 */ select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where `dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey` and `dbt3_s001`.`nation`.`n_name` = 'UNITED STATES' and `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`partsupp`.`ps_availqty` > <`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((/* select#4 */ select 0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`) from `dbt3_s001`.`lineitem` where `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`lineitem`.`l_shipDATE` >= (cast('1993-01-01' as date)) and `dbt3_s001`.`lineitem`.`l_shipDATE` < (cast('1993-01-01' as date) + interval '1' year))) and `dbt3_s001`.`part`.`p_name` like 'g%' order by `dbt3_s001`.`supplier`.`s_name` limit 10 select sql_calc_found_rows s_name, s_address from supplier, nation @@ -709,15 +709,15 @@ and n_name = 'UNITED STATES' order by s_name limit 10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 100.00 Using where; Using filesort -1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 4.00 Using where -1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70 100.00 Using where -1 PRIMARY part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 35.71 Using where; FirstMatch(nation) +1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort +1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00 +1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 7.81 Using where +1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 6.40 Using where; FirstMatch(supplier) 4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.40 Using where Warnings: Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2 Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2 -Note 1003 /* select#1 */ select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where `dbt3_s001`.`nation`.`n_nationkey` = `dbt3_s001`.`supplier`.`s_nationkey` and `dbt3_s001`.`nation`.`n_name` = 'UNITED STATES' and `dbt3_s001`.`part`.`p_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`partsupp`.`ps_availqty` > <`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((/* select#4 */ select 0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`) from `dbt3_s001`.`lineitem` where `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`lineitem`.`l_shipDATE` >= (cast('1993-01-01' as date)) and `dbt3_s001`.`lineitem`.`l_shipDATE` < (cast('1993-01-01' as date) + interval '1' year))) and `dbt3_s001`.`part`.`p_name` like 'g%' order by `dbt3_s001`.`supplier`.`s_name` limit 10 +Note 1003 /* select#1 */ select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where `dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey` and `dbt3_s001`.`nation`.`n_name` = 'UNITED STATES' and `dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey` and `dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey` and `dbt3_s001`.`partsupp`.`ps_availqty` > <`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((/* select#4 */ select 0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`) from `dbt3_s001`.`lineitem` where `dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey` and `dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey` and `dbt3_s001`.`lineitem`.`l_shipDATE` >= (cast('1993-01-01' as date)) and `dbt3_s001`.`lineitem`.`l_shipDATE` < (cast('1993-01-01' as date) + interval '1' year))) and `dbt3_s001`.`part`.`p_name` like 'g%' order by `dbt3_s001`.`supplier`.`s_name` limit 10 select sql_calc_found_rows s_name, s_address from supplier, nation diff --git a/mysql-test/main/subselect_sj.result b/mysql-test/main/subselect_sj.result index a6905d5d819..677bdfb5ec7 100644 --- a/mysql-test/main/subselect_sj.result +++ b/mysql-test/main/subselect_sj.result @@ -2499,9 +2499,9 @@ SELECT * FROM t1, t2 WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 system NULL NULL NULL NULL 1 -1 PRIMARY t2 ref a a 5 const 1 Using index +1 PRIMARY t1 ref a a 5 const 1 Using index +1 PRIMARY t2 ref a a 5 func 1 Using index 1 PRIMARY t4 ALL NULL NULL NULL NULL 0 FirstMatch(t2); Using join buffer (flat, BNL join) -1 PRIMARY t1 ref a a 5 func 1 Using index SELECT * FROM t1, t2 WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4); a a diff --git a/mysql-test/main/subselect_sj_jcl6.result b/mysql-test/main/subselect_sj_jcl6.result index 78b2518891f..b416ae210bf 100644 --- a/mysql-test/main/subselect_sj_jcl6.result +++ b/mysql-test/main/subselect_sj_jcl6.result @@ -2505,9 +2505,9 @@ SELECT * FROM t1, t2 WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 system NULL NULL NULL NULL 1 -1 PRIMARY t2 ref a a 5 const 1 Using index +1 PRIMARY t1 ref a a 5 const 1 Using index +1 PRIMARY t2 ref a a 5 func 1 Using index 1 PRIMARY t4 ALL NULL NULL NULL NULL 0 FirstMatch(t2); Using join buffer (flat, BNL join) -1 PRIMARY t1 ref a a 5 func 1 Using index SELECT * FROM t1, t2 WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4); a a diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 72df1e6e2de..c3ac3f4bcac 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8101,6 +8101,14 @@ best_access_path(JOIN *join, Json_writer_object trace_wrapper(thd, "best_access_path"); DBUG_ENTER("best_access_path"); + /* + Assume that there is at least one accepted row from previous table combinations. + This fixes a problem when the selectivity for the preceding table combinations + becomes so high that record_count becomes << 1.0, which makes the cost for the + current table so low that it does not matter when calculating the best plans. + */ + set_if_bigger(record_count, 1.0); + best.cost= DBL_MAX; best.records= DBL_MAX; best.records_read= DBL_MAX; From b74d2623eb01756d2228921c8c3824f29c7f64fd Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 2 Dec 2022 17:27:34 +0200 Subject: [PATCH 082/123] Removed diff dates from rdiff files --- mysql-test/main/alter_table_combinations,aria.rdiff | 4 ++-- mysql-test/main/alter_table_combinations,heap.rdiff | 4 ++-- mysql-test/main/myisam_mrr,32bit.rdiff | 4 ++-- mysql-test/suite/engines/funcs/r/rpl_sp,myisam,mix.rdiff | 4 ++-- mysql-test/suite/galera/r/galera_ist_MDEV-28423,debug.rdiff | 4 ++-- mysql-test/suite/galera/r/galera_ist_MDEV-28583,debug.rdiff | 4 ++-- mysql-test/suite/galera/r/galera_ist_mariabackup,debug.rdiff | 4 ++-- .../r/galera_ist_mariabackup_innodb_flush_logs,debug.rdiff | 4 ++-- mysql-test/suite/galera/r/galera_ist_rsync,debug.rdiff | 4 ++-- .../galera/r/galera_sst_mariabackup_data_dir,debug.rdiff | 4 ++-- .../r/galera_sst_mariabackup_force_recovery,debug.rdiff | 4 ++-- mysql-test/suite/galera/r/galera_sst_rsync2,debug.rdiff | 4 ++-- .../suite/galera/r/galera_sst_rsync_data_dir,debug.rdiff | 4 ++-- mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff | 4 ++-- mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff | 4 ++-- mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff | 4 ++-- mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff | 4 ++-- mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff | 4 ++-- mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff | 4 ++-- mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff | 4 ++-- mysql-test/suite/innodb/r/instant_alter_limit,16k.rdiff | 4 ++-- mysql-test/suite/innodb/r/instant_alter_limit,32k.rdiff | 4 ++-- mysql-test/suite/innodb/r/instant_alter_limit,4k.rdiff | 4 ++-- mysql-test/suite/innodb/r/instant_alter_limit,64k.rdiff | 4 ++-- mysql-test/suite/innodb/r/instant_alter_limit,8k.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,16k,compact,innodb.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,16k,dynamic,innodb.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,16k,innodb,redundant.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,32k,compact,innodb.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,32k,dynamic,innodb.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,32k,innodb,redundant.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,4k,compact,innodb.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,4k,dynamic,innodb.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,4k,innodb,redundant.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,64k,compact,innodb.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,64k,dynamic,innodb.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,64k,innodb,redundant.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,8k,compact,innodb.rdiff | 4 ++-- .../suite/innodb/r/max_record_size,8k,dynamic,innodb.rdiff | 4 ++-- mysql-test/suite/innodb/r/restart,16k,innodb.rdiff | 4 ++-- mysql-test/suite/innodb/r/restart,32k,innodb.rdiff | 4 ++-- mysql-test/suite/innodb/r/restart,4k,innodb.rdiff | 4 ++-- mysql-test/suite/innodb/r/restart,64k,innodb.rdiff | 4 ++-- mysql-test/suite/innodb/r/restart,8k,innodb.rdiff | 4 ++-- mysql-test/suite/mtr/t/simple,c2,s1.rdiff | 4 ++-- mysql-test/suite/mtr/t/simple,s2,c2.rdiff | 4 ++-- mysql-test/suite/period/r/delete,myisam.rdiff | 4 ++-- mysql-test/suite/rpl/r/rpl_delayed_slave,parallel.rdiff | 4 ++-- mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff | 4 ++-- mysql-test/suite/rpl/r/rpl_iodku,stmt.rdiff | 4 ++-- mysql-test/suite/rpl/r/rpl_row_big_table_id,32bit.rdiff | 4 ++-- .../suite/sys_vars/r/aria_sort_buffer_size_basic,32bit.rdiff | 4 ++-- .../suite/sys_vars/r/innodb_ft_result_cache_limit,32bit.rdiff | 4 ++-- mysql-test/suite/sys_vars/r/sysvars_aria,32bit.rdiff | 4 ++-- mysql-test/suite/sys_vars/r/sysvars_debug,32bit.rdiff | 4 ++-- mysql-test/suite/sys_vars/r/sysvars_wsrep,32bit.rdiff | 4 ++-- mysql-test/suite/versioning/r/select,trx_id.rdiff | 4 ++-- mysql-test/suite/versioning/r/select2,trx_id.rdiff | 4 ++-- mysql-test/suite/versioning/r/update,trx_id.rdiff | 4 ++-- mysql-test/suite/wsrep/r/wsrep-recover-v25,binlogon.rdiff | 4 ++-- 60 files changed, 120 insertions(+), 120 deletions(-) diff --git a/mysql-test/main/alter_table_combinations,aria.rdiff b/mysql-test/main/alter_table_combinations,aria.rdiff index 9ea38135908..e030571679f 100644 --- a/mysql-test/main/alter_table_combinations,aria.rdiff +++ b/mysql-test/main/alter_table_combinations,aria.rdiff @@ -1,5 +1,5 @@ ---- main/alter_table_combinations.result 2022-05-24 17:16:56.769146869 +0200 -+++ main/alter_table_combinations.reject 2022-05-24 17:25:20.847126357 +0200 +--- main/alter_table_combinations.result ++++ main/alter_table_combinations.reject @@ -173,8 +173,7 @@ t3 CREATE TABLE `t3` ( `a` int(11) DEFAULT NULL, diff --git a/mysql-test/main/alter_table_combinations,heap.rdiff b/mysql-test/main/alter_table_combinations,heap.rdiff index 0ca6d3de88d..493ce0ea884 100644 --- a/mysql-test/main/alter_table_combinations,heap.rdiff +++ b/mysql-test/main/alter_table_combinations,heap.rdiff @@ -1,5 +1,5 @@ ---- main/alter_table_combinations.result 2022-05-24 17:16:56.769146869 +0200 -+++ main/alter_table_combinations.reject 2022-05-24 17:25:01.216127156 +0200 +--- main/alter_table_combinations.result ++++ main/alter_table_combinations.reject @@ -11,7 +11,7 @@ alter table t1 change x xx int, algorithm=inplace; check table t1; diff --git a/mysql-test/main/myisam_mrr,32bit.rdiff b/mysql-test/main/myisam_mrr,32bit.rdiff index 746bf48dedd..eda77abbfce 100644 --- a/mysql-test/main/myisam_mrr,32bit.rdiff +++ b/mysql-test/main/myisam_mrr,32bit.rdiff @@ -1,5 +1,5 @@ ---- main/myisam_mrr.result 2019-05-14 15:44:52.232663568 +0530 -+++ main/myisam_mrr.reject 2019-05-14 15:51:37.123563538 +0530 +--- main/myisam_mrr.result ++++ main/myisam_mrr.reject @@ -617,8 +617,8 @@ show status like 'handler_mrr%'; Variable_name Value diff --git a/mysql-test/suite/engines/funcs/r/rpl_sp,myisam,mix.rdiff b/mysql-test/suite/engines/funcs/r/rpl_sp,myisam,mix.rdiff index da41283e42f..cbf297f8071 100644 --- a/mysql-test/suite/engines/funcs/r/rpl_sp,myisam,mix.rdiff +++ b/mysql-test/suite/engines/funcs/r/rpl_sp,myisam,mix.rdiff @@ -1,5 +1,5 @@ ---- /home/alice/git/10.3/mysql-test/suite/engines/funcs/r/rpl_sp,myisam,mix.result~ 2021-03-19 17:27:12.935559866 +0100 -+++ /home/alice/git/10.3/mysql-test/suite/engines/funcs/r/rpl_sp,myisam,mix.reject 2021-03-19 17:27:14.071534938 +0100 +--- /home/alice/git/10.3/mysql-test/suite/engines/funcs/r/rpl_sp,myisam,mix.result~ ++++ /home/alice/git/10.3/mysql-test/suite/engines/funcs/r/rpl_sp,myisam,mix.reject @@ -126,12 +126,15 @@ show warnings; Level Code Message diff --git a/mysql-test/suite/galera/r/galera_ist_MDEV-28423,debug.rdiff b/mysql-test/suite/galera/r/galera_ist_MDEV-28423,debug.rdiff index 4eda9d7d045..32c3949b1c4 100644 --- a/mysql-test/suite/galera/r/galera_ist_MDEV-28423,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_ist_MDEV-28423,debug.rdiff @@ -1,5 +1,5 @@ ---- suite/galera/r/galera_ist_MDEV-28423.result 2022-06-13 09:40:33.073863796 +0300 -+++ suite/galera/r/galera_ist_MDEV-28423.reject 2022-06-13 09:58:59.936874991 +0300 +--- suite/galera/r/galera_ist_MDEV-28423.result ++++ suite/galera/r/galera_ist_MDEV-28423.reject @@ -517,3 +517,187 @@ 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_ist_MDEV-28583,debug.rdiff b/mysql-test/suite/galera/r/galera_ist_MDEV-28583,debug.rdiff index 1c33916330a..c1bc37fb202 100644 --- a/mysql-test/suite/galera/r/galera_ist_MDEV-28583,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_ist_MDEV-28583,debug.rdiff @@ -1,5 +1,5 @@ ---- suite/galera/r/galera_ist_MDEV-28583.result 2022-06-11 10:48:16.875034382 +0300 -+++ suite/galera/r/galera_ist_MDEV-28583,debug.reject 2022-06-11 11:25:55.616481509 +0300 +--- suite/galera/r/galera_ist_MDEV-28583.result ++++ suite/galera/r/galera_ist_MDEV-28583,debug.reject @@ -517,3 +517,187 @@ 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_ist_mariabackup,debug.rdiff b/mysql-test/suite/galera/r/galera_ist_mariabackup,debug.rdiff index adf12c23e4a..243b2a50b2a 100644 --- a/mysql-test/suite/galera/r/galera_ist_mariabackup,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_ist_mariabackup,debug.rdiff @@ -1,5 +1,5 @@ ---- r/galera_ist_mariabackup.result 2021-04-10 14:21:16.141724901 +0300 -+++ r/galera_ist_mariabackup,debug.reject 2021-04-10 14:49:04.455785652 +0300 +--- r/galera_ist_mariabackup.result ++++ r/galera_ist_mariabackup,debug.reject @@ -517,3 +517,187 @@ 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_ist_mariabackup_innodb_flush_logs,debug.rdiff b/mysql-test/suite/galera/r/galera_ist_mariabackup_innodb_flush_logs,debug.rdiff index c9457d70812..b7a91b010fe 100644 --- a/mysql-test/suite/galera/r/galera_ist_mariabackup_innodb_flush_logs,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_ist_mariabackup_innodb_flush_logs,debug.rdiff @@ -1,5 +1,5 @@ ---- r/galera_ist_mariabackup_innodb_flush_logs.result 2021-04-10 14:21:52.661886653 +0300 -+++ r/galera_ist_mariabackup_innodb_flush_logs,debug.reject 2021-04-10 14:49:56.740062774 +0300 +--- r/galera_ist_mariabackup_innodb_flush_logs.result ++++ r/galera_ist_mariabackup_innodb_flush_logs,debug.reject @@ -172,3 +172,187 @@ 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_ist_rsync,debug.rdiff b/mysql-test/suite/galera/r/galera_ist_rsync,debug.rdiff index e76b37838fb..f3df998be95 100644 --- a/mysql-test/suite/galera/r/galera_ist_rsync,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_ist_rsync,debug.rdiff @@ -1,5 +1,5 @@ ---- r/galera_ist_rsync.result 2021-04-10 14:24:05.942467091 +0300 -+++ r/galera_ist_rsync,debug.reject 2021-04-10 14:52:14.236776538 +0300 +--- r/galera_ist_rsync.result ++++ r/galera_ist_rsync,debug.reject @@ -517,3 +517,187 @@ 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_sst_mariabackup_data_dir,debug.rdiff b/mysql-test/suite/galera/r/galera_sst_mariabackup_data_dir,debug.rdiff index 870b12de3c9..875d53addd8 100644 --- a/mysql-test/suite/galera/r/galera_sst_mariabackup_data_dir,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_sst_mariabackup_data_dir,debug.rdiff @@ -1,5 +1,5 @@ ---- r/galera_sst_mariabackup_data_dir.result 2021-04-10 14:26:02.798965488 +0300 -+++ r/galera_sst_mariabackup_data_dir,debug.reject 2021-04-10 14:54:44.825538224 +0300 +--- r/galera_sst_mariabackup_data_dir.result ++++ r/galera_sst_mariabackup_data_dir,debug.reject @@ -516,5 +516,189 @@ 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_sst_mariabackup_force_recovery,debug.rdiff b/mysql-test/suite/galera/r/galera_sst_mariabackup_force_recovery,debug.rdiff index bad8355b514..da294317c27 100644 --- a/mysql-test/suite/galera/r/galera_sst_mariabackup_force_recovery,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_sst_mariabackup_force_recovery,debug.rdiff @@ -1,5 +1,5 @@ ---- r/galera_sst_mariabackup.result 2021-04-10 14:25:04.142716409 +0300 -+++ r/galera_sst_mariabackup,debug.reject 2021-04-10 14:53:30.033162191 +0300 +--- r/galera_sst_mariabackup.result ++++ r/galera_sst_mariabackup,debug.reject @@ -516,5 +516,189 @@ 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_sst_rsync2,debug.rdiff b/mysql-test/suite/galera/r/galera_sst_rsync2,debug.rdiff index 14f67770572..ae242e2b216 100644 --- a/mysql-test/suite/galera/r/galera_sst_rsync2,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_sst_rsync2,debug.rdiff @@ -1,5 +1,5 @@ ---- r/galera_sst_rsync2.result 2021-04-10 14:34:48.646288119 +0300 -+++ r/galera_sst_rsync2,debug.reject 2021-04-10 15:04:10.276286996 +0300 +--- r/galera_sst_rsync2.result ++++ r/galera_sst_rsync2,debug.reject @@ -516,3 +516,187 @@ 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_data_dir,debug.rdiff b/mysql-test/suite/galera/r/galera_sst_rsync_data_dir,debug.rdiff index 00b42d53b51..558a8e7cd07 100644 --- a/mysql-test/suite/galera/r/galera_sst_rsync_data_dir,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_sst_rsync_data_dir,debug.rdiff @@ -1,5 +1,5 @@ ---- r/galera_sst_rsync_data_dir.result 2021-04-10 14:35:28.090610315 +0300 -+++ r/galera_sst_rsync_data_dir,debug.reject 2021-04-10 15:50:26.945234998 +0300 +--- r/galera_sst_rsync_data_dir.result ++++ r/galera_sst_rsync_data_dir,debug.reject @@ -516,3 +516,187 @@ 1 DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff index a176a9af29e..79b3d8854fa 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff @@ -1,5 +1,5 @@ ---- alter_algorithm.result 2020-04-30 21:39:48.923115511 +0530 -+++ alter_algorithm.reject 2020-04-30 21:45:04.131642093 +0530 +--- alter_algorithm.result ++++ alter_algorithm.reject @@ -7,43 +7,43 @@ INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); SELECT @@alter_algorithm; diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff index 414b7dc8b0c..fbcb5ca8704 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff @@ -1,5 +1,5 @@ ---- alter_algorithm.result 2020-04-30 21:39:48.923115511 +0530 -+++ alter_algorithm.reject 2020-04-30 21:47:08.245465018 +0530 +--- alter_algorithm.result ++++ alter_algorithm.reject @@ -7,43 +7,35 @@ INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); SELECT @@alter_algorithm; diff --git a/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff index 2aa8c72265a..44e9f63a5f4 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff @@ -1,5 +1,5 @@ ---- alter_algorithm.result 2020-04-30 21:39:48.923115511 +0530 -+++ alter_algorithm.reject 2020-04-30 21:52:10.785967739 +0530 +--- alter_algorithm.result ++++ alter_algorithm.reject @@ -7,43 +7,35 @@ INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); SELECT @@alter_algorithm; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff index 44446602b9f..b19abb449ad 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 -+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:29:25.129637040 +0530 +--- mysql-test/suite/innodb/r/check_ibd_filesize.result ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject @@ -3,18 +3,12 @@ # SPACE IN 5.7 THAN IN 5.6 # diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff index ef55ad971fe..a1011a1cb90 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 -+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:39.288769153 +0530 +--- mysql-test/suite/innodb/r/check_ibd_filesize.result ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject @@ -3,18 +3,18 @@ # SPACE IN 5.7 THAN IN 5.6 # diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff index bcdcea31160..010eb8a284d 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 -+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:30:28.957174270 +0530 +--- mysql-test/suite/innodb/r/check_ibd_filesize.result ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject @@ -3,18 +3,12 @@ # SPACE IN 5.7 THAN IN 5.6 # diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff index 7b699ef4cea..0e1e64724b0 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 -+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:03.516962339 +0530 +--- mysql-test/suite/innodb/r/check_ibd_filesize.result ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject @@ -3,18 +3,18 @@ # SPACE IN 5.7 THAN IN 5.6 # diff --git a/mysql-test/suite/innodb/r/instant_alter_limit,16k.rdiff b/mysql-test/suite/innodb/r/instant_alter_limit,16k.rdiff index 57d87f7172f..320df318434 100644 --- a/mysql-test/suite/innodb/r/instant_alter_limit,16k.rdiff +++ b/mysql-test/suite/innodb/r/instant_alter_limit,16k.rdiff @@ -1,5 +1,5 @@ ---- instant_alter_limit.result 2020-05-26 18:01:27.377946439 +0530 -+++ instant_alter_limit,16k.reject 2020-05-26 20:14:38.452463919 +0530 +--- instant_alter_limit.result ++++ instant_alter_limit,16k.reject @@ -45,3 +45,10 @@ instants 502 diff --git a/mysql-test/suite/innodb/r/instant_alter_limit,32k.rdiff b/mysql-test/suite/innodb/r/instant_alter_limit,32k.rdiff index 8f8cf64b7fc..951f0ce2320 100644 --- a/mysql-test/suite/innodb/r/instant_alter_limit,32k.rdiff +++ b/mysql-test/suite/innodb/r/instant_alter_limit,32k.rdiff @@ -1,5 +1,5 @@ ---- instant_alter_limit.result 2020-05-26 18:01:27.377946439 +0530 -+++ instant_alter_limit,32k.reject 2020-05-26 19:59:19.743877366 +0530 +--- instant_alter_limit.result ++++ instant_alter_limit,32k.reject @@ -43,5 +43,12 @@ FROM information_schema.global_status WHERE variable_name = 'innodb_instant_alter_column'; diff --git a/mysql-test/suite/innodb/r/instant_alter_limit,4k.rdiff b/mysql-test/suite/innodb/r/instant_alter_limit,4k.rdiff index dad28218a02..0ebd590ad54 100644 --- a/mysql-test/suite/innodb/r/instant_alter_limit,4k.rdiff +++ b/mysql-test/suite/innodb/r/instant_alter_limit,4k.rdiff @@ -1,5 +1,5 @@ ---- instant_alter_limit.result 2020-05-26 18:01:27.377946439 +0530 -+++ instant_alter_limit,4k.reject 2020-05-26 20:17:53.314736548 +0530 +--- instant_alter_limit.result ++++ instant_alter_limit,4k.reject @@ -5,6 +5,276 @@ ENGINE=InnoDB; INSERT INTO t VALUES(1,2,3,4,5); diff --git a/mysql-test/suite/innodb/r/instant_alter_limit,64k.rdiff b/mysql-test/suite/innodb/r/instant_alter_limit,64k.rdiff index d7479dbba40..7c58fa4a8db 100644 --- a/mysql-test/suite/innodb/r/instant_alter_limit,64k.rdiff +++ b/mysql-test/suite/innodb/r/instant_alter_limit,64k.rdiff @@ -1,5 +1,5 @@ ---- instant_alter_limit.result 2020-05-26 18:01:27.377946439 +0530 -+++ instant_alter_limit,64k.reject 2020-05-26 20:00:22.499711222 +0530 +--- instant_alter_limit.result ++++ instant_alter_limit,64k.reject @@ -43,5 +43,12 @@ FROM information_schema.global_status WHERE variable_name = 'innodb_instant_alter_column'; diff --git a/mysql-test/suite/innodb/r/instant_alter_limit,8k.rdiff b/mysql-test/suite/innodb/r/instant_alter_limit,8k.rdiff index 1fe3e1a56eb..d70156f3083 100644 --- a/mysql-test/suite/innodb/r/instant_alter_limit,8k.rdiff +++ b/mysql-test/suite/innodb/r/instant_alter_limit,8k.rdiff @@ -1,5 +1,5 @@ ---- instant_alter_limit.result 2020-05-26 18:01:27.377946439 +0530 -+++ instant_alter_limit,8k.reject 2020-05-26 20:19:50.881869095 +0530 +--- instant_alter_limit.result ++++ instant_alter_limit,8k.reject @@ -5,6 +5,28 @@ ENGINE=InnoDB; INSERT INTO t VALUES(1,2,3,4,5); diff --git a/mysql-test/suite/innodb/r/max_record_size,16k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,16k,compact,innodb.rdiff index 118145bec2e..b9f51624729 100644 --- a/mysql-test/suite/innodb/r/max_record_size,16k,compact,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,16k,compact,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:51:26.070418078 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -3,45 +3,65 @@ c1 CHAR(255), c2 CHAR(255), c3 CHAR(255), c4 CHAR(255), c5 CHAR(255), c6 CHAR(255), c7 CHAR(255), c8 CHAR(255), diff --git a/mysql-test/suite/innodb/r/max_record_size,16k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,16k,dynamic,innodb.rdiff index 33067866b82..5effc664f2c 100644 --- a/mysql-test/suite/innodb/r/max_record_size,16k,dynamic,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,16k,dynamic,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:52:54.580956978 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -3,45 +3,207 @@ c1 CHAR(255), c2 CHAR(255), c3 CHAR(255), c4 CHAR(255), c5 CHAR(255), c6 CHAR(255), c7 CHAR(255), c8 CHAR(255), diff --git a/mysql-test/suite/innodb/r/max_record_size,16k,innodb,redundant.rdiff b/mysql-test/suite/innodb/r/max_record_size,16k,innodb,redundant.rdiff index e50e4d2be3a..227b64a8a48 100644 --- a/mysql-test/suite/innodb/r/max_record_size,16k,innodb,redundant.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,16k,innodb,redundant.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:55:05.258762945 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -3,45 +3,65 @@ c1 CHAR(255), c2 CHAR(255), c3 CHAR(255), c4 CHAR(255), c5 CHAR(255), c6 CHAR(255), c7 CHAR(255), c8 CHAR(255), diff --git a/mysql-test/suite/innodb/r/max_record_size,32k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,32k,compact,innodb.rdiff index 1bc03a5d97a..d236e12b1e1 100644 --- a/mysql-test/suite/innodb/r/max_record_size,32k,compact,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,32k,compact,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:27:08.004932026 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -3,45 +3,104 @@ c1 CHAR(255), c2 CHAR(255), c3 CHAR(255), c4 CHAR(255), c5 CHAR(255), c6 CHAR(255), c7 CHAR(255), c8 CHAR(255), diff --git a/mysql-test/suite/innodb/r/max_record_size,32k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,32k,dynamic,innodb.rdiff index 71c4c2e41b7..ce9462b6900 100644 --- a/mysql-test/suite/innodb/r/max_record_size,32k,dynamic,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,32k,dynamic,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:38:41.609328820 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -3,45 +3,351 @@ c1 CHAR(255), c2 CHAR(255), c3 CHAR(255), c4 CHAR(255), c5 CHAR(255), c6 CHAR(255), c7 CHAR(255), c8 CHAR(255), diff --git a/mysql-test/suite/innodb/r/max_record_size,32k,innodb,redundant.rdiff b/mysql-test/suite/innodb/r/max_record_size,32k,innodb,redundant.rdiff index e42b3de8845..53d6f76a2d2 100644 --- a/mysql-test/suite/innodb/r/max_record_size,32k,innodb,redundant.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,32k,innodb,redundant.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:41:03.319664978 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -3,45 +3,104 @@ c1 CHAR(255), c2 CHAR(255), c3 CHAR(255), c4 CHAR(255), c5 CHAR(255), c6 CHAR(255), c7 CHAR(255), c8 CHAR(255), diff --git a/mysql-test/suite/innodb/r/max_record_size,4k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,4k,compact,innodb.rdiff index 6f08dab3ca1..37871798f31 100644 --- a/mysql-test/suite/innodb/r/max_record_size,4k,compact,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,4k,compact,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:56:23.489432164 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -1,47 +1,37 @@ call mtr.add_suppression("Cannot add field `.*` in table `test`.`t1` because after adding it, the row size is"); CREATE TABLE t1 ( diff --git a/mysql-test/suite/innodb/r/max_record_size,4k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,4k,dynamic,innodb.rdiff index bd37d4354e7..b0b6b007d97 100644 --- a/mysql-test/suite/innodb/r/max_record_size,4k,dynamic,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,4k,dynamic,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:57:38.636143710 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -1,47 +1,103 @@ call mtr.add_suppression("Cannot add field `.*` in table `test`.`t1` because after adding it, the row size is"); CREATE TABLE t1 ( diff --git a/mysql-test/suite/innodb/r/max_record_size,4k,innodb,redundant.rdiff b/mysql-test/suite/innodb/r/max_record_size,4k,innodb,redundant.rdiff index 93c39ff6714..0db6450d9c1 100644 --- a/mysql-test/suite/innodb/r/max_record_size,4k,innodb,redundant.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,4k,innodb,redundant.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:58:58.318768169 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -1,47 +1,37 @@ call mtr.add_suppression("Cannot add field `.*` in table `test`.`t1` because after adding it, the row size is"); CREATE TABLE t1 ( diff --git a/mysql-test/suite/innodb/r/max_record_size,64k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,64k,compact,innodb.rdiff index 5e6c62212d1..ab75975e238 100644 --- a/mysql-test/suite/innodb/r/max_record_size,64k,compact,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,64k,compact,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:45:21.760116841 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -3,45 +3,186 @@ c1 CHAR(255), c2 CHAR(255), c3 CHAR(255), c4 CHAR(255), c5 CHAR(255), c6 CHAR(255), c7 CHAR(255), c8 CHAR(255), diff --git a/mysql-test/suite/innodb/r/max_record_size,64k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,64k,dynamic,innodb.rdiff index 2cbf4cd9c54..3e13a510055 100644 --- a/mysql-test/suite/innodb/r/max_record_size,64k,dynamic,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,64k,dynamic,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:48:32.453208310 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -3,45 +3,486 @@ c1 CHAR(255), c2 CHAR(255), c3 CHAR(255), c4 CHAR(255), c5 CHAR(255), c6 CHAR(255), c7 CHAR(255), c8 CHAR(255), diff --git a/mysql-test/suite/innodb/r/max_record_size,64k,innodb,redundant.rdiff b/mysql-test/suite/innodb/r/max_record_size,64k,innodb,redundant.rdiff index c324969fb21..a31285a2714 100644 --- a/mysql-test/suite/innodb/r/max_record_size,64k,innodb,redundant.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,64k,innodb,redundant.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 12:50:05.663724193 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -3,45 +3,104 @@ c1 CHAR(255), c2 CHAR(255), c3 CHAR(255), c4 CHAR(255), c5 CHAR(255), c6 CHAR(255), c7 CHAR(255), c8 CHAR(255), diff --git a/mysql-test/suite/innodb/r/max_record_size,8k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,8k,compact,innodb.rdiff index 4db669a8aa6..cafb5f25a0d 100644 --- a/mysql-test/suite/innodb/r/max_record_size,8k,compact,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,8k,compact,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 13:00:25.037261867 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -12,7 +12,7 @@ c9 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255), c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255) diff --git a/mysql-test/suite/innodb/r/max_record_size,8k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,8k,dynamic,innodb.rdiff index 5f79d77e7f9..2f592fbb4b3 100644 --- a/mysql-test/suite/innodb/r/max_record_size,8k,dynamic,innodb.rdiff +++ b/mysql-test/suite/innodb/r/max_record_size,8k,dynamic,innodb.rdiff @@ -1,5 +1,5 @@ ---- max_record_size.result 2019-07-03 11:54:44.591421526 +0300 -+++ max_record_size.reject 2019-07-03 13:01:51.215756779 +0300 +--- max_record_size.result ++++ max_record_size.reject @@ -12,7 +12,7 @@ c9 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255), c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255) diff --git a/mysql-test/suite/innodb/r/restart,16k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,16k,innodb.rdiff index b36ed067913..3149b9aeab0 100644 --- a/mysql-test/suite/innodb/r/restart,16k,innodb.rdiff +++ b/mysql-test/suite/innodb/r/restart,16k,innodb.rdiff @@ -1,5 +1,5 @@ ---- ./suite/innodb/r/restart.result 2022-01-18 20:36:56.054653376 +1100 -+++ suite/innodb/r/restart.reject 2022-01-19 08:12:28.602794678 +1100 +--- ./suite/innodb/r/restart.result ++++ suite/innodb/r/restart.reject @@ -32,10 +32,10 @@ SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig; SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size; diff --git a/mysql-test/suite/innodb/r/restart,32k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,32k,innodb.rdiff index 8fa057814c4..3f00646cb37 100644 --- a/mysql-test/suite/innodb/r/restart,32k,innodb.rdiff +++ b/mysql-test/suite/innodb/r/restart,32k,innodb.rdiff @@ -1,5 +1,5 @@ ---- ./suite/innodb/r/restart.result 2022-01-18 20:36:56.054653376 +1100 -+++ suite/innodb/r/restart.reject 2022-01-19 08:07:57.402230887 +1100 +--- ./suite/innodb/r/restart.result ++++ suite/innodb/r/restart.reject @@ -32,10 +32,10 @@ SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig; SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size; diff --git a/mysql-test/suite/innodb/r/restart,4k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,4k,innodb.rdiff index 7d0846360e0..b00c56ef81f 100644 --- a/mysql-test/suite/innodb/r/restart,4k,innodb.rdiff +++ b/mysql-test/suite/innodb/r/restart,4k,innodb.rdiff @@ -1,5 +1,5 @@ ---- ./suite/innodb/r/restart.result 2022-01-18 20:36:56.054653376 +1100 -+++ suite/innodb/r/restart.reject 2022-01-19 08:13:56.397475513 +1100 +--- ./suite/innodb/r/restart.result ++++ suite/innodb/r/restart.reject @@ -32,10 +32,10 @@ SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig; SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size; diff --git a/mysql-test/suite/innodb/r/restart,64k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,64k,innodb.rdiff index 3ac9f45b196..886cbcde7d9 100644 --- a/mysql-test/suite/innodb/r/restart,64k,innodb.rdiff +++ b/mysql-test/suite/innodb/r/restart,64k,innodb.rdiff @@ -1,5 +1,5 @@ ---- ./suite/innodb/r/restart.result 2022-01-18 20:36:56.054653376 +1100 -+++ suite/innodb/r/restart.reject 2022-01-19 08:11:32.418759095 +1100 +--- ./suite/innodb/r/restart.result ++++ suite/innodb/r/restart.reject @@ -32,10 +32,10 @@ SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig; SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size; diff --git a/mysql-test/suite/innodb/r/restart,8k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,8k,innodb.rdiff index 4da55ebfcef..40a9e1bad1c 100644 --- a/mysql-test/suite/innodb/r/restart,8k,innodb.rdiff +++ b/mysql-test/suite/innodb/r/restart,8k,innodb.rdiff @@ -1,5 +1,5 @@ ---- ./suite/innodb/r/restart.result 2022-01-18 20:36:56.054653376 +1100 -+++ suite/innodb/r/restart.reject 2022-01-19 08:13:11.027788852 +1100 +--- ./suite/innodb/r/restart.result ++++ suite/innodb/r/restart.reject @@ -32,10 +32,10 @@ SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig; SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size; diff --git a/mysql-test/suite/mtr/t/simple,c2,s1.rdiff b/mysql-test/suite/mtr/t/simple,c2,s1.rdiff index 3023756aa8a..91f800a6211 100644 --- a/mysql-test/suite/mtr/t/simple,c2,s1.rdiff +++ b/mysql-test/suite/mtr/t/simple,c2,s1.rdiff @@ -1,5 +1,5 @@ ---- suite/mtr/t/simple.result 2012-02-04 12:13:41.000000000 +0100 -+++ suite/mtr/t/simple,infile,verbose.reject 2012-02-04 12:16:10.000000000 +0100 +--- suite/mtr/t/simple.result ++++ suite/mtr/t/simple,infile,verbose.reject @@ -3,7 +3,7 @@ proxy select @@local_infile; diff --git a/mysql-test/suite/mtr/t/simple,s2,c2.rdiff b/mysql-test/suite/mtr/t/simple,s2,c2.rdiff index a9b9b56ef1c..a4c9ab968c5 100644 --- a/mysql-test/suite/mtr/t/simple,s2,c2.rdiff +++ b/mysql-test/suite/mtr/t/simple,s2,c2.rdiff @@ -1,5 +1,5 @@ ---- suite/mtr/t/simple,old.result 2012-02-04 12:13:25.000000000 +0100 -+++ suite/mtr/t/simple,old,infile.reject 2012-02-04 12:13:59.000000000 +0100 +--- suite/mtr/t/simple,old.result ++++ suite/mtr/t/simple,old,infile.reject @@ -3,7 +3,7 @@ proxy select @@local_infile; diff --git a/mysql-test/suite/period/r/delete,myisam.rdiff b/mysql-test/suite/period/r/delete,myisam.rdiff index 78fb972b0bc..179f399ac9a 100644 --- a/mysql-test/suite/period/r/delete,myisam.rdiff +++ b/mysql-test/suite/period/r/delete,myisam.rdiff @@ -1,5 +1,5 @@ ---- suite/period/r/delete.result 2019-02-16 11:14:23.511258191 +0100 -+++ suite/period/r/delete.reject 2019-02-16 11:14:32.869258690 +0100 +--- suite/period/r/delete.result ++++ suite/period/r/delete.reject @@ -250,7 +250,6 @@ ERROR 22003: Out of range value for column 'id' at row 1 select * from t; diff --git a/mysql-test/suite/rpl/r/rpl_delayed_slave,parallel.rdiff b/mysql-test/suite/rpl/r/rpl_delayed_slave,parallel.rdiff index aaadbb28ca3..d803f8be5c2 100644 --- a/mysql-test/suite/rpl/r/rpl_delayed_slave,parallel.rdiff +++ b/mysql-test/suite/rpl/r/rpl_delayed_slave,parallel.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/rpl/r/rpl_delayed_slave.result 2016-10-14 21:14:02.338075590 +0200 -+++ mysql-test/suite/rpl/r/rpl_delayed_slave,parallel.reject 2016-10-14 21:17:51.296986686 +0200 +--- mysql-test/suite/rpl/r/rpl_delayed_slave.result ++++ mysql-test/suite/rpl/r/rpl_delayed_slave,parallel.reject @@ -45,7 +45,6 @@ # wait for first query to execute # sleep 1*T diff --git a/mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff b/mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff index 1946228f401..d1a101e51ca 100644 --- a/mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff +++ b/mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff @@ -1,5 +1,5 @@ ---- suite/rpl/r/rpl_insert_delayed.result 2016-03-25 19:44:43.408210896 +0400 -+++ suite/rpl/r/rpl_insert_delayed,stmt.reject 2016-03-25 23:55:18.396360848 +0400 +--- suite/rpl/r/rpl_insert_delayed.result ++++ suite/rpl/r/rpl_insert_delayed,stmt.reject @@ -18,19 +18,19 @@ insert delayed into t1 values(10, "my name"); flush table t1; diff --git a/mysql-test/suite/rpl/r/rpl_iodku,stmt.rdiff b/mysql-test/suite/rpl/r/rpl_iodku,stmt.rdiff index e31f1e5d991..2986a47c9ae 100644 --- a/mysql-test/suite/rpl/r/rpl_iodku,stmt.rdiff +++ b/mysql-test/suite/rpl/r/rpl_iodku,stmt.rdiff @@ -1,5 +1,5 @@ ---- r/rpl_iodku.result 2022-05-04 18:51:24.956414404 +0300 -+++ r/rpl_iodku,stmt.reject 2022-05-04 18:51:49.520106231 +0300 +--- r/rpl_iodku.result ++++ r/rpl_iodku,stmt.reject @@ -1,10 +1,15 @@ include/master-slave.inc [connection master] diff --git a/mysql-test/suite/rpl/r/rpl_row_big_table_id,32bit.rdiff b/mysql-test/suite/rpl/r/rpl_row_big_table_id,32bit.rdiff index 3815ec9375d..1154f92c39e 100644 --- a/mysql-test/suite/rpl/r/rpl_row_big_table_id,32bit.rdiff +++ b/mysql-test/suite/rpl/r/rpl_row_big_table_id,32bit.rdiff @@ -1,5 +1,5 @@ ---- /home/my/maria-test/mysql-test/suite/rpl/r/rpl_row_big_table_id.result 2019-08-18 15:19:56.829962449 +0300 -+++ /home/my/maria-test/mysql-test/suite/rpl/r/rpl_row_big_table_id,32bit.reject 2019-08-18 15:20:19.253763968 +0300 +--- /home/my/maria-test/mysql-test/suite/rpl/r/rpl_row_big_table_id.result ++++ /home/my/maria-test/mysql-test/suite/rpl/r/rpl_row_big_table_id,32bit.reject @@ -20,22 +20,22 @@ master-bin.000001 # Query 1 # use `test`; ALTER TABLE t comment '' master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# diff --git a/mysql-test/suite/sys_vars/r/aria_sort_buffer_size_basic,32bit.rdiff b/mysql-test/suite/sys_vars/r/aria_sort_buffer_size_basic,32bit.rdiff index c30b99f1f95..77bb1f81d40 100644 --- a/mysql-test/suite/sys_vars/r/aria_sort_buffer_size_basic,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/aria_sort_buffer_size_basic,32bit.rdiff @@ -1,5 +1,5 @@ ---- suite/sys_vars/r/aria_sort_buffer_size_basic.result 2021-02-02 02:58:55.686921205 +0200 -+++ suite/sys_vars/r/aria_sort_buffer_size_basic.reject 2021-02-02 11:02:12.361178360 +0200 +--- suite/sys_vars/r/aria_sort_buffer_size_basic.result ++++ suite/sys_vars/r/aria_sort_buffer_size_basic.reject @@ -44,5 +44,5 @@ set session aria_sort_buffer_size=cast(-1 as unsigned int); select @@session.aria_sort_buffer_size; diff --git a/mysql-test/suite/sys_vars/r/innodb_ft_result_cache_limit,32bit.rdiff b/mysql-test/suite/sys_vars/r/innodb_ft_result_cache_limit,32bit.rdiff index cd9a004a686..79e15420af3 100644 --- a/mysql-test/suite/sys_vars/r/innodb_ft_result_cache_limit,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/innodb_ft_result_cache_limit,32bit.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/sys_vars/r/innodb_ft_result_cache_limit.result 2019-05-07 15:09:57.220599318 +0530 -+++ mysql-test/suite/sys_vars/r/innodb_ft_result_cache_limit.reject 2019-05-07 15:10:20.012718538 +0530 +--- mysql-test/suite/sys_vars/r/innodb_ft_result_cache_limit.result ++++ mysql-test/suite/sys_vars/r/innodb_ft_result_cache_limit.reject @@ -1,5 +1,7 @@ set global innodb_ft_result_cache_limit=5000000000; +Warnings: diff --git a/mysql-test/suite/sys_vars/r/sysvars_aria,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_aria,32bit.rdiff index f0cbbd874ee..3ebce38219c 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_aria,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_aria,32bit.rdiff @@ -1,5 +1,5 @@ ---- suite/sys_vars/r/sysvars_aria.result 2021-02-02 02:58:55.686921205 +0200 -+++ suite/sys_vars/r/sysvars_aria,32bit.reject 2021-02-02 10:55:53.876791633 +0200 +--- suite/sys_vars/r/sysvars_aria.result ++++ suite/sys_vars/r/sysvars_aria,32bit.reject @@ -5,7 +5,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 8192 diff --git a/mysql-test/suite/sys_vars/r/sysvars_debug,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_debug,32bit.rdiff index 8adb294db00..cb8338d4e9b 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_debug,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_debug,32bit.rdiff @@ -1,5 +1,5 @@ ---- r\sysvars_debug.result 2017-08-08 10:52:39.036804900 +0300 -+++ r\sysvars_debug,32bit.reject 2017-09-10 08:06:38.447122100 +0300 +--- r\sysvars_debug.result ++++ r\sysvars_debug,32bit.reject @@ -21,7 +21,7 @@ GLOBAL_VALUE_ORIGIN CONFIG DEFAULT_VALUE 0 diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_wsrep,32bit.rdiff index 016bd016f29..73b788057cb 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_wsrep,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep,32bit.rdiff @@ -1,5 +1,5 @@ ---- suite/sys_vars/r/sysvars_wsrep.result 2014-10-10 13:33:55.000000000 +0300 -+++ suite/sys_vars/r/sysvars_wsrep,32bit.reject 2014-10-10 19:38:09.000000000 +0300 +--- suite/sys_vars/r/sysvars_wsrep.result ++++ suite/sys_vars/r/sysvars_wsrep,32bit.reject @@ -245,7 +245,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 131072 diff --git a/mysql-test/suite/versioning/r/select,trx_id.rdiff b/mysql-test/suite/versioning/r/select,trx_id.rdiff index 8906007a348..1b879493475 100644 --- a/mysql-test/suite/versioning/r/select,trx_id.rdiff +++ b/mysql-test/suite/versioning/r/select,trx_id.rdiff @@ -1,5 +1,5 @@ ---- select.result 2018-06-29 18:09:17.962447067 +0200 -+++ select.reject 2018-06-29 18:10:04.618808616 +0200 +--- select.result ++++ select.reject @@ -17,6 +17,8 @@ (8, 108), (9, 109); diff --git a/mysql-test/suite/versioning/r/select2,trx_id.rdiff b/mysql-test/suite/versioning/r/select2,trx_id.rdiff index bdc20d1dc4f..085a2a12653 100644 --- a/mysql-test/suite/versioning/r/select2,trx_id.rdiff +++ b/mysql-test/suite/versioning/r/select2,trx_id.rdiff @@ -1,5 +1,5 @@ ---- select2.result 2018-06-29 17:51:17.142172085 +0200 -+++ select2,trx_id.reject 2018-06-29 18:03:49.034273090 +0200 +--- select2.result ++++ select2,trx_id.reject @@ -26,6 +26,8 @@ select sys_start from t1 where x = 3 and y = 33 into @t1; Warnings: diff --git a/mysql-test/suite/versioning/r/update,trx_id.rdiff b/mysql-test/suite/versioning/r/update,trx_id.rdiff index 7ce75714235..5f0e77bf54e 100644 --- a/mysql-test/suite/versioning/r/update,trx_id.rdiff +++ b/mysql-test/suite/versioning/r/update,trx_id.rdiff @@ -1,5 +1,5 @@ ---- update.result 2018-12-19 13:55:35.873917389 +0300 -+++ update,trx_id.reject 2018-12-19 13:55:35.533917399 +0300 +--- update.result ++++ update,trx_id.reject @@ -81,12 +81,10 @@ commit; select x, y, sys_trx_end = MAXVAL as current from t1 for system_time all order by sys_trx_end, x, y; diff --git a/mysql-test/suite/wsrep/r/wsrep-recover-v25,binlogon.rdiff b/mysql-test/suite/wsrep/r/wsrep-recover-v25,binlogon.rdiff index 596abf9c681..5fc091c7752 100644 --- a/mysql-test/suite/wsrep/r/wsrep-recover-v25,binlogon.rdiff +++ b/mysql-test/suite/wsrep/r/wsrep-recover-v25,binlogon.rdiff @@ -1,5 +1,5 @@ ---- r/wsrep-recover-v25.result 2019-02-28 09:20:56.153775856 +0200 -+++ r/wsrep-recover-v25.reject 2019-02-28 09:22:16.578113115 +0200 +--- r/wsrep-recover-v25.result ++++ r/wsrep-recover-v25.reject @@ -12,4 +12,16 @@ SELECT VARIABLE_VALUE `expect 6` FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'; expect 6 From 1f4a9f086ae5ff66a10f84e1fda5bcc38b347883 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 12 Dec 2022 20:06:32 +0200 Subject: [PATCH 083/123] Removed " INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;", - "'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT INTO ;' is deprecated and will be removed in a future release. Please use 'SELECT