Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
11.8
-
None
-
None
Description
create table t20 ( |
col1 date , |
vcol date as (col1), |
index i1(col1), |
index i2(vcol) |
);
|
 |
insert into t20 (col1) select |
date_add(now(), interval seq day) |
from seq_1_to_10000; |
In 10.11, index i1 is used:
MariaDB [test]> explain select * from t20 where col1 ='2026-06-01';
|
+------+-------------+-------+------+---------------+------+---------+-------+------+-------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+------+---------------+------+---------+-------+------+-------+
|
| 1 | SIMPLE | t20 | ref | i1 | i1 | 4 | const | 1 | |
|
+------+-------------+-------+------+---------------+------+---------+-------+------+-------+
|
in 12.2, col1=... is rewritten into vcol=....
This enables use of index i2 but disables use of index i1:
MariaDB [test]> explain select * from t20 where col1 ='2026-06-01';
|
+------+-------------+-------+------+---------------+------+---------+-------+------+-------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+------+---------------+------+---------+-------+------+-------+
|
| 1 | SIMPLE | t20 | ref | i2 | i2 | 4 | const | 1 | |
|
+------+-------------+-------+------+---------------+------+---------+-------+------+-------+
|
TODO: does this apply to meaningful virtual column definitions (not "vcol as (col1)"?)