| Server IP : 88.99.149.37 / Your IP : 216.73.216.141 Web Server : nginx/1.31.2 System : Linux server-88-99-149-37 6.12.0-124.56.5.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Fri May 15 06:12:08 EDT 2026 x86_64 User : muralimurth ( 1015) PHP Version : 8.4.23 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/local/mysql/mysql-test/main/ |
Upload File : |
--source include/have_sequence.inc --source include/not_embedded.inc --source include/have_innodb.inc # Testcase for MDEV-33306 takes ~6 minutes with valgrind: --source include/not_valgrind.inc # # Show the costs for rowid filter # 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; --disable_ps_protocol set optimizer_trace="enabled=on"; set optimizer_switch='rowid_filter=on'; set statement optimizer_adjust_secondary_key_costs=0 for explain select * from t1 where nm like '500%' AND fl2 = 0; set @trace=(select trace from information_schema.optimizer_trace); select json_detailed(json_extract(@trace, '$**.considered_access_paths')); --echo --echo The following trace should have a different rowid_filter_key cost --echo set statement optimizer_adjust_secondary_key_costs=2 for explain select * from t1 where nm like '500%' AND fl2 = 0; set @trace=(select trace from information_schema.optimizer_trace); select json_detailed(json_extract(@trace, '$**.considered_access_paths')); --enable_ps_protocol drop table t1, name, flag2; select @@optimizer_adjust_secondary_key_costs; set @@optimizer_adjust_secondary_key_costs=7; select @@optimizer_adjust_secondary_key_costs; set @@optimizer_adjust_secondary_key_costs=default; --echo # --echo # MDEV-33306 Optimizer choosing incorrect index in 10.6, 10.5 but not in 10.4 --echo # create table t1 (a int primary key, b int, c int, d int, key(b),key(c)) engine=innodb; insert into t1 select seq, mod(seq,10), mod(seq,2), seq from seq_1_to_50000; --replace_column 9 # explain select b, sum(d) from t1 where c=0 group by b; select b, sum(d) from t1 where c=0 group by b; set @@optimizer_adjust_secondary_key_costs="disable_forced_index_in_group_by"; --replace_column 9 # explain select b, sum(d) from t1 where c=0 group by b; select b, sum(d) from t1 where c=0 group by b; drop table t1; --echo # --echo # MDEV-34664: fix_innodb_cardinality --echo # set @save_userstat=@@global.userstat; set @save_ispsp=@@global.innodb_stats_persistent_sample_pages; set @@global.innodb_stats_persistent_sample_pages=20; set @@global.userstat=on; set use_stat_tables=PREFERABLY_FOR_QUERIES; create or replace table t1 (a int primary key, b int, c int, d int, key(b,c,d)) engine=innodb; insert into t1 select seq,seq/100,seq/60,seq/10 from seq_1_to_1000; create or replace table t2 (a int); insert into t2 values (1),(2),(3); analyze table t1; select count(distinct b),count(distinct b,c), count(distinct b,c,d) from t1; show index from t1; explain select * from t1,t2 where t1.b=t2.a; set @@optimizer_adjust_secondary_key_costs=8; explain select * from t1,t2 where t1.b=t2.a; show index from t1; # Flush tables or show index is needed to refresh the data in table share flush tables; explain select * from t1,t2 where t1.b=t2.a; show index from t1; # Check that the option does not affect other usage connect (user2, localhost, root,,); show index from t1; connection default; disconnect user2; drop table t1,t2; set global userstat=@save_userstat; set global innodb_stats_persistent_sample_pages=@save_ispsp; --echo # --echo # MDEV-35958: Cost estimates for materialized derived tables are poor --echo # set optimizer_trace=1; create table t1 ( a int ); insert into t1 select seq from seq_1_to_10000; explain select * from t1 as t1_base, (select a from t1 limit 10000) as TBL; set @trace=(select trace from information_schema.optimizer_trace); --echo # BEFORE, without fix_derived_table_read_cost: derived2 has cost=rows=10000 select json_detailed( json_extract(json_extract(@trace, '$**.rows_estimation'), '$[1]') ) as Trace; set optimizer_adjust_secondary_key_costs='fix_derived_table_read_cost'; explain select * from t1 as t1_base, (select a from t1 limit 10000) as TBL; set @trace=(select trace from information_schema.optimizer_trace); --echo # AFTER, with fix_derived_table_read_cost: derived2 has more realistic cost select json_detailed( json_extract(json_extract(@trace, '$**.rows_estimation'), '$[1]') ) as Trace; drop table t1; set @@optimizer_adjust_secondary_key_costs=default;