SlideShare une entreprise Scribd logo
1  sur  146
Télécharger pour lire hors ligne
1 /
146
Frédéric Descamps
Community Manager
MySQL
June 2020
MySQL 8.0 Document Store
discovery of a new world
2 /
146
 
Safe Harbor
The following is intended to outline our general product direction. It is intended for information purpose 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 up in making purchasing decisions. The development, release, timing and pricing of any
features or functionality described for Oracle´s product may change and remains at the sole discretion of Oracle
Corporation.
Statement in this presentation relating to Oracle´s future plans, expectations, beliefs, intentions and ptospects
are "forward-looking statements" and are subject to material risks and uncertainties. A detailed discussion of
these factors and other risks that a ect our business is contained in Oracle´s Securities and Exchange
Commission (SEC) lings, including our most recent reports on Form 10-K and Form 10-Q under the heading
"Risk Factors". These lings are available on the SEC´s website or on Oracle´s website at
h p://www.oracle.com/investor. All information in this presentation is current as of September 2019 and Oracle
undertakes no duty to update any statement in light of new information or future events.
Copyright @ 2020 Oracle and/or its affiliates.
3 /
146
about.me/lefred
Who am I ?
Copyright @ 2020 Oracle and/or its affiliates.
4 /
146
Frédéric Descamps
@lefred
MySQL Evangelist
Managing MySQL since 3.20 !
devops believer
living in Belgium 🇧🇪
h ps://lefred.be
Copyright @ 2020 Oracle and/or its affiliates.
5 /
146
#MySQl8isGreat
MySQL
Copyright @ 2020 Oracle and/or its affiliates.
6 /
146
DB-Engines 2020
Database Ranking
Copyright @ 2020 Oracle and/or its affiliates.
7 /
146
DB-Engines 2020
Database Ranking
MySQL is the most popular Open Source database
Copyright @ 2020 Oracle and/or its affiliates.
8 /
146
MySQL is the DBMS of the Year 2019 !
Copyright @ 2020 Oracle and/or its affiliates.
9 /
146
Happy 25th Anniversary MySQL
Copyright @ 2020 Oracle and/or its affiliates.
10 /
146
from LAMP stack to modern Web applications
Evolution...
Copyright @ 2020 Oracle and/or its affiliates.
11 /
146
Web Applications 2000's
Who ?
Copyright @ 2020 Oracle and/or its affiliates.
12 /
146
Web Applications 2000's
Who ?
Copyright @ 2020 Oracle and/or its affiliates.
13 /
146
Web Applications 2000's
How ?
Copyright @ 2020 Oracle and/or its affiliates.
14 /
146
Web Applications 2000's
How ?
Copyright @ 2020 Oracle and/or its affiliates.
15 /
146
Relational Databases
Data Integrity
Copyright @ 2020 Oracle and/or its affiliates.
16 /
146
Relational Databases
Data Integrity
normalization
Copyright @ 2020 Oracle and/or its affiliates.
17 /
146
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Copyright @ 2020 Oracle and/or its affiliates.
18 /
146
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
Copyright @ 2020 Oracle and/or its affiliates.
19 /
146
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
ACID compliant
Copyright @ 2020 Oracle and/or its affiliates.
20 /
146
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
ACID compliant
transactions
Copyright @ 2020 Oracle and/or its affiliates.
21 /
146
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
ACID compliant
transactions
SQL
Copyright @ 2020 Oracle and/or its affiliates.
22 /
146
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
ACID compliant
transactions
SQL
powerfull query language
Copyright @ 2020 Oracle and/or its affiliates.
23 /
146
Web Applications current days
Who ?
Copyright @ 2020 Oracle and/or its affiliates.
24 /
146
Web Applications current days
Who ?
Copyright @ 2020 Oracle and/or its affiliates.
25 /
146
Web Applications current days
How ?
Copyright @ 2020 Oracle and/or its affiliates.
26 /
146
Web Applications current days
Why ?
Copyright @ 2020 Oracle and/or its affiliates.
27 /
146
Web Applications current days
Why ?
Developers don't really like SQL anymore...
 
