@@ -3869,6 +3869,92 @@ l_orderkey
38693869291
38703870DROP TABLE lineitem;
38713871#
3872+ # MDEV-39251: Add an option to count records_in_range calls and skip them for point lookups
3873+ #
3874+ create table t1 (
3875+ a int,
3876+ b int,
3877+ index(a),
3878+ index(b)
3879+ );
3880+ insert into t1 select seq, floor(seq/10) from seq_1_to_100;
3881+ #
3882+ # The default behavior is to make records_in_range calls:
3883+ #
3884+ flush status;
3885+ explain select * from t1 where a in (1,2);
3886+ id select_type table type possible_keys key key_len ref rows Extra
3887+ 1 SIMPLE t1 range a a 5 NULL 2 Using index condition; Rowid-ordered scan
3888+ show status like 'Handler_records_in_range';
3889+ Variable_name Value
3890+ Handler_records_in_range 2
3891+ flush status;
3892+ explain select * from t1 where a=1;
3893+ id select_type table type possible_keys key key_len ref rows Extra
3894+ 1 SIMPLE t1 ref a a 5 const 1
3895+ show status like 'Handler_records_in_range';
3896+ Variable_name Value
3897+ Handler_records_in_range 1
3898+ flush status;
3899+ explain select * from t1 where b=1;
3900+ id select_type table type possible_keys key key_len ref rows Extra
3901+ 1 SIMPLE t1 ref b b 5 const 5
3902+ show status like 'Handler_records_in_range';
3903+ Variable_name Value
3904+ Handler_records_in_range 1
3905+ #
3906+ # Now, INDEX(a) should be handled without records_in_range:
3907+ #
3908+ set @tmp=@@optimizer_min_point_range_size_to_use_stats;
3909+ set optimizer_min_point_range_size_to_use_stats=5;
3910+ flush status;
3911+ explain select * from t1 where a in (1,2);
3912+ id select_type table type possible_keys key key_len ref rows Extra
3913+ 1 SIMPLE t1 range a a 5 NULL 2 Using index condition; Rowid-ordered scan
3914+ show status like 'Handler_records_in_range';
3915+ Variable_name Value
3916+ Handler_records_in_range 0
3917+ flush status;
3918+ explain select * from t1 where a=1;
3919+ id select_type table type possible_keys key key_len ref rows Extra
3920+ 1 SIMPLE t1 ref a a 5 const 1
3921+ show status like 'Handler_records_in_range';
3922+ Variable_name Value
3923+ Handler_records_in_range 0
3924+ flush status;
3925+ explain select * from t1 where b=1;
3926+ id select_type table type possible_keys key key_len ref rows Extra
3927+ 1 SIMPLE t1 ref b b 5 const 5
3928+ show status like 'Handler_records_in_range';
3929+ Variable_name Value
3930+ Handler_records_in_range 1
3931+ #
3932+ # Now, both INDEX(a) and INDEX(a) should be handled without records_in_range:
3933+ #
3934+ set optimizer_min_point_range_size_to_use_stats=30;
3935+ flush status;
3936+ explain select * from t1 where a in (1,2);
3937+ id select_type table type possible_keys key key_len ref rows Extra
3938+ 1 SIMPLE t1 range a a 5 NULL 2 Using index condition; Rowid-ordered scan
3939+ show status like 'Handler_records_in_range';
3940+ Variable_name Value
3941+ Handler_records_in_range 0
3942+ flush status;
3943+ explain select * from t1 where a=1;
3944+ id select_type table type possible_keys key key_len ref rows Extra
3945+ 1 SIMPLE t1 ref a a 5 const 1
3946+ show status like 'Handler_records_in_range';
3947+ Variable_name Value
3948+ Handler_records_in_range 0
3949+ flush status;
3950+ explain select * from t1 where b=1;
3951+ id select_type table type possible_keys key key_len ref rows Extra
3952+ 1 SIMPLE t1 ref b b 5 const 9
3953+ show status like 'Handler_records_in_range';
3954+ Variable_name Value
3955+ Handler_records_in_range 0
3956+ set optimizer_min_point_range_size_to_use_stats=@tmp;
3957+ #
38723958# End of 11.0 tests
38733959#
38743960set optimizer_switch=@mrr_icp_extra_tmp;
0 commit comments