SlideShare a Scribd company logo
1 of 48
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Combining the Power of SQL and
NoSQL Databases with MySQL
Morgan Tocker
MySQL Product Manager (Server)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Today’s Agenda
4
Introduction
Core New JSON Features
Use Cases
1
2
3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL: Ubiquity & Market Share
5
MySQL is the 2nd most popular database!
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 6
More Jobs than Developers/DBAs
• Growing Demand
Source: StackOverflow, Developer Hiring Trends in 2017
More Developers/DBAs than Jobs
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Powers the Web
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
1. Google
2. Facebook
3. YouTube
4. Baidu
5. Yahoo!
6. Amazon
7. Wikipedia
8. QQ
9. Google.co.in
10. Twitter
11. Live.com
12. Taobao
13. Msn.com
14. Yahoo.co.jp
15. Sina
16. Linkedin.com
17. Google.co.jp
18. Weibo
19. Bing.com
20. Yandaz.ru
Global Top 20 Sites: Powered by MySQL
Source: Wikipedia 2016
8
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Powers Social
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Powers eCommerce
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Powers SaaS
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Powers FinTech
12
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Powers Unicorns
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Powers the Cloud
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 15
MySQL 5.7 GA – October 2015
Enhanced InnoDB: faster online & bulk
load operations
Replication Improvements (incl. multi-
source, multi-threaded slaves...)
New Optimizer Cost Model: greater user
control & better query performance
Performance Schema Improvements
MySQL SYS Schema
Performance & Scalability Manageability
3 X Faster than MySQL 5.6
Improved Security: safer initialization,
setup & management
Native JSON Support
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Today’s Agenda
16
Introduction
Core New JSON Features
Use Cases
1
2
3
2
1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Core New JSON features in MySQL 5.7
1. Native JSON datatype
2. JSON Functions
3. Generated Columns
4. JSON Comparator
17
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
The JSON Type
18
CREATE TABLE employees (data JSON);
INSERT INTO employees VALUES ('{"id": 1, "name": "Jane"}');
INSERT INTO employees VALUES ('{"id": 2, "name": "Joe"}');
SELECT * FROM employees;
+---------------------------+
| data |
+---------------------------+
| {"id": 1, "name": "Jane"} |
| {"id": 2, "name": "Joe"} |
+---------------------------+
2 rows in set (0,00 sec)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON Type Tech Specs
• utf8mb4 character set
• Optimized for read intensive workload
• Parse and validation on insert only
• Fast access to array cells by index
19
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON Type Tech Specs (cont.)
• Supports all native JSON types
• Numbers, strings, bool
• Objects, arrays
• Extended
• Date, time, datetime, timestamp
• Other
20
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Advantages over TEXT/VARCHAR
1. Provides Document Validation:
2. Efficient Binary Format
Allows quicker access to object members and array elements
21
INSERT INTO employees VALUES ('some random text');
ERROR 3130 (22032): Invalid JSON text: "Expect a value
here." at position 0 in value (or column) 'some random
text'.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Using Real Life Data
• Via SF OpenData
• 206K JSON objects
representing subdivision
parcels.
22
CREATE TABLE features (
id INT NOT NULL auto_increment primary key,
feature JSON NOT NULL
);
http://mysqlserverteam.com/taking-the-new-mysql-5-7-json-features-for-a-test-drive/
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 23
{
"type":"Feature",
"geometry":{
"type":"Polygon",
"coordinates":[
[
[-122.42200352825247,37.80848009696725,0],
[-122.42207601332528,37.808835019815085,0],
[-122.42110217434865,37.808803534992904,0],
[-122.42106256906727,37.80860105681814,0],
[-122.42200352825247,37.80848009696725,0]
]
]
},
"properties":{
"TO_ST":"0",
"BLKLOT":"0001001",
"STREET":"UNKNOWN",
"FROM_ST":"0",
"LOT_NUM":"001",
"ST_TYPE":null,
"ODD_EVEN":"E",
"BLOCK_NUM":"0001",
"MAPBLKLOT":"0001001"
}
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON Functions
24
SET @document = '[10, 20, [30, 40]]';
SELECT JSON_EXTRACT(@document, '$[1]');
+---------------------------------+
| JSON_EXTRACT(@document, '$[1]') |
+---------------------------------+
| 20 |
+---------------------------------+
1 row in set (0.01 sec)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON_EXTRACT
• Accepts a JSON Path, which is similar to a selector:
• JSON_EXTRACT also supports two short hand operators:
column_name->"$.type" (extract)
column_name->>"$.type" (extract + unquote)
25
$("#type") JSON_EXTRACT
(column_name, "$.type")
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SELECT DISTINCT JSON_EXTRACT(feature,
"$.type") as feature_type FROM features;
+--------------+
| feature_type |
+--------------+
| "Feature" |
+--------------+
1 row in set (1.00 sec)
26
JSON Shorthand Operators Explained
SELECT DISTINCT feature->"$.type" as
feature_type FROM features;
+--------------+
| feature_type |
+--------------+
| "Feature" |
+--------------+
1 row in set (0.99 sec)
SELECT DISTINCT
JSON_UNQUOTE(JSON_EXTRACT(feature,
"$.type")) as feature_type FROM features;
+--------------+
| feature_type |
+--------------+
| Feature |
+--------------+
1 row in set (1.06 sec)
SELECT DISTINCT feature->>"$.type" as
feature_type FROM features;
+--------------+
| feature_type |
+--------------+
| Feature |
+--------------+
1 row in set (1.02 sec)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Basic Find a Record
27
SELECT * FROM features
WHERE feature->"$.properties.STREET" = 'MARKET'
LIMIT 1G
************************* 1. row *************************
id: 12250
feature: {"type": "Feature", "geometry": {"type": "Polygon",
"coordinates": [[[-122.39836263491878, 37.79189388899312, 0],
[-122.39845248797837, 37.79233030084018, 0], [-
122.39768507706792, 37.7924280850133, 0], [-
122.39836263491878, 37.79189388899312, 0]]]}, "properties":
{"TO_ST": "388", "BLKLOT": "0265003", "STREET": "MARKET",
"FROM_ST": "388", "LOT_NUM": "003", "ST_TYPE": "ST",
"ODD_EVEN": "E", "BLOCK_NUM": "0265", "MAPBLKLOT":
"0265003"}}
1 row in set (0.02 sec)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Find where not exists
28
SELECT * FROM features
WHERE feature->"$.properties.STREET" IS NULL
LIMIT 1G
Empty set (0.39 sec)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Naive Performance Comparison
29
Unindexed traversal of 206K documents
# as JSON type
SELECT DISTINCT
feature->>"$.type" as json_extract
FROM features;
+--------------+
| json_extract |
+--------------+
| Feature |
+--------------+
1 row in set (1.25 sec)
# as TEXT type
SELECT DISTINCT
feature->>"$.type" as json_extract
FROM features;
+--------------+
| json_extract |
+--------------+
| Feature |
+--------------+
1 row in set (12.85 sec)
Using short cut for
JSON_UNQUOTE +
JSON_EXTRACT.
Explanation: Binary format of JSON type is very efficient at searching.
Storing as TEXT performs over 10x worse at traversal.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Introducing Generated Columns
30
CREATE TABLE t1 (
id INT NOT NULL PRIMARY KEY auto_increment,
my_integer INT,
my_integer_plus_one INT AS (my_integer+1)
);
UPDATE t1 SET my_integer_plus_one = 10 WHERE id = 1;
ERROR 3105 (HY000): The value specified for generated
column 'my_integer_plus_one' in table 't1' is not
allowed.
Column automatically
maintained based on your
specification.
Read-only of course
Id my_integer my_integer_plus_one
1 10 11
2 20 21
3 30 31
4 40 41
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Generated Columns Support Indexes!
31
From table scan on 206K documents to index scan on 206K materialized values
ALTER TABLE features ADD feature_type VARCHAR(30) AS
(feature->"$.type");
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE features ADD INDEX (feature_type);
Query OK, 0 rows affected (0.73 sec)
Records: 0 Duplicates: 0 Warnings: 0
SELECT DISTINCT feature_type FROM features;
+--------------+
| feature_type |
+--------------+
| "Feature" |
+--------------+
1 row in set (0.06 sec)
Meta data change only
(FAST). Does not need to
touch table.
Creates index only. Does
not modify table rows.
Down from 1.25 sec to
0.06 sec
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Generated Columns (cont.)
• Used for “functional index”
• Available as either VIRTUAL (default) or STORED:
• Both types of computed columns permit for indexes to be added.
32
ALTER TABLE features ADD feature_type varchar(30) AS
(feature->"$.type") STORED;
Query OK, 206560 rows affected (4.70 sec)
Records: 206560 Duplicates: 0 Warnings: 0
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Indexing Options Available
33
STORED VIRTUAL
Primary and Secondary
BTREE, Fulltext, GIS
Mixed with fields
Requires table rebuild
Not Online
Secondary Only
BTREE Only
Mixed with fields
No table rebuild
INSTANT Alter
Faster Insert
Bottom Line: Unless you need a PRIMARY KEY, FULLTEXT or GIS index
VIRTUAL is probably better.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON Path Search
• Provides a novice way to know the path. To retrieve via:
[[database.]table.]column->"$<path spec>"
34
SELECT JSON_SEARCH(feature,
'one', 'MARKET') AS
extract_path
FROM features
WHERE id = 121254;
+-----------------------+
| extract_path |
+-----------------------+
| "$.properties.STREET" |
+-----------------------+
1 row in set (0.00 sec)
SELECT
feature-
>"$.properties.STREET"
AS property_street
FROM features
WHERE id = 121254;
+-----------------+
| property_street |
+-----------------+
| "MARKET" |
+-----------------+
1 row in set (0.00 sec)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Create JSON_OBJECT
35
SELECT JSON_OBJECT('id', id,
'street', feature->"$.properties.STREET",
'type', feature->"$.type"
) AS json_object
FROM features ORDER BY RAND() LIMIT 3;
+--------------------------------------------------------+
| json_object |
+--------------------------------------------------------+
| {"id": 122976, "type": "Feature", "street": "RAUSCH"} |
| {"id": 148698, "type": "Feature", "street": "WALLACE"} |
| {"id": 45214, "type": "Feature", "street": "HAIGHT"} |
+--------------------------------------------------------+
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Create JSON_ARRAY
36
SELECT JSON_REPLACE(feature, '$.type', JSON_ARRAY('feature', 'bug')) as
json_object FROM features LIMIT 1;
+--------------------------------------------------------+
| json_object |
+--------------------------------------------------------+
| {"type": ["feature", "bug"], "geometry": {"type": ..}} |
+--------------------------------------------------------+
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON Functions
• 5.7 supports functions to CREATE, SEARCH, MODIFY and RETURN JSON
values:
37
JSON_ARRAY_APPEND()
JSON_ARRAY_INSERT()
JSON_ARRAY()
JSON_CONTAINS_PATH()
JSON_CONTAINS()
JSON_DEPTH()
JSON_EXTRACT()
JSON_INSERT()
JSON_KEYS()
JSON_LENGTH()
JSON_MERGE()
JSON_OBJECT()
JSON_QUOTE()
JSON_REMOVE()
JSON_REPLACE()
JSON_SEARCH()
JSON_SET()
JSON_TYPE()
JSON_UNQUOTE()
JSON_VALID()
https://dev.mysql.com/doc/refman/5.7/en/json-functions.html
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON Comparator
38
SELECT CAST(1 AS JSON) = 1;
+---------------------+
| CAST(1 AS JSON) = 1 |
+---------------------+
| 1 |
+---------------------+
1 row in set (0.01 sec)
SELECT CAST('{"a": 10, "num": 1.1}' AS JSON) = CAST('{"num": 1.1, "a":10}' AS JSON);
+------------------------------------------------------------------------------+
| CAST('{"a": 10, "num": 1.1}' AS JSON) = CAST('{"num": 1.1, "a":10}' AS JSON) |
+------------------------------------------------------------------------------+
| 1 |
+------------------------------------------------------------------------------+
1 row in set (0.00 sec)
JSON value of 1 equals 1
JSON Objects Compare
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON Comparator (cont.)
39
Join JSON value to MySQL value
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a INTEGER NOT NULL);
CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY, doc JSON NOT NULL);
INSERT INTO t1 VALUES (1, 1), (2, 2);
INSERT INTO t2 VALUES (1, JSON_OBJECT('a', 1)), (2, JSON_OBJECT('a', 2));
SELECT t1.id, t1.a, t2.doc FROM t1 INNER JOIN t2 ON (t1.a=t2.doc->"$.a");
+----+---+----------+
| id | a | doc |
+----+---+----------+
| 1 | 1 | {"a": 1} |
| 2 | 2 | {"a": 2} |
+----+---+----------+
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Today’s Agenda
40
Introduction
Core New JSON Features
Use cases
1
22
1
2
3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON or Column?
• Up to you!
• Advantages to both approaches
41
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Storing as a Column
• Easier to apply a schema to your application
• Schema may make applications easier to maintain over time, as change is
controlled;
• Do not have to expect as many permutations
• Allows some constraints over data
42
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Storing as JSON
• More flexible way to represent data that is hard to model in schema;
• Imagine you are a SaaS application serving many customers
• Strong use-case to support custom-fields
• Historically this may have used Entity–attribute–value model (EAV). Does not always
perform well
43
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON (cont.)
• Easier denormalization; an optimization that is important in some specific
situations
• No painful schema changes*
• Easier prototyping
• Fewer types to consider
• No enforced schema, start storing values immediately
44
* MySQL 5.6+ has Online DDL. This is not as large of an issue as it was historically.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Schema + Schemaless
45
SSDs have capacity_in_gb, CPUs have a core_count. These attributes
are not consistent across products.
CREATE TABLE pc_components (
id INT NOT NULL PRIMARY KEY,
description VARCHAR(60) NOT NULL,
vendor VARCHAR(30) NOT NULL,
serial_number VARCHAR(30) NOT NULL,
attributes JSON NOT NULL
);
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Road Map
• In-place partial update of JSON/BLOB (performance)
• Partial streaming of JSON/BLOB (replication)
• Full text and GIS index on virtual columns
• Currently works for "STORED"
• More Functions:
• Aggregate Functions
• Table Function
• Pretty print
• Binary Size / Binary Free
46
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Resources
• http://mysqlserverteam.com/
• http://mysqlserverteam.com/tag/json/
• https://dev.mysql.com/doc/refman/5.7/en/mysql-nutshell.html
• http://dev.mysql.com/doc/relnotes/mysql/5.7/en/
• https://dev.mysql.com/doc/refman/5.7/en/json.html
• https://dev.mysql.com/doc/refman/5.7/en/json-functions.html
• http://www.thecompletelistoffeatures.com
47
Combine the power of MySQL and NoSQL Database with MySQL

