Details
-
New Feature
-
Status: Open (View Workflow)
-
Critical
-
Resolution: Unresolved
-
Q3/2026 Server Development
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: Do index 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))); |
MySQL does support this also. Ultimately it depends on what MDEV-25848 implements.
In MySQL, UNSIGNED ARRAY is not a real 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'
|
Sargable conditions in MySQL
Those are:
- MEMBER OF
- JSON_CONTAINS
- JSON_OVERLAPS
MEMBER OF syntax is MySQL-specific
SQL Standard does define MEMBER OF but it's for MULTISET datatypes which are not related to JSON documents.
MariaDB's Jira task for implementing MEMBER OF is MDEV-38591 (a GSoC task this year?).
Goal 2: Support indexed searches for JSON members.
The idea is to support searches for conditions like
WHERE JSON_VALUE(js_column, '$.attribute_name') = 'value' |
where we do not require a prior index created for attribute_name.
When/if arrow -> syntax is allowed for JSON, this will also handle
|
WHERE column->'$.json_attr' = 'foo'; |
Note that the -> operator MDEV-13594 has been pushed to 13.1.
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
- is blocked by
-
MDEV-25848 Support for Multi-Valued Indexes
-
- In Progress
-
-
MDEV-40168 Indexes over JSON data based on Fulltext index
-
- Open
-
- relates to
-
MDEV-13594 Support for JSON operators column->path and column->>path
-
- Closed
-
-
MDEV-35389 Native Multi-Value Indexes for JSON
-
- Open
-
-
MDEV-37288 JSON Comparator: does MariaDB need one?
-
- Closed
-
-
MDEV-40113 Optimizer support for Multi-Valued indexes: support new Full Text Search
-
- Open
-
- split to
-
MDEV-40168 Indexes over JSON data based on Fulltext index
-
- Open
-