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

indexes on virtual (not materialized) columns

Details

    • 10.2.0-1, 10.2.0-2, 10.2.0-4, 10.2.0-6, 10.2.0-7, 10.2.0-8, 10.2.0-9, 10.2.0-10, 10.2.0-11, 10.2.2-4, 10.2.3-2, 10.0.28, 10.2.4-1, 10.2.4-4

    Description

      Currently to have a index on a virtual column, one has to materialized it. To support indexes on fully virtual columns, a storage engine must call back into the server to calculate the value of the virtual column.

      Attachments

        Issue Links

          Activity

            richa Richa Sehgal added a comment -

            Hi,

            I am Richa Sehgal currently pursuing Master’s at University of Illinois Urbana Champaign, USA. I did my undergraduate from Indian Institute of Technology Delhi (IIT-Delhi). I would like to take this up as my GSoC project.

            Materialization gives us two things:
            1. A name to the column which we can use in queries
            2. A formal "regular" column which is stored and indexed in the regular fashion - Disadvantage: Extra memory requirements for the materialized column.

            My initial thoughts on this project are the following:
            We do need the name of the column which can be used to query. So maybe we can expose a command such as:

            create virtual_index <name> on <column_name> <expression>

            What this would do would run a regular query which evaluates expressions (like in WHERE clause) and the feed the result into the indexer. This index can then be stored in the regular fashion.
            Am I approaching this in the right direction? Can you please point me to the next steps?
            Thanks
            Richa

            richa Richa Sehgal added a comment - Hi, I am Richa Sehgal currently pursuing Master’s at University of Illinois Urbana Champaign, USA. I did my undergraduate from Indian Institute of Technology Delhi (IIT-Delhi). I would like to take this up as my GSoC project. Materialization gives us two things: 1. A name to the column which we can use in queries 2. A formal "regular" column which is stored and indexed in the regular fashion - Disadvantage: Extra memory requirements for the materialized column. My initial thoughts on this project are the following: We do need the name of the column which can be used to query. So maybe we can expose a command such as: create virtual_index <name> on <column_name> <expression> What this would do would run a regular query which evaluates expressions (like in WHERE clause) and the feed the result into the indexer. This index can then be stored in the regular fashion. Am I approaching this in the right direction? Can you please point me to the next steps? Thanks Richa
            serg Sergei Golubchik added a comment - https://lists.launchpad.net/maria-developers/msg08303.html
            axel Axel Schwenke added a comment - - edited

            From a user right now on #maria: an index on a virtual column should be used not only when the virtual column is referenced by name, but also when the expression defining that column is used. That would mean that an index on a virtual column is equivalent to a functional index (MDEV-6017) on the expression defining that column.

            Example:

            CREATE TABLE t1 (c1 INT, c2 INT, c3 INT AS (c1+c2) VIRTUAL, INDEX (c3));
            SELECT * FROM t1 WHERE c3=42;
            SELECT * FROM t1 WHERE (c1+c2)=42;

            The expectation is that both queries use the index on the virtual column. The first because the virtual column is referenced by name, the second because the virtual column is referenced by the defining expression. The index on c3 would behave like a functional index on (c1+c2)

            axel Axel Schwenke added a comment - - edited From a user right now on #maria: an index on a virtual column should be used not only when the virtual column is referenced by name, but also when the expression defining that column is used. That would mean that an index on a virtual column is equivalent to a functional index ( MDEV-6017 ) on the expression defining that column. Example: CREATE TABLE t1 (c1 INT, c2 INT, c3 INT AS (c1+c2) VIRTUAL, INDEX (c3)); SELECT * FROM t1 WHERE c3=42; SELECT * FROM t1 WHERE (c1+c2)=42; The expectation is that both queries use the index on the virtual column. The first because the virtual column is referenced by name, the second because the virtual column is referenced by the defining expression. The index on c3 would behave like a functional index on (c1+c2)

            People

              serg Sergei Golubchik
              serg Sergei Golubchik
              Votes:
              7 Vote for this issue
              Watchers:
              13 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.