More Related Content

Recently uploaded

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 

Recently uploaded (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Combine the power of MySQL and NoSQL Database with MySQL

  • 1. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Combining the Power of SQL and NoSQL Databases with MySQL Morgan Tocker MySQL Product Manager (Server) Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
  • 2.
  • 3. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 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, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Today’s Agenda 4 Introduction Core New JSON Features Use Cases 1 2 3
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL: Ubiquity & Market Share 5 MySQL is the 2nd most popular database!
  • 6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 6 More Jobs than Developers/DBAs • Growing Demand Source: StackOverflow, Developer Hiring Trends in 2017 More Developers/DBAs than Jobs
  • 7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Powers the Web
  • 8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 1. Google 2. Facebook 3. YouTube 4. Baidu 5. Yahoo! 6. Amazon 7. Wikipedia 8. QQ 9. Google.co.in 10. Twitter 11. Live.com 12. Taobao 13. Msn.com 14. Yahoo.co.jp 15. Sina 16. Linkedin.com 17. Google.co.jp 18. Weibo 19. Bing.com 20. Yandaz.ru Global Top 20 Sites: Powered by MySQL Source: Wikipedia 2016 8
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Powers Social
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Powers eCommerce
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Powers SaaS
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Powers FinTech 12
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Powers Unicorns
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Powers the Cloud
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 15 MySQL 5.7 GA – October 2015 Enhanced InnoDB: faster online & bulk load operations Replication Improvements (incl. multi- source, multi-threaded slaves...) New Optimizer Cost Model: greater user control & better query performance Performance Schema Improvements MySQL SYS Schema Performance & Scalability Manageability 3 X Faster than MySQL 5.6 Improved Security: safer initialization, setup & management Native JSON Support
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Today’s Agenda 16 Introduction Core New JSON Features Use Cases 1 2 3 2 1
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Core New JSON features in MySQL 5.7 1. Native JSON datatype 2. JSON Functions 3. Generated Columns 4. JSON Comparator 17
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | The JSON Type 18 CREATE TABLE employees (data JSON); INSERT INTO employees VALUES ('{"id": 1, "name": "Jane"}'); INSERT INTO employees VALUES ('{"id": 2, "name": "Joe"}'); SELECT * FROM employees; +---------------------------+ | data | +---------------------------+ | {"id": 1, "name": "Jane"} | | {"id": 2, "name": "Joe"} | +---------------------------+ 2 rows in set (0,00 sec)
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Type Tech Specs • utf8mb4 character set • Optimized for read intensive workload • Parse and validation on insert only • Fast access to array cells by index 19
  • 20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Type Tech Specs (cont.) • Supports all native JSON types • Numbers, strings, bool • Objects, arrays • Extended • Date, time, datetime, timestamp • Other 20
  • 21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Advantages over TEXT/VARCHAR 1. Provides Document Validation: 2. Efficient Binary Format Allows quicker access to object members and array elements 21 INSERT INTO employees VALUES ('some random text'); ERROR 3130 (22032): Invalid JSON text: "Expect a value here." at position 0 in value (or column) 'some random text'.
  • 22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Using Real Life Data • Via SF OpenData • 206K JSON objects representing subdivision parcels. 22 CREATE TABLE features ( id INT NOT NULL auto_increment primary key, feature JSON NOT NULL ); http://mysqlserverteam.com/taking-the-new-mysql-5-7-json-features-for-a-test-drive/
  • 23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 23 { "type":"Feature", "geometry":{ "type":"Polygon", "coordinates":[ [ [-122.42200352825247,37.80848009696725,0], [-122.42207601332528,37.808835019815085,0], [-122.42110217434865,37.808803534992904,0], [-122.42106256906727,37.80860105681814,0], [-122.42200352825247,37.80848009696725,0] ] ] }, "properties":{ "TO_ST":"0", "BLKLOT":"0001001", "STREET":"UNKNOWN", "FROM_ST":"0", "LOT_NUM":"001", "ST_TYPE":null, "ODD_EVEN":"E", "BLOCK_NUM":"0001", "MAPBLKLOT":"0001001" } }
  • 24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 24 SET @document = '[10, 20, [30, 40]]'; SELECT JSON_EXTRACT(@document, '$[1]'); +---------------------------------+ | JSON_EXTRACT(@document, '$[1]') | +---------------------------------+ | 20 | +---------------------------------+ 1 row in set (0.01 sec)
  • 25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON_EXTRACT • Accepts a JSON Path, which is similar to a selector: • JSON_EXTRACT also supports two short hand operators: column_name->"$.type" (extract) column_name->>"$.type" (extract + unquote) 25 $("#type") JSON_EXTRACT (column_name, "$.type")
  • 26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SELECT DISTINCT JSON_EXTRACT(feature, "$.type") as feature_type FROM features; +--------------+ | feature_type | +--------------+ | "Feature" | +--------------+ 1 row in set (1.00 sec) 26 JSON Shorthand Operators Explained SELECT DISTINCT feature->"$.type" as feature_type FROM features; +--------------+ | feature_type | +--------------+ | "Feature" | +--------------+ 1 row in set (0.99 sec) SELECT DISTINCT JSON_UNQUOTE(JSON_EXTRACT(feature, "$.type")) as feature_type FROM features; +--------------+ | feature_type | +--------------+ | Feature | +--------------+ 1 row in set (1.06 sec) SELECT DISTINCT feature->>"$.type" as feature_type FROM features; +--------------+ | feature_type | +--------------+ | Feature | +--------------+ 1 row in set (1.02 sec)
  • 27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic Find a Record 27 SELECT * FROM features WHERE feature->"$.properties.STREET" = 'MARKET' LIMIT 1G ************************* 1. row ************************* id: 12250 feature: {"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[-122.39836263491878, 37.79189388899312, 0], [-122.39845248797837, 37.79233030084018, 0], [- 122.39768507706792, 37.7924280850133, 0], [- 122.39836263491878, 37.79189388899312, 0]]]}, "properties": {"TO_ST": "388", "BLKLOT": "0265003", "STREET": "MARKET", "FROM_ST": "388", "LOT_NUM": "003", "ST_TYPE": "ST", "ODD_EVEN": "E", "BLOCK_NUM": "0265", "MAPBLKLOT": "0265003"}} 1 row in set (0.02 sec)
  • 28. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Find where not exists 28 SELECT * FROM features WHERE feature->"$.properties.STREET" IS NULL LIMIT 1G Empty set (0.39 sec)
  • 29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Naive Performance Comparison 29 Unindexed traversal of 206K documents # as JSON type SELECT DISTINCT feature->>"$.type" as json_extract FROM features; +--------------+ | json_extract | +--------------+ | Feature | +--------------+ 1 row in set (1.25 sec) # as TEXT type SELECT DISTINCT feature->>"$.type" as json_extract FROM features; +--------------+ | json_extract | +--------------+ | Feature | +--------------+ 1 row in set (12.85 sec) Using short cut for JSON_UNQUOTE + JSON_EXTRACT. Explanation: Binary format of JSON type is very efficient at searching. Storing as TEXT performs over 10x worse at traversal.
  • 30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Introducing Generated Columns 30 CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY auto_increment, my_integer INT, my_integer_plus_one INT AS (my_integer+1) ); UPDATE t1 SET my_integer_plus_one = 10 WHERE id = 1; ERROR 3105 (HY000): The value specified for generated column 'my_integer_plus_one' in table 't1' is not allowed. Column automatically maintained based on your specification. Read-only of course Id my_integer my_integer_plus_one 1 10 11 2 20 21 3 30 31 4 40 41
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Generated Columns Support Indexes! 31 From table scan on 206K documents to index scan on 206K materialized values ALTER TABLE features ADD feature_type VARCHAR(30) AS (feature->"$.type"); Query OK, 0 rows affected (0.01 sec) Records: 0 Duplicates: 0 Warnings: 0 ALTER TABLE features ADD INDEX (feature_type); Query OK, 0 rows affected (0.73 sec) Records: 0 Duplicates: 0 Warnings: 0 SELECT DISTINCT feature_type FROM features; +--------------+ | feature_type | +--------------+ | "Feature" | +--------------+ 1 row in set (0.06 sec) Meta data change only (FAST). Does not need to touch table. Creates index only. Does not modify table rows. Down from 1.25 sec to 0.06 sec
  • 32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Generated Columns (cont.) • Used for “functional index” • Available as either VIRTUAL (default) or STORED: • Both types of computed columns permit for indexes to be added. 32 ALTER TABLE features ADD feature_type varchar(30) AS (feature->"$.type") STORED; Query OK, 206560 rows affected (4.70 sec) Records: 206560 Duplicates: 0 Warnings: 0
  • 33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Indexing Options Available 33 STORED VIRTUAL Primary and Secondary BTREE, Fulltext, GIS Mixed with fields Requires table rebuild Not Online Secondary Only BTREE Only Mixed with fields No table rebuild INSTANT Alter Faster Insert Bottom Line: Unless you need a PRIMARY KEY, FULLTEXT or GIS index VIRTUAL is probably better.
  • 34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Path Search • Provides a novice way to know the path. To retrieve via: [[database.]table.]column->"$<path spec>" 34 SELECT JSON_SEARCH(feature, 'one', 'MARKET') AS extract_path FROM features WHERE id = 121254; +-----------------------+ | extract_path | +-----------------------+ | "$.properties.STREET" | +-----------------------+ 1 row in set (0.00 sec) SELECT feature- >"$.properties.STREET" AS property_street FROM features WHERE id = 121254; +-----------------+ | property_street | +-----------------+ | "MARKET" | +-----------------+ 1 row in set (0.00 sec)
  • 35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Create JSON_OBJECT 35 SELECT JSON_OBJECT('id', id, 'street', feature->"$.properties.STREET", 'type', feature->"$.type" ) AS json_object FROM features ORDER BY RAND() LIMIT 3; +--------------------------------------------------------+ | json_object | +--------------------------------------------------------+ | {"id": 122976, "type": "Feature", "street": "RAUSCH"} | | {"id": 148698, "type": "Feature", "street": "WALLACE"} | | {"id": 45214, "type": "Feature", "street": "HAIGHT"} | +--------------------------------------------------------+
  • 36. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Create JSON_ARRAY 36 SELECT JSON_REPLACE(feature, '$.type', JSON_ARRAY('feature', 'bug')) as json_object FROM features LIMIT 1; +--------------------------------------------------------+ | json_object | +--------------------------------------------------------+ | {"type": ["feature", "bug"], "geometry": {"type": ..}} | +--------------------------------------------------------+
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions • 5.7 supports functions to CREATE, SEARCH, MODIFY and RETURN JSON values: 37 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT() JSON_ARRAY() JSON_CONTAINS_PATH() JSON_CONTAINS() JSON_DEPTH() JSON_EXTRACT() JSON_INSERT() JSON_KEYS() JSON_LENGTH() JSON_MERGE() JSON_OBJECT() JSON_QUOTE() JSON_REMOVE() JSON_REPLACE() JSON_SEARCH() JSON_SET() JSON_TYPE() JSON_UNQUOTE() JSON_VALID() https://dev.mysql.com/doc/refman/5.7/en/json-functions.html
  • 38. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Comparator 38 SELECT CAST(1 AS JSON) = 1; +---------------------+ | CAST(1 AS JSON) = 1 | +---------------------+ | 1 | +---------------------+ 1 row in set (0.01 sec) SELECT CAST('{"a": 10, "num": 1.1}' AS JSON) = CAST('{"num": 1.1, "a":10}' AS JSON); +------------------------------------------------------------------------------+ | CAST('{"a": 10, "num": 1.1}' AS JSON) = CAST('{"num": 1.1, "a":10}' AS JSON) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ 1 row in set (0.00 sec) JSON value of 1 equals 1 JSON Objects Compare
  • 39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Comparator (cont.) 39 Join JSON value to MySQL value CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a INTEGER NOT NULL); CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY, doc JSON NOT NULL); INSERT INTO t1 VALUES (1, 1), (2, 2); INSERT INTO t2 VALUES (1, JSON_OBJECT('a', 1)), (2, JSON_OBJECT('a', 2)); SELECT t1.id, t1.a, t2.doc FROM t1 INNER JOIN t2 ON (t1.a=t2.doc->"$.a"); +----+---+----------+ | id | a | doc | +----+---+----------+ | 1 | 1 | {"a": 1} | | 2 | 2 | {"a": 2} | +----+---+----------+
  • 40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Today’s Agenda 40 Introduction Core New JSON Features Use cases 1 22 1 2 3
  • 41. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON or Column? • Up to you! • Advantages to both approaches 41
  • 42. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Storing as a Column • Easier to apply a schema to your application • Schema may make applications easier to maintain over time, as change is controlled; • Do not have to expect as many permutations • Allows some constraints over data 42
  • 43. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Storing as JSON • More flexible way to represent data that is hard to model in schema; • Imagine you are a SaaS application serving many customers • Strong use-case to support custom-fields • Historically this may have used Entity–attribute–value model (EAV). Does not always perform well 43
  • 44. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON (cont.) • Easier denormalization; an optimization that is important in some specific situations • No painful schema changes* • Easier prototyping • Fewer types to consider • No enforced schema, start storing values immediately 44 * MySQL 5.6+ has Online DDL. This is not as large of an issue as it was historically.
  • 45. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Schema + Schemaless 45 SSDs have capacity_in_gb, CPUs have a core_count. These attributes are not consistent across products. CREATE TABLE pc_components ( id INT NOT NULL PRIMARY KEY, description VARCHAR(60) NOT NULL, vendor VARCHAR(30) NOT NULL, serial_number VARCHAR(30) NOT NULL, attributes JSON NOT NULL );
  • 46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Road Map • In-place partial update of JSON/BLOB (performance) • Partial streaming of JSON/BLOB (replication) • Full text and GIS index on virtual columns • Currently works for "STORED" • More Functions: • Aggregate Functions • Table Function • Pretty print • Binary Size / Binary Free 46
  • 47. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Resources • http://mysqlserverteam.com/ • http://mysqlserverteam.com/tag/json/ • https://dev.mysql.com/doc/refman/5.7/en/mysql-nutshell.html • http://dev.mysql.com/doc/relnotes/mysql/5.7/en/ • https://dev.mysql.com/doc/refman/5.7/en/json.html • https://dev.mysql.com/doc/refman/5.7/en/json-functions.html • http://www.thecompletelistoffeatures.com 47

