[MDEV-6017] Add support for Indexes on Expressions Created: 2014-04-03 Updated: 2023-12-22 |
|
| Status: | In Review |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Fix Version/s: | 11.5 |
| Type: | New Feature | Priority: | Major |
| Reporter: | Fabio Alessandro Locati | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 20 |
| Labels: | gsoc19, index, optimizer-feature | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||
| Description |
|
An index on expression means something like
in this case the optimizer should be able to use an index. This task naturally splits in two steps:
original task description is visible in the history |
| Comments |
| Comment by VAROQUI Stephane [ 2014-04-04 ] |
|
What about using the virtual columns feature ? https://mariadb.com/kb/en/virtual-columns/ |
| Comment by roberto spadim [ 2015-01-29 ] |
|
this allow implement of virtual columns with index |
| Comment by Daniel Black [ 2017-05-30 ] |
|
fale as mentioned the virtual columns combined with indexes on these provide the equivalent functionality to the Postgres implementation even if slightly different. Queries need to be rewritten to reference the virtual column to use the index on that column. There are no triggers involved. Is this an acceptable implement of your feature request? |
| Comment by VAROQUI Stephane [ 2017-05-30 ] |
|
May be a limited implementation of simple case of parser rewriting constant to virtual constant can be quick win like: rewrite to for the case of virtual column v1 defined as SUBSTRING_INDEX(c1, '.', 2); SELECT id FROM t WHERE c1=="www.mariadb.com" AND v1= SUBSTRING_INDEX('www.mariadb.org', '.', 2); |
| Comment by Sergei Golubchik [ 2017-05-30 ] |
|
danblack, using virtual columns is an acceptable workaround in many cases. This feature is mainly about using virtual columns automatically, when it's expression is used in a query, not only when a virtual column is used by name. Combining it with |
| Comment by Pavel Cibulka [ 2018-08-07 ] |
|
Can you also include Partial / Filtered Indexes MDEV-15140. MariaDB / MySQL is only major DB not supporting this feature. |
| Comment by Sergei Golubchik [ 2018-08-07 ] |
|
Yes, of course. But it's MDEV-15140, a separate feature |
| Comment by Nikita Malyavin [ 2019-08-17 ] |
|
According to pgsql docs: https://www.postgresql.org/docs/11/sql-createindex.html |
| Comment by Federico Razzoli [ 2023-02-13 ] |
|
Some questions:
|
| Comment by Sergei Golubchik [ 2023-02-27 ] |
|
All answers are preliminary, but that's what I think will be:
|