Copyright @ 2020 Oracle and/or its affiliates.
28 /
146
SQL can be complicated and slows down
the initial development
Web Applications current days
Why ?
Copyright @ 2020 Oracle and/or its affiliates.
29 /
146
Developers don't have time to learn SQL,
they need time to workout and have a nice
look ;-)
Web Applications current days
Why ?
Copyright @ 2020 Oracle and/or its affiliates.
30 /
146
easy operations
What do developers want ?
Copyright @ 2020 Oracle and/or its affiliates.
31 /
146
Use Objects / Documents
Developers want just to use objects
Copyright @ 2020 Oracle and/or its affiliates.
32 /
146
Use Objects / Documents
Developers want just to use objects
that's why they usually love what DBAs hate the most ORMs !
Copyright @ 2020 Oracle and/or its affiliates.
33 /
146
Use Objects / Documents
Developers want just to use objects
that's why they usually love what DBAs hate the most ORMs !
They want to deal with these objects easily (CRUD operations) and they don't want to think
about schema design (slows down the initial development process).
Copyright @ 2020 Oracle and/or its affiliates.
34 /
146
Use Objects / Documents
Developers want just to use objects
that's why they usually love what DBAs hate the most ORMs !
They want to deal with these objects easily (CRUD operations) and they don't want to think
about schema design (slows down the initial development process).
But they also want to keep their data safe and use transactions.
Copyright @ 2020 Oracle and/or its affiliates.
35 /
146
Web Applications current days
How ?
Copyright @ 2020 Oracle and/or its affiliates.
36 /
146
Web Applications current days
How ?
Copyright @ 2020 Oracle and/or its affiliates.
37 /
146
JSON Document Store
NoSQL Databases
Copyright @ 2020 Oracle and/or its affiliates.
38 /
146
NoSQL Document Store
Schemaless
Copyright @ 2020 Oracle and/or its affiliates.
39 /
146
NoSQL Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
Copyright @ 2020 Oracle and/or its affiliates.
40 /
146
NoSQL Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Copyright @ 2020 Oracle and/or its affiliates.
41 /
146
NoSQL Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
Copyright @ 2020 Oracle and/or its affiliates.
42 /
146
NoSQL Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
Copyright @ 2020 Oracle and/or its affiliates.
43 /
146
NoSQL Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can't be modelized optimaly into a relational model
Copyright @ 2020 Oracle and/or its affiliates.
44 /
146
NoSQL Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can't be modelized optimaly into a relational model
objects persistance without the use of any ORM - mapping oobject-oriented
Copyright @ 2020 Oracle and/or its affiliates.
45 /
146
NoSQL Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can't be modelized optimaly into a relational model
objects persistance without the use of any ORM - mapping oobject-oriented
JSON
Copyright @ 2020 Oracle and/or its affiliates.
46 /
146
NoSQL Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can't be modelized optimaly into a relational model
objects persistance without the use of any ORM - mapping oobject-oriented
JSON
close to frontend
Copyright @ 2020 Oracle and/or its affiliates.
47 /
146
NoSQL Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can't be modelized optimaly into a relational model
objects persistance without the use of any ORM - mapping oobject-oriented
JSON
close to frontend
easy to learn
Copyright @ 2020 Oracle and/or its affiliates.
48 /
146
How DBAs see data
Copyright @ 2020 Oracle and/or its affiliates.
49 /
146
How DBAs see data How Developers see data
{
"GNP" : 249704,
"Name" : "Belgium",
"government" : {
"GovernmentForm" :
"Constitutional Monarchy, Federation",
"HeadOfState" : "Philippe I"
},
"_id" : "BEL",
"IndepYear" : 1830,
"demographics" : {
"Population" : 10239000,
"LifeExpectancy" : 77.8000030517578
},
"geography" : {
"Region" : "Western Europe",
"SurfaceArea" : 30518,
"Continent" : "Europe"
}
}
Copyright @ 2020 Oracle and/or its affiliates.
50 /
146
And they still need to do Analytics
SQL
SQL
SQL
Copyright @ 2020 Oracle and/or its affiliates.
51 /
146
... mmm...how ?
?
SQL
SQL
SQL
Copyright @ 2020 Oracle and/or its affiliates.
52 /
146
Help needed !
Who ?
Copyright @ 2020 Oracle and/or its affiliates.
53 /
146
Help needed !
Who ?
Copyright @ 2020 Oracle and/or its affiliates.
54 /
146
How ?
SQL
SQL
SQL
Copyright @ 2020 Oracle and/or its affiliates.
55 /
146
What if there was a way to provide both SQL
and NoSQL on one stable platform that has
proven stability on well know technology with
a large Community and a diverse ecosystem ?
Copyright @ 2020 Oracle and/or its affiliates.
56 /
146
DBMS or NoSQL ?
Copyright @ 2020 Oracle and/or its affiliates.
57 /
146
DBMS or NoSQL ?
Why not both ?
Copyright @ 2020 Oracle and/or its affiliates.
58 /
146
The MySQL Document Store !
SQL is now optional ?!
Copyright @ 2020 Oracle and/or its affiliates.
59 /
146
SQL is now optional ?!
Copyright @ 2020 Oracle and/or its affiliates.
60 /
146
Using MySQL Document Store !
SQL
SQL
SQL
Copyright @ 2020 Oracle and/or its affiliates.
61 /
146
Developers:
[x] schemaless
[x] rapid prototying/simpler APIs
[x] document model
[x] transactions
Operations:
[x] performance
management/visibility
[x] robust replication, backup, restore
[x] comprehensive tooling ecosystem
[x] simpler application schema
upgrades
Business Owner:
[x] don't lose my data == ACID trx
[x] capture all my data = extensible/schemaless
[x] product on schedule/time to market = rapid
developement
A solution for all
Copyright @ 2020 Oracle and/or its affiliates.
62 /
146
MySQL Document Store
the Solution
Copyright @ 2020 Oracle and/or its affiliates.
63 /
146
Built on
the MySQL
JSON Data
type and
Proven
MySQL
Server
Technology
Provides a schema exible JSON Document Store
No SQL required
No need to de ne all possible a ributes, tables, etc.
Uses new X DevAPI
Can leverage generated column to extract JSON values into
materialized columns that can be indexed for fast SQL searches.
Document can be ~1GB
It's a column in a row of a table
It cannot exceed max_allowed_packet
Allows use of modern programming styles
No more embedded strings of SQL in your code
Easy to read
Also works with relational Tables
Proven MySQL Technology
Copyright @ 2020 Oracle and/or its affiliates.
64 /
146
X Protocol Connectors
Copyright @ 2020 Oracle and/or its affiliates.
65 /
146
X DevAPI We provide connectors for
C++, Java, .Net, Node.js, Python, PHP
working with Communities to help them supporting it too
New MySQL Shell
Command Completion
Python, JavaScrips & SQL modes
Admin functions
New Util object
A new high-level session concept that can scale from single
.mysql-blue[My].mysql-orange[SQL] Server to a multiple
server environment
Non-blocking, asynchronous calls follow common language
pa erns
Supports CRUD operations
Copyright @ 2020 Oracle and/or its affiliates.
66 /
146
MySQL Document Store
Setup
Copyright @ 2020 Oracle and/or its affiliates.
67 /
146
Installing MySQL Document Store
install MySQL 8.0
Copyright @ 2020 Oracle and/or its affiliates.
68 /
146
Installing MySQL Document Store
install MySQL 8.0
install MySQL Shell
Copyright @ 2020 Oracle and/or its affiliates.
69 /
146
Installing MySQL Document Store
install MySQL 8.0
install MySQL Shell
install MySQL Connector for your programming language
Copyright @ 2020 Oracle and/or its affiliates.
70 /
146
Installing MySQL Document Store
install MySQL 8.0
install MySQL Shell
install MySQL Connector for your programming language
php-pecl-mysql-xdevapi for PHP
mysql-connector-python for Python
...
Copyright @ 2020 Oracle and/or its affiliates.
71 /
146
Installing MySQL Document Store
install MySQL 8.0
install MySQL Shell
install MySQL Connector for your programming language
php-pecl-mysql-xdevapi for PHP
mysql-connector-python for Python
...
And nothing else, no need to install anything else or load any plugin, just be sure your
rewall allows you to connect through port 33060 (X Protocol).
Copyright @ 2020 Oracle and/or its affiliates.
72 /
146
Migration from MongoDB to MySQL DS
For this example, I will use the well known restaurants collection:
Copyright @ 2020 Oracle and/or its affiliates.
73 /
146
Migration from MongoDB to MySQL DS
For this example, I will use the well known restaurants collection:
Copyright @ 2020 Oracle and/or its affiliates.
74 /
146
Copyright @ 2020 Oracle and/or its affiliates.
75 /
146
Copyright @ 2020 Oracle and/or its affiliates.
76 /
146
Let's make a query
Copyright @ 2020 Oracle and/or its affiliates.
77 /
146
Let's make a query
That's too much records to show in here... let's limit it
Copyright @ 2020 Oracle and/or its affiliates.
78 /
146
Copyright @ 2020 Oracle and/or its affiliates.
79 /
146
Some more examples
Copyright @ 2020 Oracle and/or its affiliates.
80 /
146
Let's add a selection criteria:
Copyright @ 2020 Oracle and/or its affiliates.
81 /
146
Syntax slightly different than MongoDB
Copyright @ 2020 Oracle and/or its affiliates.
82 /
146
Syntax slightly different than MongoDB
Copyright @ 2020 Oracle and/or its affiliates.
83 /
146
And for developers ?
Copyright @ 2020 Oracle and/or its affiliates.
84 /
146
And for developers ?
$session = mysql_xdevapigetSession("mysqlx://fred:MyP@ssw0rd%@localhost");
$schema = $session->getSchema("docstore");
$collection = $schema->getCollection("restaurants");
$results = $collection-> nd($search)->execute()->fetchAll();
...
foreach ($results as $doc) {
echo "<tr><td><a href='?id=${doc[_id]}'>${doc[name]}</a></td>";
echo "<td>${doc[borough]}</td><td>${doc[cuisine]}</td></tr>";
}
Copyright @ 2020 Oracle and/or its affiliates.
85 /
146
And for developers ?
$session = mysql_xdevapigetSession("mysqlx://fred:MyP@ssw0rd%@localhost");
$schema = $session->getSchema("docstore");
$collection = $schema->getCollection("restaurants");
$results = $collection-> nd($search)->execute()->fetchAll();
...
foreach ($results as $doc) {
echo "<tr><td><a href='?id=${doc[_id]}'>${doc[name]}</a></td>";
echo "<td>${doc[borough]}</td><td>${doc[cuisine]}</td></tr>";
}
 
Easy, using only CRUD operations !
Copyright @ 2020 Oracle and/or its affiliates.
86 /
146
And for developers ?
$session = mysql_xdevapigetSession("mysqlx://fred:MyP@ssw0rd%@localhost");
$schema = $session->getSchema("docstore");
$collection = $schema->getCollection("restaurants");
$results = $collection-> nd($search)->execute()->fetchAll();
...
foreach ($results as $doc) {
echo "<tr><td><a href='?id=${doc[_id]}'>${doc[name]}</a></td>";
echo "<td>${doc[borough]}</td><td>${doc[cuisine]}</td></tr>";
}
 
