|
Ok, it's a genuine problem that affects pruning
The SEL_ARG graph has this shape:
part=0
|
|
SEL_ARG1 ---\
|
| \
|
SEL_ARG2 +-->SEL_ARG4--...
|
| /
|
SEL_ARG3 ---/
|
Both SEL_ARG1 and SEL_ARG2 have pointers to SEL_ARG4.
prune_sel_arg_graph(SEL_ARG1) calls
prune_sel_arg_graph(SEL_ARG4), and the last call
updates the weight:
sel_arg->weight -= (old_weight - cur->next_key_part->weight);
|
The weight of the whole tree is changed accordingly.
But the problem is that SEL_ARG4 is present in the graph TWICE, so when
we're cutting off SEL_ARG4->next_key_part, that has an effect in multiple places.
An easy solution to this is to re-compute the weight from scratch after the cut-off.
But we need to make sure this doesn't cause a slowdown like in MDEV-25020...
|
|
Similar problem, but with AND:
--source include/have_innodb.inc
|
|
CREATE TABLE t1 ( id int, b1 int, i1 int, d1 TIMESTAMP, PRIMARY KEY (id,i1,b1,d1), KEY (id,b1,d1)) engine=innodb;
|
insert ignore into t1 values (1,2,3,'1970-01-01');
|
|
explain select * from t1
|
where
|
d1 between 'w' and 'th'
|
and b1 not in (9, 255, 2)
|
and (id not in (-87, 1) and b1 not in (255, 1))
|
and i1 in (213, 1)
|
and id in (1, 255, 6);
|
|
10.5 cad33ded19e45a0187754
|
2023-01-11 16:59:40 4 [ERROR] SEL_ARG weight mismatch: computed 20 have 18
|
|
mariadbd: /10.5/src/sql/opt_range.cc:10088: uint SEL_ARG::verify_weight(): Assertion `computed_weight == weight' failed.
|
230111 16:49:40 [ERROR] mysqld got signal 6 ;
|
|
Server version: 10.5.19-MariaDB-debug-log
|
|
??:0(__assert_fail)[0x7f24c1f7cfd6]
|
sql/opt_range.cc:10090(SEL_ARG::verify_weight())[0x55bf2e0b561d]
|
sql/opt_range.cc:10072(SEL_ARG::verify_weight())[0x55bf2e0b5459]
|
sql/opt_range.cc:10131(key_and_with_limit(RANGE_OPT_PARAM*, unsigned int, SEL_ARG*, SEL_ARG*, unsigned int))[0x55bf2e0b573c]
|
sql/opt_range.cc:9209(and_range_trees(RANGE_OPT_PARAM*, SEL_TREE*, SEL_TREE*, SEL_TREE*))[0x55bf2e0b0305]
|
sql/opt_range.cc:9321(tree_and(RANGE_OPT_PARAM*, SEL_TREE*, SEL_TREE*))[0x55bf2e0b0c65]
|
sql/opt_range.cc:8341(Item_cond_and::get_mm_tree(RANGE_OPT_PARAM*, Item**))[0x55bf2e0a77b1]
|
sql/opt_range.cc:2885(SQL_SELECT::test_quick_select(THD*, Bitmap<64u>, unsigned long long, unsigned long long, bool, bool, bool, bool))[0x55bf2e0837a2]
|
sql/sql_select.cc:4870(get_quick_record_count(THD*, SQL_SELECT*, TABLE*, Bitmap<64u> const*, unsigned long long))[0x55bf2d542e8b]
|
sql/sql_select.cc:5597(make_join_statistics(JOIN*, List<TABLE_LIST>&, st_dynamic_array*))[0x55bf2d549d59]
|
sql/sql_select.cc:2337(JOIN::optimize_inner())[0x55bf2d5283cd]
|
sql/sql_select.cc:1695(JOIN::optimize())[0x55bf2d5218a7]
|
sql/sql_select.cc:4812(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55bf2d542590]
|
sql/sql_select.cc:27729(mysql_explain_union(THD*, st_select_lex_unit*, select_result*))[0x55bf2d5ec847]
|
sql/sql_parse.cc:6256(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55bf2d47a58f]
|
sql/sql_parse.cc:4008(mysql_execute_command(THD*))[0x55bf2d469de9]
|
sql/sql_parse.cc:8089(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55bf2d4860b3]
|
sql/sql_parse.cc:1894(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55bf2d45bff6]
|
sql/sql_parse.cc:1375(do_command(THD*))[0x55bf2d458974]
|
sql/sql_connect.cc:1416(do_handle_one_connection(CONNECT*, bool))[0x55bf2d8aad2b]
|
sql/sql_connect.cc:1320(handle_one_connection)[0x55bf2d8aa68f]
|
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x55bf2e52350a]
|
nptl/pthread_create.c:478(start_thread)[0x7fd430d90609]
|
??:0(clone)[0x7fd430961133]
|
|
Query (0x62b0000852a8): explain select * from t1
|
where
|
d1 between 'w' and 'th'
|
and b1 not in (9, 255, 2)
|
and (id not in (-87, 1) and b1 not in (255, 1))
|
and i1 in (213, 1)
|
and id in (1, 255, 6)
|
|
|