SlideShare a Scribd company logo
6
Most read
7
Most read
14
Most read
Copyright © 2019 Oracle and/or its affiliates.1
JSON array indexes
in MySQL
Norvald H. Ryeng
Software Development Senior Manager
MySQL Optimizer Team
October 2, 2019
New in
8.0.17
Copyright © 2019 Oracle and/or its affiliates.2
Safe harbor statement
The following is intended to outline our general product direction. It is intended for information
purposes only, and may not be incorporated into any contract. It is not a commitment to deliver
any material, code, or functionality, and should not be relied upon in making purchasing
decisions.
The development, release, timing, and pricing of any features or functionality described for
Oracle’s products may change and remains at the sole discretion of Oracle Corporation.
Copyright © 2019 Oracle and/or its affiliates.3
Program agenda
1 What is it?
2 How do I use it?
3 Demo
Copyright © 2019 Oracle and/or its affiliates.4
What is it?
 Index of a JSON array
A functional index over a JSON expression
The expression evaluates to an array
 Several index entries per row
One index entry per array element
General mechanism, currently used for JSON arrays
 Used to speed up array lookups
JSON_CONTAINS(…)
JSON_OVERLAPS(…)
MEMBER OF (…)
Copyright © 2019 Oracle and/or its affiliates.5
Limitations
 Can be part of a multi-column index
Only one array expression per index
Avoiding combinatorial explosion
 Can flatten and index nested arrays
CAST(json->'$.the_array[*][*]' AS UNSIGNED INT ARRAY)
 Can't be PRIMARY
 Can be UNIQUE
Copyright © 2019 Oracle and/or its affiliates.6
How do I use it?
CREATE TABLE lottery (data JSON);
CREATE INDEX ticket_idx ON lottery ((CAST(data->'$.lottery_tickets' AS UNSIGNED INT ARRAY)));
INSERT INTO lottery VALUES
('{"id":1, "name":"Alice", "lottery_tickets": [1]}'),
('{"id":2, "name":"Bob", "lottery_tickets": [2,22]}'),
('{"id":3, "name":"Carol", "lottery_tickets": [3,33,333]}'),
('{"id":4, "name":"Dan", "lottery_tickets": [4,44,444,4444]}'),
('{"id":5, "name":"Erin", "lottery_tickets": [5,55,555,5555,55555]}');
Cast to array is only available
when creating a functional index
Type of array element
Copyright © 2019 Oracle and/or its affiliates.7
New in
8.0.17
How do I use it?
Find all rows where the array contains a given value
SELECT data
FROM lottery
WHERE JSON_CONTAINS(data->'$.lottery_tickets', CAST(22 AS JSON));
or
SELECT data FROM lottery WHERE 22 MEMBER OF (data->'$.lottery_tickets');
Find the one winner
Copyright © 2019 Oracle and/or its affiliates.8
How do I use it?
Find all rows that contain one or more of the given values
SELECT data
FROM lottery
WHERE JSON_OVERLAPS(data->'$.lottery_tickets', CAST('[22,44]' AS JSON));
Find everyone with at
least one winning ticket
New in
8.0.17
Copyright © 2019 Oracle and/or its affiliates.9
Demo
MySQL 8.0.17
JSON Array Indexes in MySQL
JSON Array Indexes in MySQL
JSON Array Indexes in MySQL
Copyright © 2019 Oracle and/or its affiliates.13
Feature descriptions and design details
directly from the source
https://mysqlserverteam.com/
Copyright © 2019 Oracle and/or its affiliates.14
Thank you!
Norvald H. Ryeng
Software Development Senior Manager
MySQL Optimizer Team

More Related Content

What's hot (20)

PPTX
Indexing the MySQL Index: Key to performance tuning
OSSCube
 
PPTX
Basic oracle-database-administration
sreehari orienit
 
PDF
MySQL: Indexing for Better Performance
jkeriaki
 
PPT
Explain that explain
Fabrizio Parrella
 
PDF
InnoDB Internal
mysqlops
 
PDF
Extensible Data Modeling
Karwin Software Solutions LLC
 
PDF
SOUG Day Oracle 21c New Security Features
Stefan Oehrli
 
PPT
MySQL and its basic commands
Bwsrang Basumatary
 
PDF
Using Optimizer Hints to Improve MySQL Query Performance
oysteing
 
PPT
Constraints In Sql
Anurag
 
PDF
Advanced MySQL Query Tuning
Alexander Rubin
 
PPTX
Monitoramento de Aplicações Web Modernas com Zabbix
André Déo
 
PPTX
Mongo DB Presentation
Jaya Naresh Kovela
 