Easy, using only CRUD operations !
Not a single SQL statement !
Copyright @ 2020 Oracle and/or its affiliates.
87 /
146
CRUD operations
Copyright @ 2020 Oracle and/or its affiliates.
88 /
146
CRUD operations for collections
Add a document
collection.add({ name: 'fred', age: 42 })
.add({ name: 'dave', age: 23 })
.execute()
collection.add([
{ name: 'dimo', age: 50 },
{ name: 'kenny', age: 25 }
]).execute()
Copyright @ 2020 Oracle and/or its affiliates.
89 /
146
CRUD operations for collections
Modify a document
collection.modify('name = :name')
.bind('name', 'fred')
.set('age', 43)
.sort('name ASC')
.limit(1)
.execute()
collection.modify('name = :name')
.bind('name', 'fred')
.patch({ age: 43, active: false })
.sort('name DESC')
.limit(1)
.execute()
Copyright @ 2020 Oracle and/or its affiliates.
90 /
146
CRUD operations for collections
Remove a document
collection.remove('name = :name')
.bind('name', 'fred')
.sort('age ASC')
.limit(1)
.execute()
Copyright @ 2020 Oracle and/or its affiliates.
91 /
146
MySQL Document Store Objects Summary
Copyright @ 2020 Oracle and/or its affiliates.
92 /
146
All you need to know is here:
h ps://dev.mysql.com/doc/x-devapi-userguide/en/crud-operations-overview.html
Copyright @ 2020 Oracle and/or its affiliates.
93 /
146
we do care about your data
MySQL Document Store is Full ACID Compliant
Copyright @ 2020 Oracle and/or its affiliates.
94 /
146
Document Store Full ACID !
It relies on the proven MySQL InnoDB's strength & robustness:
Copyright @ 2020 Oracle and/or its affiliates.
95 /
146
Document Store Full ACID !
It relies on the proven MySQL InnoDB's strength & robustness:
innodb_ ush_log_at_trx_commit = 1
Copyright @ 2020 Oracle and/or its affiliates.
96 /
146
Document Store Full ACID !
It relies on the proven MySQL InnoDB's strength & robustness:
innodb_ ush_log_at_trx_commit = 1
innodb_doublewrite = ON
Copyright @ 2020 Oracle and/or its affiliates.
97 /
146
Document Store Full ACID !
It relies on the proven MySQL InnoDB's strength & robustness:
innodb_ ush_log_at_trx_commit = 1
innodb_doublewrite = ON
sync_binlog = 1
Copyright @ 2020 Oracle and/or its affiliates.
98 /
146
Document Store Full ACID !
It relies on the proven MySQL InnoDB's strength & robustness:
innodb_ ush_log_at_trx_commit = 1
innodb_doublewrite = ON
sync_binlog = 1
transaction_isolation = REPEATABLE-READ|READ-COMMITTED|...
Copyright @ 2020 Oracle and/or its affiliates.
99 /
146
Document Store Full ACID !
It relies on the proven MySQL InnoDB's strength & robustness:
innodb_ ush_log_at_trx_commit = 1
innodb_doublewrite = ON
sync_binlog = 1
transaction_isolation = REPEATABLE-READ|READ-COMMITTED|...
We do care about your data !
Copyright @ 2020 Oracle and/or its affiliates.
100 /
146
Full ACID - Transactions support
Copyright @ 2020 Oracle and/or its affiliates.
101 /
146
Full ACID - Transactions support
Copyright @ 2020 Oracle and/or its affiliates.
102 /
146
OK we have Document Store, CRUD and ACID
but what makes MySQL Document Store unique ?
Copyright @ 2020 Oracle and/or its affiliates.
103 /
146
Challenge: list the best restaurant of each type
of food and show the top 10, with the best one
first !
 
don't forget that all these restaurants are just JSON documents
Copyright @ 2020 Oracle and/or its affiliates.
104 /
146
NoSQL as SQL - aggregation
Copyright @ 2020 Oracle and/or its affiliates.
105 /
146
NoSQL as SQL - aggregation
Copyright @ 2020 Oracle and/or its affiliates.
106 /
146
NoSQL as SQL - aggregation
Copyright @ 2020 Oracle and/or its affiliates.
107 /
146
NoSQL as SQL - aggregation
Copyright @ 2020 Oracle and/or its affiliates.
108 /
146
NoSQL or SQL
You have the possibility to write clean and neat code:
Copyright @ 2020 Oracle and/or its affiliates.
109 /
146
NoSQL or SQL
You have the possibility to write clean and neat code:
$results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll();
Copyright @ 2020 Oracle and/or its affiliates.
110 /
146
NoSQL or SQL
You have the possibility to write clean and neat code:
$results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll();
Or use SQL only when it's really needed:
Copyright @ 2020 Oracle and/or its affiliates.
111 /
146
NoSQL or SQL
You have the possibility to write clean and neat code:
$results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll();
Or use SQL only when it's really needed:
$results = $session->sql('WITH cte1 AS (SELECT doc->>"$.name" AS name,
doc->>"$.cuisine" AS cuisine,
(SELECT AVG(score) FROM JSON_TABLE(doc, "$.grades[*]" COLUMNS (score INT
PATH "$.score")) AS r) AS avg_score FROM docstore.restaurants)
SELECT *, RANK()
OVER ( PARTITION BY cuisine ORDER BY avg_score) AS `rank`
FROM cte1 ORDER BY `rank`, avg_score DESC LIMIT 10;')->execute();
Copyright @ 2020 Oracle and/or its affiliates.
112 /
146
NoSQL or SQL
You have the possibility to write clean and neat code:
$results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll();
Or use SQL only when it's really needed:
$results = $session->sql('WITH cte1 AS (SELECT doc->>"$.name" AS name,
doc->>"$.cuisine" AS cuisine,
(SELECT AVG(score) FROM JSON_TABLE(doc, "$.grades[*]" COLUMNS (score INT
PATH "$.score")) AS r) AS avg_score FROM docstore.restaurants)
SELECT *, RANK()
OVER ( PARTITION BY cuisine ORDER BY avg_score) AS `rank`
FROM cte1 ORDER BY `rank`, avg_score DESC LIMIT 10;')->execute();
All in the same MySQL X Session !
Copyright @ 2020 Oracle and/or its affiliates.
113 /
146
You can mix NoSQL & SQL as you want
Copyright @ 2020 Oracle and/or its affiliates.
114 /
146
Best of Both Worlds: JSON_TABLE
What are the maximum 10 ratings ever given to a restaurant?
Copyright @ 2020 Oracle and/or its affiliates.
115 /
146
Best of Both Worlds: JSON_TABLE
What are the maximum 10 ratings ever given to a restaurant?
Cool... but my app only processes JSON !
Copyright @ 2020 Oracle and/or its affiliates.
116 /
146
Best of Both Worlds: JSON_TABLE (2)
With JSON output:
Copyright @ 2020 Oracle and/or its affiliates.
117 /
146
MySQL Document Store
And the DBA ?
Copyright @ 2020 Oracle and/or its affiliates.
118 /
146
Role of the MySQL Document Store DBA ?
Copyright @ 2020 Oracle and/or its affiliates.
119 /
146
nd the non optimal lookups
create the necessary indexes based on
the results
 
Role of the MySQL Document Store DBA ?
Copyright @ 2020 Oracle and/or its affiliates.
120 /
146
Role of the MySQL Document Store DBA
Looking for full table scans:
SELECT schema_name, sum_rows_examined, (sum_rows_examined/exec_count) avg_rows_call,
format_time(total_latency) tot_lat, exec_count,
format_time(total_latency/exec_count) AS latency_per_call, query_sample_text
FROM sys.x$statements_with_full_table_scans AS t1
JOIN performance_schema.events_statements_summary_by_digest AS t2
ON t2.digest=t1.digest
WHERE schema_name = "docstore" AND query_sample_text LIKE '%select%'
ORDER BY (total_latency/exec_count) descG
Copyright @ 2020 Oracle and/or its affiliates.
121 /
146
Role of the MySQL Document Store DBA
Looking for full table scans:
SELECT schema_name, sum_rows_examined, (sum_rows_examined/exec_count) avg_rows_call,
format_time(total_latency) tot_lat, exec_count,
format_time(total_latency/exec_count) AS latency_per_call, query_sample_text
FROM sys.x$statements_with_full_table_scans AS t1
JOIN performance_schema.events_statements_summary_by_digest AS t2
ON t2.digest=t1.digest
WHERE schema_name = "docstore" AND query_sample_text LIKE '%select%'
ORDER BY (total_latency/exec_count) descG
More info at h ps://lefred.be/content/mysql-8-0-if-i-should-optimize-only-one-query-
on-my-application-which-one-should-it-be/
Copyright @ 2020 Oracle and/or its affiliates.
122 /
146
Role of the MySQL Document Store DBA (2)
Copyright @ 2020 Oracle and/or its affiliates.
123 /
146
Role of the MySQL Document Store DBA (3)
Getting the Query Explain Plan:
Copyright @ 2020 Oracle and/or its affiliates.
124 /
146
Role of the MySQL Document Store DBA (3)
Getting the Query Explain Plan:
It's indeed a full table scan !
Copyright @ 2020 Oracle and/or its affiliates.
125 /
146
Role of the MySQL Document Store DBA (4)
MySQL supports also EXPLAIN ANALYZE !!
Copyright @ 2020 Oracle and/or its affiliates.
126 /
146
Role of the MySQL Document Store DBA (5)
Create Indexes:
Copyright @ 2020 Oracle and/or its affiliates.
127 /
146
Role of the MySQL Document Store DBA (5)
Create Indexes:
For the "old" experienced MySQL DBAs, you can instead use:
Copyright @ 2020 Oracle and/or its affiliates.
128 /
146
INFO: JSON Notation Shortcut
Copyright @ 2020 Oracle and/or its affiliates.
129 /
146
Role of the MySQL Document Store DBA (6)
Result:
Copyright @ 2020 Oracle and/or its affiliates.
130 /
146
For the curious: a collection in SQL:
Copyright @ 2020 Oracle and/or its affiliates.
131 /
146
Since MySQL 8.0.17
JSON Array Indexes
JSON Schema
JSON_SCHEMA_VALID(<json schema>,<json doc>)
JSON_SCHEMA_VALIDATION_REPORT(<json schema>,<json doc>)
Copyright @ 2020 Oracle and/or its affiliates.
132 /
146
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 (...)
JSON Array Indexes
Copyright @ 2020 Oracle and/or its affiliates.
133 /
146
JSON Array Indexes
Copyright @ 2020 Oracle and/or its affiliates.
134 /
146
JSON Array Indexes (2)
Copyright @ 2020 Oracle and/or its affiliates.
135 /
146
CHECK CONSTRAINTS
MySQL 8.0 supports Check Constraints:
Copyright @ 2020 Oracle and/or its affiliates.
136 /
146
JSON Schema Validation
Copyright @ 2020 Oracle and/or its affiliates.
137 /
146
JSON Schema Validation (2)
Copyright @ 2020 Oracle and/or its affiliates.
138 /
146
JSON Schema Validation (3)
And the best of both worlds:
Copyright @ 2020 Oracle and/or its affiliates.
139 /
146
JSON Schema Validation (3)
And the best of both worlds:
And the result in action:
Copyright @ 2020 Oracle and/or its affiliates.
140 /
146
JSON Schema Validation (3)
And the best of both worlds:
And the result in action:
Copyright @ 2020 Oracle and/or its affiliates.
141 /
146
what do I gain ?
Conclusion
Copyright @ 2020 Oracle and/or its affiliates.
142 /
146
schemaless
exible data structure
easy to start (CRUD)
Conclusion
This is the best of the two worlds in one product !
Data integrity
ACID Compliant
Transactions
SQL
Copyright @ 2020 Oracle and/or its affiliates.
143 /
146
8.0
http://lefred.be/content/top-10-reasons-for-
nosql-with-mysql/
Copyright @ 2020 Oracle and/or its affiliates.
144 /
146
145 /
146
Q & A
Copyright @ 2020 Oracle and/or its affiliates.
146 /
146

