mirror of
https://github.com/MariaDB/server.git
synced 2025-10-24 00:27:49 +02:00
(Review input addressed)
After this patch, the optimizer can handle virtual column expressions
in WHERE/ON clauses. If the table has an indexed virtual column:
ALTER TABLE t1
ADD COLUMN vcol INT AS (col1+1),
ADD INDEX idx1(vcol);
and the query uses the exact virtual column expression:
SELECT * FROM t1 WHERE col1+1 <= 100
then the optimizer will be able use index idx1 for it.
This is achieved by walking the WHERE/ON clauses and replacing instances
of virtual column expression (like "col1+1" above) with virtual column's
Item_field (like "vcol"). The latter can be processed by the optimizer.
Replacement is considered (and done) only in items that are potentially
usable to the range optimizer.
15 lines
416 B
Text
15 lines
416 B
Text
|
|
--source include/have_sequence.inc
|
|
--source include/have_debug.inc
|
|
--source include/not_embedded.inc
|
|
|
|
create table t1 (a int, vcol1 int as (a+1), index(vcol1));
|
|
insert into t1 (a) select seq from seq_1_to_100;
|
|
|
|
SET SESSION debug_dbug="+d,vcol_subst_simulate_oom";
|
|
--error ER_OUT_OF_RESOURCES
|
|
explain select * from t1 where a+1=2;
|
|
SET @saved_dbug = @@SESSION.debug_dbug;
|
|
|
|
SET debug_dbug= @saved_dbug;
|
|
drop table t1;
|