Editor's Notes

  1. This is a Safe Harbor Front slide, one of two Safe Harbor Statement slides included in this template. One of the Safe Harbor slides must be used if your presentation covers material affected by Oracle’s Revenue Recognition Policy To learn more about this policy, e-mail: Revrec-americasiebc_us@oracle.com For internal communication, Safe Harbor Statements are not required. However, there is an applicable disclaimer (Exhibit E) that should be used, found in the Oracle Revenue Recognition Policy for Future Product Communications. Copy and paste this link into a web browser, to find out more information.   http://my.oracle.com/site/fin/gfo/GlobalProcesses/cnt452504.pdf For all external communications such as press release, roadmaps, PowerPoint presentations, Safe Harbor Statements are required. You can refer to the link mentioned above to find out additional information/disclaimers required depending on your audience.
  2. Hilight a few other features from 5.7 GA and say “this talk is focused on Native JSON Support”
  3. The comparator allows the noSQL and SQL worlds to combine.
  4. The ones in bold are shown on the slides.
  5. Notice that the JSON object comparisons are equal - even though the keys are in a different order. The JSON specification allows keys to be in any order.
  6. This is a repeat from the previous slide (values comparing as equal). Notice how natural it is, this provides an easy migration path between top level columns and JSON (and the reverse).