Details
-
New Feature
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
Description
This MDEV covers basic optimizer support for virtual columns added in 11.8.
If a user declares a virtual column and an index on it
ALTER TABLE t1 |
ADD COLUMN vcol INT AS (col1+1), |
ADD INDEX idx1(vcol); |
and then a query uses the exact same expression:
SELECT * FROM t1 WHERE col1+1 <= 100 |
Then the optimizer will rewrite the above into
... WHERE vcol <= 100 |
which enables the rest of the optimizer to construct query plans that use index idx1.
The rewrite is performed in WHERE/ON clauses (and only there).
The rewrite targets indexed virtual columns.
The rewrite targets a subset of conditions usable by the range optimizer:
vcol_expr $CMP const1 where $CMP is = or [less|greater][or equal].
|
vcol_expr BETWEEN const1 AND const2
|
vcol_expr IN (const-list)
|
vcol_expr IS [NOT] NULL
|
Attachments
Issue Links
- blocks
-
MXS-5346 Properly support [create|drop|list]Indexes
-
- Closed
-
- causes
-
MDEV-35833 Assertion `marked_for_read()' failed after DELETE/UPDATE from table with virtual columns
-
- Closed
-
-
MDEV-35913 Assertion `m_comparator.cmp_type() != ROW_RESULT' failed in bool Item_func_in::compatible_types_scalar_bisection_possible()
-
- Open
-
- is part of
-
MDEV-6017 Add support for Indexes on Expressions
-
- Stalled
-
- relates to
-
MDEV-35615 Query optimizer support for functional indexes: next steps
-
- Open
-
-
MDEV-35496 JSON_UNQUOTE produces utf8mb3 output while JSON can be utf8mb4
-
- In Progress
-
-
MDEV-36299 Issues with collations when using indexed JSON attribute search
-
- Open
-
Activity
Field | Original Value | New Value |
---|---|---|
Component/s | Optimizer [ 10200 ] |
Labels | optimizer-feature |
Fix Version/s | 11.8 [ 29921 ] |
Assignee | Sergei Petrunia [ psergey ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | In Testing [ 10301 ] |
Assignee | Sergei Petrunia [ psergey ] | Lena Startseva [ JIRAUSER50478 ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
Link | This issue relates to MDEV-35615 [ MDEV-35615 ] |
Link | This issue relates to MDEV-35496 [ MDEV-35496 ] |
Link | This issue is part of TODO-5071 [ TODO-5071 ] |
Assignee | Lena Startseva [ JIRAUSER50478 ] | Alice Sherepa [ alice ] |
Labels | optimizer-feature | optimizer-feature virtual_columns |
Link |
This issue causes |
Assignee | Alice Sherepa [ alice ] | Sergei Petrunia [ psergey ] |
Status | In Testing [ 10301 ] | Stalled [ 10000 ] |
Fix Version/s | 11.8.1 [ 29961 ] | |
Fix Version/s | 11.8 [ 29921 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Labels | optimizer-feature virtual_columns | Preview_11.8 optimizer-feature virtual_columns |
Link | This issue causes MDEV-35913 [ MDEV-35913 ] |
Link | This issue relates to MDEV-36299 [ MDEV-36299 ] |
The commit is in bb-11.8-MDEV-6017-variant3 branch:
commit 75773e1d28877d7f3c4599b554921c472adcc6bb (HEAD -> bb-11.8-MDEV-6017-variant3, origin/bb-11.8-MDEV-6017-variant3)
Author: Sergei Petrunia <sergey@mariadb.com>
Date: Tue Nov 26 14:50:41 2024 +0200
MDEV-35616: Add basic optimizer support for virtual column
(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.