Contenu connexe

Tendances

Tendances (20)

MySQL Group Replication: Handling Network Glitches - Best Practices
MySQL Group Replication: Handling Network Glitches - Best PracticesMySQL Group Replication: Handling Network Glitches - Best Practices
MySQL Group Replication: Handling Network Glitches - Best Practices
 
State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20
State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20
State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20
 
MySQL Database Service Webinar - Installing WordPress in OCI with MDS
MySQL Database Service Webinar - Installing WordPress in OCI with MDSMySQL Database Service Webinar - Installing WordPress in OCI with MDS
MySQL Database Service Webinar - Installing WordPress in OCI with MDS
 
MySQL Shell - the best DBA tool !
MySQL Shell - the best DBA tool !MySQL Shell - the best DBA tool !
MySQL Shell - the best DBA tool !
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & Operations
 
MySQL Day Virtual: Best Practices Tips - Upgrading to MySQL 8.0
MySQL Day Virtual: Best Practices Tips - Upgrading to MySQL 8.0MySQL Day Virtual: Best Practices Tips - Upgrading to MySQL 8.0
MySQL Day Virtual: Best Practices Tips - Upgrading to MySQL 8.0
 
UAE MySQL Users Group Meet-up : MySQL Shell Document Store & more...
UAE MySQL Users Group Meet-up : MySQL Shell Document Store & more...UAE MySQL Users Group Meet-up : MySQL Shell Document Store & more...
UAE MySQL Users Group Meet-up : MySQL Shell Document Store & more...
 
Another MySQL HA Solution for ProxySQL Users, Easy and All Integrated: MySQL ...
Another MySQL HA Solution for ProxySQL Users, Easy and All Integrated: MySQL ...Another MySQL HA Solution for ProxySQL Users, Easy and All Integrated: MySQL ...
Another MySQL HA Solution for ProxySQL Users, Easy and All Integrated: MySQL ...
 
MySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python DevelopersMySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python Developers
 
preFOSDEM MySQL Day - Best Practices to Upgrade to MySQL 8.0
preFOSDEM MySQL Day - Best Practices to Upgrade to MySQL 8.0preFOSDEM MySQL Day - Best Practices to Upgrade to MySQL 8.0
preFOSDEM MySQL Day - Best Practices to Upgrade to MySQL 8.0
 
Hash join in MySQL 8
Hash join in MySQL 8Hash join in MySQL 8
Hash join in MySQL 8
 
MySQL : State of the Dolphin May 2019
MySQL : State of the Dolphin May 2019MySQL : State of the Dolphin May 2019
MySQL : State of the Dolphin May 2019
 
MySQL InnoDB Cluster and Group Replication in a nutshell hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a nutshell  hands-on tutorialMySQL InnoDB Cluster and Group Replication in a nutshell  hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a nutshell hands-on tutorial
 
the State of the Dolphin - October 2020
the State of the Dolphin - October 2020the State of the Dolphin - October 2020
the State of the Dolphin - October 2020
 
Oracle Open World 2018 / Code One : MySQL 8.0 Document Store
Oracle Open World 2018 /  Code One : MySQL 8.0 Document StoreOracle Open World 2018 /  Code One : MySQL 8.0 Document Store
Oracle Open World 2018 / Code One : MySQL 8.0 Document Store
 
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native -  Why to use MySQL 8.0 and how to use it on oci with MDSCloud native -  Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
 
MySQL Innovation Day Chicago - MySQL HA So Easy : That's insane !!
MySQL Innovation Day Chicago  - MySQL HA So Easy : That's insane !!MySQL Innovation Day Chicago  - MySQL HA So Easy : That's insane !!
MySQL Innovation Day Chicago - MySQL HA So Easy : That's insane !!
 
Oracle Developer Live: Deploying MySQL InnoDB Cluster on OCI with Terraform
Oracle Developer Live: Deploying MySQL InnoDB Cluster on OCI with TerraformOracle Developer Live: Deploying MySQL InnoDB Cluster on OCI with Terraform
Oracle Developer Live: Deploying MySQL InnoDB Cluster on OCI with Terraform
 
MySQL Shell : the best DBA tool ?
MySQL Shell : the best DBA tool ?MySQL Shell : the best DBA tool ?
MySQL Shell : the best DBA tool ?
 
MySQL 8.0 Document Store - how to mix NoSQL & SQL in MySQL 8.0
MySQL 8.0 Document Store - how to mix NoSQL & SQL in MySQL 8.0MySQL 8.0 Document Store - how to mix NoSQL & SQL in MySQL 8.0
MySQL 8.0 Document Store - how to mix NoSQL & SQL in MySQL 8.0
 

Similaire à OpenExpo Virtual Experience 2020: MySQL 8.0 Document Store - Discovery of a new world

Similaire à OpenExpo Virtual Experience 2020: MySQL 8.0 Document Store - Discovery of a new world (20)

MySQL 8.0 Document Store - Discovery of a New World
MySQL 8.0 Document Store - Discovery of a New WorldMySQL 8.0 Document Store - Discovery of a New World
MySQL 8.0 Document Store - Discovery of a New World
 
Oracle Code Roma: NoSQL + SQL = MySQL
Oracle Code Roma:   NoSQL + SQL = MySQLOracle Code Roma:   NoSQL + SQL = MySQL
Oracle Code Roma: NoSQL + SQL = MySQL
 
MySQL User Group NL: MySQL 8.0 Document Store- NoSQL with all the benefits of...
MySQL User Group NL: MySQL 8.0 Document Store- NoSQL with all the benefits of...MySQL User Group NL: MySQL 8.0 Document Store- NoSQL with all the benefits of...
MySQL User Group NL: MySQL 8.0 Document Store- NoSQL with all the benefits of...
 
pre-FOSDEM MySQL day, February 2018 - MySQL Document Store
pre-FOSDEM MySQL day, February 2018 - MySQL Document Storepre-FOSDEM MySQL day, February 2018 - MySQL Document Store
pre-FOSDEM MySQL day, February 2018 - MySQL Document Store
 
DataOps barcelona - MySQL 8.0 document store: NoSQL with all the benefits of ...
DataOps barcelona - MySQL 8.0 document store: NoSQL with all the benefits of ...DataOps barcelona - MySQL 8.0 document store: NoSQL with all the benefits of ...
DataOps barcelona - MySQL 8.0 document store: NoSQL with all the benefits of ...
 