PDF
MySQL Index Cookbook
MYXPLAIN
 
PPT
MYSQL.ppt
webhostingguy
 
PDF
Mysql index
Yuan Yao
 
PDF
Oracle goldengate 11g schema replication from standby database
uzzal basak
 
PDF
MySQL 8.0 Optimizer Guide
Morgan Tocker
 
PDF
Open Source 101 2022 - MySQL Indexes and Histograms
Frederic Descamps
 
PPTX
Guide To Mastering The MySQL Query Execution Plan
Optimiz DBA
 
Indexing the MySQL Index: Key to performance tuning
OSSCube
 
Basic oracle-database-administration
sreehari orienit
 
MySQL: Indexing for Better Performance
jkeriaki
 
Explain that explain
Fabrizio Parrella
 
InnoDB Internal
mysqlops
 
Extensible Data Modeling
Karwin Software Solutions LLC
 
SOUG Day Oracle 21c New Security Features
Stefan Oehrli
 
MySQL and its basic commands
Bwsrang Basumatary
 
Using Optimizer Hints to Improve MySQL Query Performance
oysteing
 
Constraints In Sql
Anurag
 
Advanced MySQL Query Tuning
Alexander Rubin
 
Monitoramento de Aplicações Web Modernas com Zabbix
André Déo
 
Mongo DB Presentation
Jaya Naresh Kovela
 
MySQL Index Cookbook
MYXPLAIN
 
MYSQL.ppt
webhostingguy
 
Mysql index
Yuan Yao
 
Oracle goldengate 11g schema replication from standby database
uzzal basak
 
MySQL 8.0 Optimizer Guide
Morgan Tocker
 
Open Source 101 2022 - MySQL Indexes and Histograms
Frederic Descamps
 
Guide To Mastering The MySQL Query Execution Plan
Optimiz DBA
 

Similar to JSON Array Indexes in MySQL (20)

PDF
JSON array indexes in MySQL
Dag H. Wanvik
 
PDF
Oracle CodeOne Foreign Keys Support in MySQL 8.0
Dave Stokes
 
PPTX
cPanel now supports MySQL 8.0 - My Top Seven Features
Dave Stokes
 
PDF
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Otávio Santana
 
PDF
MySQL : State of the Dolphin May 2019
Frederic Descamps
 
PDF
MySQL New Features -- Sunshine PHP 2020 Presentation
Dave Stokes
 
PDF
MySQL 8.0 Introduction to NoSQL + SQL
Manuel Contreras
 
PDF
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
Dave Stokes
 
PPTX
A Step by Step Introduction to the MySQL Document Store
Dave Stokes
 
PDF
2012 summarytables
sqlhjalp
 
PDF
Develop Python Applications with MySQL Connector/Python
Jesper Wisborg Krogh
 
PDF
Oracle NoSQL
Oracle Korea
 
PDF
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
Carsten Czarski
 
PDF
MySQL Tech Café #8: MySQL 8.0 for Python Developers
Frederic Descamps
 
PDF
Looking Inside the MySQL 8.0 Document Store
Frederic Descamps
 
PDF
20200402 oracle cloud infrastructure data science
Kenichi Sonoda
 
PDF
Python and the MySQL Document Store
Jesper Wisborg Krogh
 
PDF
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
Geir Høydalsvik
 
PDF
20320130406009
IAEME Publication
 
JSON array indexes in MySQL
Dag H. Wanvik
 
Oracle CodeOne Foreign Keys Support in MySQL 8.0
Dave Stokes
 
cPanel now supports MySQL 8.0 - My Top Seven Features
Dave Stokes
 
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Otávio Santana
 
MySQL : State of the Dolphin May 2019
Frederic Descamps
 
MySQL New Features -- Sunshine PHP 2020 Presentation
Dave Stokes
 
MySQL 8.0 Introduction to NoSQL + SQL
Manuel Contreras
 
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
Dave Stokes
 
A Step by Step Introduction to the MySQL Document Store
Dave Stokes
 
2012 summarytables
sqlhjalp
 
Develop Python Applications with MySQL Connector/Python
Jesper Wisborg Krogh
 
Oracle NoSQL
Oracle Korea
 
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
Carsten Czarski
 
MySQL Tech Café #8: MySQL 8.0 for Python Developers
Frederic Descamps
 
Looking Inside the MySQL 8.0 Document Store
Frederic Descamps
 
20200402 oracle cloud infrastructure data science
Kenichi Sonoda
 
Python and the MySQL Document Store
Jesper Wisborg Krogh
 
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
Geir Høydalsvik
 
20320130406009
IAEME Publication
 
Ad

More from Norvald Ryeng (9)

