mirror of
https://github.com/MariaDB/server.git
synced 2025-02-21 21:03:09 +01: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.
29 lines
1 KiB
C
29 lines
1 KiB
C
/*
|
|
Copyright (c) 2009, 2021, MariaDB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
|
|
|
|
/*
|
|
Interface to indexed virtual column substitution module
|
|
*/
|
|
|
|
/* Do substitution in one join */
|
|
bool substitute_indexed_vcols_for_join(JOIN *join);
|
|
|
|
/*
|
|
Do substitution for one table and condition. This is for single-table
|
|
UPDATE/DELETE.
|
|
*/
|
|
bool substitute_indexed_vcols_for_table(TABLE *table, Item *item);
|
|
|