MySQL Document Store - How to replace a NoSQL database by MySQL without effor...
MySQL Document Store - How to replace a NoSQL database by MySQL without effor...MySQL Document Store - How to replace a NoSQL database by MySQL without effor...
MySQL Document Store - How to replace a NoSQL database by MySQL without effor...
 
A Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document StoreA Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document Store
 
Why Use an Oracle Database?
Why Use an Oracle Database?Why Use an Oracle Database?
Why Use an Oracle Database?
 
SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP
 
Introduction to MySQL Document Store
Introduction to MySQL Document StoreIntroduction to MySQL Document Store
Introduction to MySQL Document Store
 
はじめてのOracle Cloud Infrastructure(Oracle Cloudウェビナーシリーズ: 2020年6月24日)
はじめてのOracle Cloud Infrastructure(Oracle Cloudウェビナーシリーズ: 2020年6月24日)はじめてのOracle Cloud Infrastructure(Oracle Cloudウェビナーシリーズ: 2020年6月24日)
はじめてのOracle Cloud Infrastructure(Oracle Cloudウェビナーシリーズ: 2020年6月24日)
 
Oracle Database House Party_Oracle Machine Learning to Pick a Good Inexpensiv...
Oracle Database House Party_Oracle Machine Learning to Pick a Good Inexpensiv...Oracle Database House Party_Oracle Machine Learning to Pick a Good Inexpensiv...
Oracle Database House Party_Oracle Machine Learning to Pick a Good Inexpensiv...
 
#dbhouseparty - Using Oracle’s Converged “AI” Database to Pick a Good but Ine...
#dbhouseparty - Using Oracle’s Converged “AI” Database to Pick a Good but Ine...#dbhouseparty - Using Oracle’s Converged “AI” Database to Pick a Good but Ine...
#dbhouseparty - Using Oracle’s Converged “AI” Database to Pick a Good but Ine...
 
Marcin Szałowicz - MySQL Workbench
Marcin Szałowicz - MySQL WorkbenchMarcin Szałowicz - MySQL Workbench
Marcin Szałowicz - MySQL Workbench
 
Oracle database 12c_and_DevOps
Oracle database 12c_and_DevOpsOracle database 12c_and_DevOps
Oracle database 12c_and_DevOps
 
Oracle NoSQL
Oracle NoSQLOracle NoSQL
Oracle NoSQL
 
Database Basics with PHP -- Connect JS Conference October 17th, 2015
Database Basics with PHP -- Connect JS Conference October 17th, 2015Database Basics with PHP -- Connect JS Conference October 17th, 2015
Database Basics with PHP -- Connect JS Conference October 17th, 2015
 
RMOUG MySQL 5.7 New Features
RMOUG MySQL 5.7 New FeaturesRMOUG MySQL 5.7 New Features
RMOUG MySQL 5.7 New Features
 
MySQL Document Store - A Document Store with all the benefts of a Transactona...
MySQL Document Store - A Document Store with all the benefts of a Transactona...MySQL Document Store - A Document Store with all the benefts of a Transactona...
MySQL Document Store - A Document Store with all the benefts of a Transactona...
 
OUG Scotland 2014 - NoSQL and MySQL - The best of both worlds
OUG Scotland 2014 - NoSQL and MySQL - The best of both worldsOUG Scotland 2014 - NoSQL and MySQL - The best of both worlds
OUG Scotland 2014 - NoSQL and MySQL - The best of both worlds
 

Plus de Frederic Descamps

Plus de Frederic Descamps (20)

MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
 
RivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsRivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and Histograms
 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
 
MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8
 
State of the Dolphin - May 2022
State of the Dolphin - May 2022State of the Dolphin - May 2022
State of the Dolphin - May 2022
 
Percona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodePercona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio Code
 
Percona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database SystemPercona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database System
 
Percona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesPercona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL Architectures
 
LinuxFest Northwest 2022 - The Evolution of a MySQL Database System
LinuxFest Northwest 2022 - The Evolution of a MySQL Database SystemLinuxFest Northwest 2022 - The Evolution of a MySQL Database System
LinuxFest Northwest 2022 - The Evolution of a MySQL Database System
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
 
Pi Day 2022 - from IoT to MySQL HeatWave Database Service
Pi Day 2022 -  from IoT to MySQL HeatWave Database ServicePi Day 2022 -  from IoT to MySQL HeatWave Database Service
Pi Day 2022 - from IoT to MySQL HeatWave Database Service
 
Confoo 2022 - le cycle d'une instance MySQL
Confoo 2022  - le cycle d'une instance MySQLConfoo 2022  - le cycle d'une instance MySQL
Confoo 2022 - le cycle d'une instance MySQL
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021
 
MySQL Shell for DBAs
MySQL Shell for DBAsMySQL Shell for DBAs
MySQL Shell for DBAs
 
Deploying Magento on OCI with MDS
Deploying Magento on OCI with MDSDeploying Magento on OCI with MDS
Deploying Magento on OCI with MDS
 
MySQL Router REST API
MySQL Router REST APIMySQL Router REST API
MySQL Router REST API
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

