Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35616

Add basic optimizer support for virtual columns

Details

    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

          Activity

            People

              psergei Sergei Petrunia
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.