PDF
MySQL 8.0 EXPLAIN ANALYZE
Norvald Ryeng
 
PDF
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
Norvald Ryeng
 
PDF
Spatial Support in MySQL
Norvald Ryeng
 
PDF
LATERAL Derived Tables in MySQL 8.0
Norvald Ryeng
 
PDF
More SQL in MySQL 8.0
Norvald Ryeng
 
PDF
MySQL 8.0: What Is New in Optimizer and Executor?
Norvald Ryeng
 
PDF
How to Take Advantage of Optimizer Improvements in MySQL 8.0
Norvald Ryeng
 
PDF
MySQL 8.0 GIS Overview
Norvald Ryeng
 
PDF
MySQL 8.0: GIS — Are you ready?
Norvald Ryeng
 
MySQL 8.0 EXPLAIN ANALYZE
Norvald Ryeng
 
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
Norvald Ryeng
 
Spatial Support in MySQL
Norvald Ryeng
 
LATERAL Derived Tables in MySQL 8.0
Norvald Ryeng
 
More SQL in MySQL 8.0
Norvald Ryeng
 
MySQL 8.0: What Is New in Optimizer and Executor?
Norvald Ryeng
 
How to Take Advantage of Optimizer Improvements in MySQL 8.0
Norvald Ryeng
 
MySQL 8.0 GIS Overview
Norvald Ryeng
 
MySQL 8.0: GIS — Are you ready?
Norvald Ryeng
 
Ad

Recently uploaded (20)

PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 

JSON Array Indexes in MySQL

  • 1. Copyright © 2019 Oracle and/or its affiliates.1 JSON array indexes in MySQL Norvald H. Ryeng Software Development Senior Manager MySQL Optimizer Team October 2, 2019 New in 8.0.17
  • 2. Copyright © 2019 Oracle and/or its affiliates.2 Safe harbor statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation.
  • 3. Copyright © 2019 Oracle and/or its affiliates.3 Program agenda 1 What is it? 2 How do I use it? 3 Demo
  • 4. Copyright © 2019 Oracle and/or its affiliates.4 What is it?  Index of a JSON array A functional index over a JSON expression The expression evaluates to an array  Several index entries per row One index entry per array element General mechanism, currently used for JSON arrays  Used to speed up array lookups JSON_CONTAINS(…) JSON_OVERLAPS(…) MEMBER OF (…)
  • 5. Copyright © 2019 Oracle and/or its affiliates.5 Limitations  Can be part of a multi-column index Only one array expression per index Avoiding combinatorial explosion  Can flatten and index nested arrays CAST(json->'$.the_array[*][*]' AS UNSIGNED INT ARRAY)  Can't be PRIMARY  Can be UNIQUE
  • 6. Copyright © 2019 Oracle and/or its affiliates.6 How do I use it? CREATE TABLE lottery (data JSON); CREATE INDEX ticket_idx ON lottery ((CAST(data->'$.lottery_tickets' AS UNSIGNED INT ARRAY))); INSERT INTO lottery VALUES ('{"id":1, "name":"Alice", "lottery_tickets": [1]}'), ('{"id":2, "name":"Bob", "lottery_tickets": [2,22]}'), ('{"id":3, "name":"Carol", "lottery_tickets": [3,33,333]}'), ('{"id":4, "name":"Dan", "lottery_tickets": [4,44,444,4444]}'), ('{"id":5, "name":"Erin", "lottery_tickets": [5,55,555,5555,55555]}'); Cast to array is only available when creating a functional index Type of array element
  • 7. Copyright © 2019 Oracle and/or its affiliates.7 New in 8.0.17 How do I use it? Find all rows where the array contains a given value SELECT data FROM lottery WHERE JSON_CONTAINS(data->'$.lottery_tickets', CAST(22 AS JSON)); or SELECT data FROM lottery WHERE 22 MEMBER OF (data->'$.lottery_tickets'); Find the one winner
  • 8. Copyright © 2019 Oracle and/or its affiliates.8 How do I use it? Find all rows that contain one or more of the given values SELECT data FROM lottery WHERE JSON_OVERLAPS(data->'$.lottery_tickets', CAST('[22,44]' AS JSON)); Find everyone with at least one winning ticket New in 8.0.17
  • 9. Copyright © 2019 Oracle and/or its affiliates.9 Demo MySQL 8.0.17
  • 13. Copyright © 2019 Oracle and/or its affiliates.13 Feature descriptions and design details directly from the source https://mysqlserverteam.com/
  • 14. Copyright © 2019 Oracle and/or its affiliates.14 Thank you! Norvald H. Ryeng Software Development Senior Manager MySQL Optimizer Team