OpenExpo Virtual Experience 2020: MySQL 8.0 Document Store - Discovery of a new world

  • 2. Frédéric Descamps Community Manager MySQL June 2020 MySQL 8.0 Document Store discovery of a new world 2 / 146
  • 3.   Safe Harbor The following is intended to outline our general product direction. It is intended for information purpose 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 up in making purchasing decisions. The development, release, timing and pricing of any features or functionality described for Oracle´s product may change and remains at the sole discretion of Oracle Corporation. Statement in this presentation relating to Oracle´s future plans, expectations, beliefs, intentions and ptospects are "forward-looking statements" and are subject to material risks and uncertainties. A detailed discussion of these factors and other risks that a ect our business is contained in Oracle´s Securities and Exchange Commission (SEC) lings, including our most recent reports on Form 10-K and Form 10-Q under the heading "Risk Factors". These lings are available on the SEC´s website or on Oracle´s website at h p://www.oracle.com/investor. All information in this presentation is current as of September 2019 and Oracle undertakes no duty to update any statement in light of new information or future events. Copyright @ 2020 Oracle and/or its affiliates. 3 / 146
  • 4. about.me/lefred Who am I ? Copyright @ 2020 Oracle and/or its affiliates. 4 / 146
  • 5. Frédéric Descamps @lefred MySQL Evangelist Managing MySQL since 3.20 ! devops believer living in Belgium 🇧🇪 h ps://lefred.be Copyright @ 2020 Oracle and/or its affiliates. 5 / 146
  • 6. #MySQl8isGreat MySQL Copyright @ 2020 Oracle and/or its affiliates. 6 / 146
  • 7. DB-Engines 2020 Database Ranking Copyright @ 2020 Oracle and/or its affiliates. 7 / 146
  • 8. DB-Engines 2020 Database Ranking MySQL is the most popular Open Source database Copyright @ 2020 Oracle and/or its affiliates. 8 / 146
  • 9. MySQL is the DBMS of the Year 2019 ! Copyright @ 2020 Oracle and/or its affiliates. 9 / 146
  • 10. Happy 25th Anniversary MySQL Copyright @ 2020 Oracle and/or its affiliates. 10 / 146
  • 11. from LAMP stack to modern Web applications Evolution... Copyright @ 2020 Oracle and/or its affiliates. 11 / 146
  • 12. Web Applications 2000's Who ? Copyright @ 2020 Oracle and/or its affiliates. 12 / 146
  • 13. Web Applications 2000's Who ? Copyright @ 2020 Oracle and/or its affiliates. 13 / 146
  • 14. Web Applications 2000's How ? Copyright @ 2020 Oracle and/or its affiliates. 14 / 146
  • 15. Web Applications 2000's How ? Copyright @ 2020 Oracle and/or its affiliates. 15 / 146
  • 16. Relational Databases Data Integrity Copyright @ 2020 Oracle and/or its affiliates. 16 / 146
  • 17. Relational Databases Data Integrity normalization Copyright @ 2020 Oracle and/or its affiliates. 17 / 146
  • 18. Relational Databases Data Integrity normalization constraints (foreign keys, ...) Copyright @ 2020 Oracle and/or its affiliates. 18 / 146
  • 19. Relational Databases Data Integrity normalization constraints (foreign keys, ...) Atomicity, Consistency, Isolation, Durability Copyright @ 2020 Oracle and/or its affiliates. 19 / 146
  • 20. Relational Databases Data Integrity normalization constraints (foreign keys, ...) Atomicity, Consistency, Isolation, Durability ACID compliant Copyright @ 2020 Oracle and/or its affiliates. 20 / 146
  • 21. Relational Databases Data Integrity normalization constraints (foreign keys, ...) Atomicity, Consistency, Isolation, Durability ACID compliant transactions Copyright @ 2020 Oracle and/or its affiliates. 21 / 146
  • 22. Relational Databases Data Integrity normalization constraints (foreign keys, ...) Atomicity, Consistency, Isolation, Durability ACID compliant transactions SQL Copyright @ 2020 Oracle and/or its affiliates. 22 / 146
  • 23. Relational Databases Data Integrity normalization constraints (foreign keys, ...) Atomicity, Consistency, Isolation, Durability ACID compliant transactions SQL powerfull query language Copyright @ 2020 Oracle and/or its affiliates. 23 / 146
  • 24. Web Applications current days Who ? Copyright @ 2020 Oracle and/or its affiliates. 24 / 146
  • 25. Web Applications current days Who ? Copyright @ 2020 Oracle and/or its affiliates. 25 / 146
  • 26. Web Applications current days How ? Copyright @ 2020 Oracle and/or its affiliates. 26 / 146
  • 27. Web Applications current days Why ? Copyright @ 2020 Oracle and/or its affiliates. 27 / 146
  • 28. Web Applications current days Why ? Developers don't really like SQL anymore...   Copyright @ 2020 Oracle and/or its affiliates. 28 / 146
  • 29. SQL can be complicated and slows down the initial development Web Applications current days Why ? Copyright @ 2020 Oracle and/or its affiliates. 29 / 146
  • 30. Developers don't have time to learn SQL, they need time to workout and have a nice look ;-) Web Applications current days Why ? Copyright @ 2020 Oracle and/or its affiliates. 30 / 146
  • 31. easy operations What do developers want ? Copyright @ 2020 Oracle and/or its affiliates. 31 / 146
  • 32. Use Objects / Documents Developers want just to use objects Copyright @ 2020 Oracle and/or its affiliates. 32 / 146
  • 33. Use Objects / Documents Developers want just to use objects that's why they usually love what DBAs hate the most ORMs ! Copyright @ 2020 Oracle and/or its affiliates. 33 / 146
  • 34. Use Objects / Documents Developers want just to use objects that's why they usually love what DBAs hate the most ORMs ! They want to deal with these objects easily (CRUD operations) and they don't want to think about schema design (slows down the initial development process). Copyright @ 2020 Oracle and/or its affiliates. 34 / 146
  • 35. Use Objects / Documents Developers want just to use objects that's why they usually love what DBAs hate the most ORMs ! They want to deal with these objects easily (CRUD operations) and they don't want to think about schema design (slows down the initial development process). But they also want to keep their data safe and use transactions. Copyright @ 2020 Oracle and/or its affiliates. 35 / 146
  • 36. Web Applications current days How ? Copyright @ 2020 Oracle and/or its affiliates. 36 / 146
  • 37. Web Applications current days How ? Copyright @ 2020 Oracle and/or its affiliates. 37 / 146
  • 38. JSON Document Store NoSQL Databases Copyright @ 2020 Oracle and/or its affiliates. 38 / 146
  • 39. NoSQL Document Store Schemaless Copyright @ 2020 Oracle and/or its affiliates. 39 / 146
  • 40. NoSQL Document Store Schemaless no schema design, no normalization, no foreign keys, no data types, ... Copyright @ 2020 Oracle and/or its affiliates. 40 / 146
  • 41. NoSQL Document Store Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Copyright @ 2020 Oracle and/or its affiliates. 41 / 146
  • 42. NoSQL Document Store Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure Copyright @ 2020 Oracle and/or its affiliates. 42 / 146
  • 43. NoSQL Document Store Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects Copyright @ 2020 Oracle and/or its affiliates. 43 / 146
  • 44. NoSQL Document Store Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can't be modelized optimaly into a relational model Copyright @ 2020 Oracle and/or its affiliates. 44 / 146
  • 45. NoSQL Document Store Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can't be modelized optimaly into a relational model objects persistance without the use of any ORM - mapping oobject-oriented Copyright @ 2020 Oracle and/or its affiliates. 45 / 146
  • 46. NoSQL Document Store Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can't be modelized optimaly into a relational model objects persistance without the use of any ORM - mapping oobject-oriented JSON Copyright @ 2020 Oracle and/or its affiliates. 46 / 146
  • 47. NoSQL Document Store Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can't be modelized optimaly into a relational model objects persistance without the use of any ORM - mapping oobject-oriented JSON close to frontend Copyright @ 2020 Oracle and/or its affiliates. 47 / 146
  • 48. NoSQL Document Store Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can't be modelized optimaly into a relational model objects persistance without the use of any ORM - mapping oobject-oriented JSON close to frontend easy to learn Copyright @ 2020 Oracle and/or its affiliates. 48 / 146
  • 49. How DBAs see data Copyright @ 2020 Oracle and/or its affiliates. 49 / 146
  • 50. How DBAs see data How Developers see data { "GNP" : 249704, "Name" : "Belgium", "government" : { "GovernmentForm" : "Constitutional Monarchy, Federation", "HeadOfState" : "Philippe I" }, "_id" : "BEL", "IndepYear" : 1830, "demographics" : { "Population" : 10239000, "LifeExpectancy" : 77.8000030517578 }, "geography" : { "Region" : "Western Europe", "SurfaceArea" : 30518, "Continent" : "Europe" } } Copyright @ 2020 Oracle and/or its affiliates. 50 / 146
  • 51. And they still need to do Analytics SQL SQL SQL Copyright @ 2020 Oracle and/or its affiliates. 51 / 146
  • 52. ... mmm...how ? ? SQL SQL SQL Copyright @ 2020 Oracle and/or its affiliates. 52 / 146
  • 53. Help needed ! Who ? Copyright @ 2020 Oracle and/or its affiliates. 53 / 146
  • 54. Help needed ! Who ? Copyright @ 2020 Oracle and/or its affiliates. 54 / 146
  • 55. How ? SQL SQL SQL Copyright @ 2020 Oracle and/or its affiliates. 55 / 146
  • 56. What if there was a way to provide both SQL and NoSQL on one stable platform that has proven stability on well know technology with a large Community and a diverse ecosystem ? Copyright @ 2020 Oracle and/or its affiliates. 56 / 146
  • 57. DBMS or NoSQL ? Copyright @ 2020 Oracle and/or its affiliates. 57 / 146
  • 58. DBMS or NoSQL ? Why not both ? Copyright @ 2020 Oracle and/or its affiliates. 58 / 146
  • 59. The MySQL Document Store ! SQL is now optional ?! Copyright @ 2020 Oracle and/or its affiliates. 59 / 146
  • 60. SQL is now optional ?! Copyright @ 2020 Oracle and/or its affiliates. 60 / 146
  • 61. Using MySQL Document Store ! SQL SQL SQL Copyright @ 2020 Oracle and/or its affiliates. 61 / 146
  • 62. Developers: [x] schemaless [x] rapid prototying/simpler APIs [x] document model [x] transactions Operations: [x] performance management/visibility [x] robust replication, backup, restore [x] comprehensive tooling ecosystem [x] simpler application schema upgrades Business Owner: [x] don't lose my data == ACID trx [x] capture all my data = extensible/schemaless [x] product on schedule/time to market = rapid developement A solution for all Copyright @ 2020 Oracle and/or its affiliates. 62 / 146
  • 63. MySQL Document Store the Solution Copyright @ 2020 Oracle and/or its affiliates. 63 / 146
  • 64. Built on the MySQL JSON Data type and Proven MySQL Server Technology Provides a schema exible JSON Document Store No SQL required No need to de ne all possible a ributes, tables, etc. Uses new X DevAPI Can leverage generated column to extract JSON values into materialized columns that can be indexed for fast SQL searches. Document can be ~1GB It's a column in a row of a table It cannot exceed max_allowed_packet Allows use of modern programming styles No more embedded strings of SQL in your code Easy to read Also works with relational Tables Proven MySQL Technology Copyright @ 2020 Oracle and/or its affiliates. 64 / 146
  • 65. X Protocol Connectors Copyright @ 2020 Oracle and/or its affiliates. 65 / 146
  • 66. X DevAPI We provide connectors for C++, Java, .Net, Node.js, Python, PHP working with Communities to help them supporting it too New MySQL Shell Command Completion Python, JavaScrips & SQL modes Admin functions New Util object A new high-level session concept that can scale from single .mysql-blue[My].mysql-orange[SQL] Server to a multiple server environment Non-blocking, asynchronous calls follow common language pa erns Supports CRUD operations Copyright @ 2020 Oracle and/or its affiliates. 66 / 146
  • 67. MySQL Document Store Setup Copyright @ 2020 Oracle and/or its affiliates. 67 / 146
  • 68. Installing MySQL Document Store install MySQL 8.0 Copyright @ 2020 Oracle and/or its affiliates. 68 / 146
  • 69. Installing MySQL Document Store install MySQL 8.0 install MySQL Shell Copyright @ 2020 Oracle and/or its affiliates. 69 / 146
  • 70. Installing MySQL Document Store install MySQL 8.0 install MySQL Shell install MySQL Connector for your programming language Copyright @ 2020 Oracle and/or its affiliates. 70 / 146
  • 71. Installing MySQL Document Store install MySQL 8.0 install MySQL Shell install MySQL Connector for your programming language php-pecl-mysql-xdevapi for PHP mysql-connector-python for Python ... Copyright @ 2020 Oracle and/or its affiliates. 71 / 146
  • 72. Installing MySQL Document Store install MySQL 8.0 install MySQL Shell install MySQL Connector for your programming language php-pecl-mysql-xdevapi for PHP mysql-connector-python for Python ... And nothing else, no need to install anything else or load any plugin, just be sure your rewall allows you to connect through port 33060 (X Protocol). Copyright @ 2020 Oracle and/or its affiliates. 72 / 146
  • 73. Migration from MongoDB to MySQL DS For this example, I will use the well known restaurants collection: Copyright @ 2020 Oracle and/or its affiliates. 73 / 146
  • 74. Migration from MongoDB to MySQL DS For this example, I will use the well known restaurants collection: Copyright @ 2020 Oracle and/or its affiliates. 74 / 146
  • 75. Copyright @ 2020 Oracle and/or its affiliates. 75 / 146
  • 76. Copyright @ 2020 Oracle and/or its affiliates. 76 / 146
  • 77. Let's make a query Copyright @ 2020 Oracle and/or its affiliates. 77 / 146
  • 78. Let's make a query That's too much records to show in here... let's limit it Copyright @ 2020 Oracle and/or its affiliates. 78 / 146
  • 79. Copyright @ 2020 Oracle and/or its affiliates. 79 / 146
  • 80. Some more examples Copyright @ 2020 Oracle and/or its affiliates. 80 / 146
  • 81. Let's add a selection criteria: Copyright @ 2020 Oracle and/or its affiliates. 81 / 146
  • 82. Syntax slightly different than MongoDB Copyright @ 2020 Oracle and/or its affiliates. 82 / 146
  • 83. Syntax slightly different than MongoDB Copyright @ 2020 Oracle and/or its affiliates. 83 / 146
  • 84. And for developers ? Copyright @ 2020 Oracle and/or its affiliates. 84 / 146
  • 85. And for developers ? $session = mysql_xdevapigetSession("mysqlx://fred:MyP@ssw0rd%@localhost"); $schema = $session->getSchema("docstore"); $collection = $schema->getCollection("restaurants"); $results = $collection-> nd($search)->execute()->fetchAll(); ... foreach ($results as $doc) { echo "<tr><td><a href='?id=${doc[_id]}'>${doc[name]}</a></td>"; echo "<td>${doc[borough]}</td><td>${doc[cuisine]}</td></tr>"; } Copyright @ 2020 Oracle and/or its affiliates. 85 / 146
  • 86. And for developers ? $session = mysql_xdevapigetSession("mysqlx://fred:MyP@ssw0rd%@localhost"); $schema = $session->getSchema("docstore"); $collection = $schema->getCollection("restaurants"); $results = $collection-> nd($search)->execute()->fetchAll(); ... foreach ($results as $doc) { echo "<tr><td><a href='?id=${doc[_id]}'>${doc[name]}</a></td>"; echo "<td>${doc[borough]}</td><td>${doc[cuisine]}</td></tr>"; }   Easy, using only CRUD operations ! Copyright @ 2020 Oracle and/or its affiliates. 86 / 146
  • 87. And for developers ? $session = mysql_xdevapigetSession("mysqlx://fred:MyP@ssw0rd%@localhost"); $schema = $session->getSchema("docstore"); $collection = $schema->getCollection("restaurants"); $results = $collection-> nd($search)->execute()->fetchAll(); ... foreach ($results as $doc) { echo "<tr><td><a href='?id=${doc[_id]}'>${doc[name]}</a></td>"; echo "<td>${doc[borough]}</td><td>${doc[cuisine]}</td></tr>"; }   Easy, using only CRUD operations ! Not a single SQL statement ! Copyright @ 2020 Oracle and/or its affiliates. 87 / 146
  • 88. CRUD operations Copyright @ 2020 Oracle and/or its affiliates. 88 / 146
  • 89. CRUD operations for collections Add a document collection.add({ name: 'fred', age: 42 }) .add({ name: 'dave', age: 23 }) .execute() collection.add([ { name: 'dimo', age: 50 }, { name: 'kenny', age: 25 } ]).execute() Copyright @ 2020 Oracle and/or its affiliates. 89 / 146
  • 90. CRUD operations for collections Modify a document collection.modify('name = :name') .bind('name', 'fred') .set('age', 43) .sort('name ASC') .limit(1) .execute() collection.modify('name = :name') .bind('name', 'fred') .patch({ age: 43, active: false }) .sort('name DESC') .limit(1) .execute() Copyright @ 2020 Oracle and/or its affiliates. 90 / 146
  • 91. CRUD operations for collections Remove a document collection.remove('name = :name') .bind('name', 'fred') .sort('age ASC') .limit(1) .execute() Copyright @ 2020 Oracle and/or its affiliates. 91 / 146
  • 92. MySQL Document Store Objects Summary Copyright @ 2020 Oracle and/or its affiliates. 92 / 146
  • 93. All you need to know is here: h ps://dev.mysql.com/doc/x-devapi-userguide/en/crud-operations-overview.html Copyright @ 2020 Oracle and/or its affiliates. 93 / 146
  • 94. we do care about your data MySQL Document Store is Full ACID Compliant Copyright @ 2020 Oracle and/or its affiliates. 94 / 146
  • 95. Document Store Full ACID ! It relies on the proven MySQL InnoDB's strength & robustness: Copyright @ 2020 Oracle and/or its affiliates. 95 / 146
  • 96. Document Store Full ACID ! It relies on the proven MySQL InnoDB's strength & robustness: innodb_ ush_log_at_trx_commit = 1 Copyright @ 2020 Oracle and/or its affiliates. 96 / 146
  • 97. Document Store Full ACID ! It relies on the proven MySQL InnoDB's strength & robustness: innodb_ ush_log_at_trx_commit = 1 innodb_doublewrite = ON Copyright @ 2020 Oracle and/or its affiliates. 97 / 146
  • 98. Document Store Full ACID ! It relies on the proven MySQL InnoDB's strength & robustness: innodb_ ush_log_at_trx_commit = 1 innodb_doublewrite = ON sync_binlog = 1 Copyright @ 2020 Oracle and/or its affiliates. 98 / 146
  • 99. Document Store Full ACID ! It relies on the proven MySQL InnoDB's strength & robustness: innodb_ ush_log_at_trx_commit = 1 innodb_doublewrite = ON sync_binlog = 1 transaction_isolation = REPEATABLE-READ|READ-COMMITTED|... Copyright @ 2020 Oracle and/or its affiliates. 99 / 146
  • 100. Document Store Full ACID ! It relies on the proven MySQL InnoDB's strength & robustness: innodb_ ush_log_at_trx_commit = 1 innodb_doublewrite = ON sync_binlog = 1 transaction_isolation = REPEATABLE-READ|READ-COMMITTED|... We do care about your data ! Copyright @ 2020 Oracle and/or its affiliates. 100 / 146
  • 101. Full ACID - Transactions support Copyright @ 2020 Oracle and/or its affiliates. 101 / 146
  • 102. Full ACID - Transactions support Copyright @ 2020 Oracle and/or its affiliates. 102 / 146
  • 103. OK we have Document Store, CRUD and ACID but what makes MySQL Document Store unique ? Copyright @ 2020 Oracle and/or its affiliates. 103 / 146
  • 104. Challenge: list the best restaurant of each type of food and show the top 10, with the best one first !   don't forget that all these restaurants are just JSON documents Copyright @ 2020 Oracle and/or its affiliates. 104 / 146
  • 105. NoSQL as SQL - aggregation Copyright @ 2020 Oracle and/or its affiliates. 105 / 146
  • 106. NoSQL as SQL - aggregation Copyright @ 2020 Oracle and/or its affiliates. 106 / 146
  • 107. NoSQL as SQL - aggregation Copyright @ 2020 Oracle and/or its affiliates. 107 / 146
  • 108. NoSQL as SQL - aggregation Copyright @ 2020 Oracle and/or its affiliates. 108 / 146
  • 109. NoSQL or SQL You have the possibility to write clean and neat code: Copyright @ 2020 Oracle and/or its affiliates. 109 / 146
  • 110. NoSQL or SQL You have the possibility to write clean and neat code: $results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll(); Copyright @ 2020 Oracle and/or its affiliates. 110 / 146
  • 111. NoSQL or SQL You have the possibility to write clean and neat code: $results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll(); Or use SQL only when it's really needed: Copyright @ 2020 Oracle and/or its affiliates. 111 / 146
  • 112. NoSQL or SQL You have the possibility to write clean and neat code: $results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll(); Or use SQL only when it's really needed: $results = $session->sql('WITH cte1 AS (SELECT doc->>"$.name" AS name, doc->>"$.cuisine" AS cuisine, (SELECT AVG(score) FROM JSON_TABLE(doc, "$.grades[*]" COLUMNS (score INT PATH "$.score")) AS r) AS avg_score FROM docstore.restaurants) SELECT *, RANK() OVER ( PARTITION BY cuisine ORDER BY avg_score) AS `rank` FROM cte1 ORDER BY `rank`, avg_score DESC LIMIT 10;')->execute(); Copyright @ 2020 Oracle and/or its affiliates. 112 / 146
  • 113. NoSQL or SQL You have the possibility to write clean and neat code: $results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll(); Or use SQL only when it's really needed: $results = $session->sql('WITH cte1 AS (SELECT doc->>"$.name" AS name, doc->>"$.cuisine" AS cuisine, (SELECT AVG(score) FROM JSON_TABLE(doc, "$.grades[*]" COLUMNS (score INT PATH "$.score")) AS r) AS avg_score FROM docstore.restaurants) SELECT *, RANK() OVER ( PARTITION BY cuisine ORDER BY avg_score) AS `rank` FROM cte1 ORDER BY `rank`, avg_score DESC LIMIT 10;')->execute(); All in the same MySQL X Session ! Copyright @ 2020 Oracle and/or its affiliates. 113 / 146
  • 114. You can mix NoSQL & SQL as you want Copyright @ 2020 Oracle and/or its affiliates. 114 / 146
  • 115. Best of Both Worlds: JSON_TABLE What are the maximum 10 ratings ever given to a restaurant? Copyright @ 2020 Oracle and/or its affiliates. 115 / 146
  • 116. Best of Both Worlds: JSON_TABLE What are the maximum 10 ratings ever given to a restaurant? Cool... but my app only processes JSON ! Copyright @ 2020 Oracle and/or its affiliates. 116 / 146
  • 117. Best of Both Worlds: JSON_TABLE (2) With JSON output: Copyright @ 2020 Oracle and/or its affiliates. 117 / 146
  • 118. MySQL Document Store And the DBA ? Copyright @ 2020 Oracle and/or its affiliates. 118 / 146
  • 119. Role of the MySQL Document Store DBA ? Copyright @ 2020 Oracle and/or its affiliates. 119 / 146
  • 120. nd the non optimal lookups create the necessary indexes based on the results   Role of the MySQL Document Store DBA ? Copyright @ 2020 Oracle and/or its affiliates. 120 / 146
  • 121. Role of the MySQL Document Store DBA Looking for full table scans: SELECT schema_name, sum_rows_examined, (sum_rows_examined/exec_count) avg_rows_call, format_time(total_latency) tot_lat, exec_count, format_time(total_latency/exec_count) AS latency_per_call, query_sample_text FROM sys.x$statements_with_full_table_scans AS t1 JOIN performance_schema.events_statements_summary_by_digest AS t2 ON t2.digest=t1.digest WHERE schema_name = "docstore" AND query_sample_text LIKE '%select%' ORDER BY (total_latency/exec_count) descG Copyright @ 2020 Oracle and/or its affiliates. 121 / 146
  • 122. Role of the MySQL Document Store DBA Looking for full table scans: SELECT schema_name, sum_rows_examined, (sum_rows_examined/exec_count) avg_rows_call, format_time(total_latency) tot_lat, exec_count, format_time(total_latency/exec_count) AS latency_per_call, query_sample_text FROM sys.x$statements_with_full_table_scans AS t1 JOIN performance_schema.events_statements_summary_by_digest AS t2 ON t2.digest=t1.digest WHERE schema_name = "docstore" AND query_sample_text LIKE '%select%' ORDER BY (total_latency/exec_count) descG More info at h ps://lefred.be/content/mysql-8-0-if-i-should-optimize-only-one-query- on-my-application-which-one-should-it-be/ Copyright @ 2020 Oracle and/or its affiliates. 122 / 146
  • 123. Role of the MySQL Document Store DBA (2) Copyright @ 2020 Oracle and/or its affiliates. 123 / 146
  • 124. Role of the MySQL Document Store DBA (3) Getting the Query Explain Plan: Copyright @ 2020 Oracle and/or its affiliates. 124 / 146
  • 125. Role of the MySQL Document Store DBA (3) Getting the Query Explain Plan: It's indeed a full table scan ! Copyright @ 2020 Oracle and/or its affiliates. 125 / 146
  • 126. Role of the MySQL Document Store DBA (4) MySQL supports also EXPLAIN ANALYZE !! Copyright @ 2020 Oracle and/or its affiliates. 126 / 146
  • 127. Role of the MySQL Document Store DBA (5) Create Indexes: Copyright @ 2020 Oracle and/or its affiliates. 127 / 146
  • 128. Role of the MySQL Document Store DBA (5) Create Indexes: For the "old" experienced MySQL DBAs, you can instead use: Copyright @ 2020 Oracle and/or its affiliates. 128 / 146
  • 129. INFO: JSON Notation Shortcut Copyright @ 2020 Oracle and/or its affiliates. 129 / 146
  • 130. Role of the MySQL Document Store DBA (6) Result: Copyright @ 2020 Oracle and/or its affiliates. 130 / 146
  • 131. For the curious: a collection in SQL: Copyright @ 2020 Oracle and/or its affiliates. 131 / 146
  • 132. Since MySQL 8.0.17 JSON Array Indexes JSON Schema JSON_SCHEMA_VALID(<json schema>,<json doc>) JSON_SCHEMA_VALIDATION_REPORT(<json schema>,<json doc>) Copyright @ 2020 Oracle and/or its affiliates. 132 / 146
  • 133. 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 (...) JSON Array Indexes Copyright @ 2020 Oracle and/or its affiliates. 133 / 146
  • 134. JSON Array Indexes Copyright @ 2020 Oracle and/or its affiliates. 134 / 146
  • 135. JSON Array Indexes (2) Copyright @ 2020 Oracle and/or its affiliates. 135 / 146
  • 136. CHECK CONSTRAINTS MySQL 8.0 supports Check Constraints: Copyright @ 2020 Oracle and/or its affiliates. 136 / 146
  • 137. JSON Schema Validation Copyright @ 2020 Oracle and/or its affiliates. 137 / 146
  • 138. JSON Schema Validation (2) Copyright @ 2020 Oracle and/or its affiliates. 138 / 146
  • 139. JSON Schema Validation (3) And the best of both worlds: Copyright @ 2020 Oracle and/or its affiliates. 139 / 146
  • 140. JSON Schema Validation (3) And the best of both worlds: And the result in action: Copyright @ 2020 Oracle and/or its affiliates. 140 / 146
  • 141. JSON Schema Validation (3) And the best of both worlds: And the result in action: Copyright @ 2020 Oracle and/or its affiliates. 141 / 146
  • 142. what do I gain ? Conclusion Copyright @ 2020 Oracle and/or its affiliates. 142 / 146
  • 143. schemaless exible data structure easy to start (CRUD) Conclusion This is the best of the two worlds in one product ! Data integrity ACID Compliant Transactions SQL Copyright @ 2020 Oracle and/or its affiliates. 143 / 146
  • 146. Q & A Copyright @ 2020 Oracle and/or its affiliates. 146 / 146