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

Optimizer support for Multi-Valued indexes over JSON data

    XMLWordPrintable

Details

    Description

      After MDEV-25848 implements multi-value indexes, the optimizer could use those to perform efficient searches for JSON data.

      This will achieve either or both of the goals:

      Goal 1: index do searches like in MySQL:

      create index idx1 on  t1 ((cast(a->'$.arr' as unsigned array)));
      explain select * from t101 where 4 member of (a->'$.arr');
      

      Without MDEV-13594 (support for '->' syntax), an alternative would be using JSON_EXTRACT:

      create index idx1 on  t1 ((cast (json_extract(a, '$.arr') as unsigned array)));
      

      but ultimately it depends on what MDEV-25848 implements.

      Note: in MySQL, there is no UNSIGNED ARRAY datatype. The CAST ... AS UNSIGNED ARRAY syntax is only accepted in index definitions. Attempt to use it somewhere else gives this error:

      ERROR 1235 (42000): This version of MySQL doesn't yet support 'Use of CAST( .. AS .. 
      ARRAY) outside of functional index in CREATE(non-SELECT)/ALTER TABLE or in 
      general expressions'
      

      Goal 2: Support index lookups for generic JSON predicates like

      JSON_VALUE(js_column, '$.attribute_name') = 'value'
      

      WHERE column->json_attr = 'foo';

      The scope of this task.

      MDEV-25848 be implemented before this task. It will add Multi-Value Index support for New Fulltext and vector indexes.
      It will NOT do anything for JSON.
      The scope of this task is everything else needed to get the above JSON use cases running.

      • Adjust CREATE TABLE to support new index definitions.
      • Produce index entries for a table row.
      • Detect relevant expressions in the WHERE clause and construct Access Methods for them
      • ...

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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