mariadb/mysql-test/suite/sys_vars/r/new_mode.result
Sergei Petrunia 4cff562f3f MDEV-38164: Fix the estimates reported by TABLE::key_storage_length()
They were based on the maximum possible key tuple length, which can be
much larger than the real data size.

The return value is used by handler::keyread_time(), which is used
to estimate the cost of range access.
This could cause range access not to be picked, even if it uses
the clustered PK and reads about 8% of the table.

The fix is to add KEY::stat_storage_length (next to KEY::rec_per_key) and
have the storage engine fill it in handler::info(HA_STATUS_CONST).

Currently, only InnoDB fills this based on its internal statistics:
index->stat_index_size and ib_table->stat_n_rows.

Also changed:
- In handler::calculate_costs(), use ha_keyread_clustered_time() when
  computing clustered PK read cost, not ha_keyread_time().

The fix is OFF by default and enabled by setting FIX_INDEX_LOOKUP_COST flag
in @@new_mode.
2025-12-02 10:54:31 +02:00

60 lines
2 KiB
Text

SET @global_start_value = @@global.new_mode;
SELECT @global_start_value;
@global_start_value
SET @session_start_value = @@session.new_mode;
SELECT @session_start_value;
@session_start_value
SET @@global.new_mode = DEFAULT;
SELECT @@global.new_mode;
@@global.new_mode
SELECT @@session.new_mode;
@@session.new_mode
SET @@session.new_mode = "TEST_WARNING1";
Warnings:
Warning 4200 The setting 'new_mode=TEST_WARNING1' is ignored. It only exists for compatibility with old installations and will be removed in a future release
SET @@session.new_mode = "TEST_WARNING1,TEST_WARNING2";
Warnings:
Warning 4200 The setting 'new_mode=TEST_WARNING1' is ignored. It only exists for compatibility with old installations and will be removed in a future release
Warning 4200 The setting 'new_mode=TEST_WARNING2' is ignored. It only exists for compatibility with old installations and will be removed in a future release
SET @@session.new_mode = "TEST_WARNING1,TEST_WARNING2,TEST_WARNING3";
ERROR 42000: Variable 'new_mode' can't be set to the value of 'TEST_WARNING3'
SET @@session.new_mode = "ALL";
select @@session.new_mode;
@@session.new_mode
FIX_INDEX_STATS_FOR_ALL_NULLS,FIX_INDEX_LOOKUP_COST
SET @@global.new_mode = NULL;
ERROR 42000: Variable 'new_mode' can't be set to the value of 'NULL'
SET @@global.new_mode = '';
SELECT @@global.new_mode;
@@global.new_mode
SET @@global.new_mode = ' ';
SELECT @@global.new_mode;
@@global.new_mode
SET @@session.new_mode = NULL;
ERROR 42000: Variable 'new_mode' can't be set to the value of 'NULL'
SET @@session.new_mode = '';
SELECT @@session.new_mode;
@@session.new_mode
SET @@session.new_mode = ' ';
SELECT @@session.new_mode;
@@session.new_mode
SET @@global.new_mode = OFF;
ERROR 42000: Variable 'new_mode' can't be set to the value of 'OFF'
SET @@session.new_mode = OFF;
ERROR 42000: Variable 'new_mode' can't be set to the value of 'OFF'
SET @@global.new_mode = @global_start_value;
SELECT @@global.new_mode;
@@global.new_mode
SET @@session.new_mode = @session_start_value;
SELECT @@session.new_mode;
@@session.new_mode