MySQL 8.0 New Features
Dave Stokes
MySQL Community Manager
MySQL Community Team
Linux Foundation Open Source Summit
September 27th, 2021
1
Me?
✔ Started using MySQL when it first was available
✔ Used in many projects -> Open Source, used due to low $
✔ Joined MySQL AB as PHP Programmer on the Certification Team
MySQL AB -> Sun Microsystems -> Oracle
✔ MySQL Community Team
✔ MySQL 8.0 DBA & DEV Certified
✔ Live in Texas with required hound dog and pickup truck
slides -> slideshare.net/davestokes
@Stoker David.Stokes @Oracle.com
2
Copyright © 2021, Oracle and/or its affiliates
3
MySQL
is
25 Years
Old!
MySQL 5.6 reached ‘end of life’ status in February of 2021!
Please upgrade to MySQL 5.7 or 8.0
MySQL 5.6 EOL
4
Generally Available in April 2018
Releases every three months, or so
-ci/cd bandwagon
-software much more complex than the 5.5 era
-better product gets to customers quicker
Same release numbers for all products
-server, clients, connectors, router, utilities, etc.
-tested together
MySQL 8.0
5
No More Wondering Which Version of What to Run – now all 8.0.26
▪ In the past you had various versions for
the server, the connectors, the tools,
and etcetera.
▪ Now one release number for all
products
All tested together
Pass Q/A Together
▪ MySQL Server – Community &
Enterprise
▪ MySQL NDB Cluster
▪ MySQL Shell
▪ MySQL Workbench
▪ MySQL Router
▪ MySQL Connectors – C/C++, Java, .Net,
Node.JS, ODBC, Python & PHP
(MySQLnd & X DevAPI)
6
So
What
Changed?
7
The data dictionary that stores information about
database objects.
In previous MySQL releases, dictionary data was
stored in metadata files, non transactional tables,
and storage engine-specific data dictionaries
Data Dictionary
8
Now stored in InnoDB storage engine.
Excellent for point in time recovery
Less inodes consumed, less mess
Data Dictionary
9
The good news:
You can now have millions of tables in a schema.
The bad news:
You can now have millions of tables in a schema.
Data Dictionary
10
● Unicode support
● 4 bytes
● CJK Support
● and 💩
Optimized for UTF8MB4
11
mysql> EXPLAIN FORMAT=TREE SELECT * FROM t1 JOIN t2 ON t1.c1 < t2.c1G
*************************** 1. row ***************************
EXPLAIN: -> Filter: (t1.c1 < t2.c1) (cost=4.70 rows=12)
-> Inner hash join (no condition) (cost=4.70 rows=12)
-> Table scan on t2 (cost=0.08 rows=6)
-> Hash
-> Table scan on t1 (cost=0.85 rows=6)
Beginning with MySQL 8.0.18, MySQL employs a hash join for any query for
which each join has an equi-join condition, and in which there are no
indexes that can be applied
A hash join is usually faster than and is intended to be used in such
cases instead of the block nested loop algorithm ( employed in previous
versions of MySQL.
Hash Joins
12
Hash Joins
13
NoSQL access via new protocol based on Google
Protobufs
Not an ORM
Will also work with relational data
API follows modern design practices
Using Structured Query Language or X DevAPI
MySQL as a NoSQL JSON Document Store Database
14
• Advanced Client and Code Editor
• Command Completion
• Extensive help support
• Three modes – SQL, Python, and JavaScript
• Admin for InnoDB Cluster and ReplicaSet Replication
• 5.7 to 8.0 upgrade checker
• Bulk loader
• Utilities for dumping schemas, or instances and restoration
MySQL Shell
15
Three Modes
● JavaScript
● Python
● SQL
TLS 1.3
● Secure by default
Compression
16
ALTER TABLE t1 ALTER INDEX i_idx INVISIBLE;
ALTER TABLE t1 ALTER INDEX i_idx VISIBLE;
Invisible indexes make it possible to test the effect of removing an index on
query performance, without making a destructive change that must be undone
should the index turn out to be required.
Dropping and re-adding an index can be expensive for a large table, whereas
making it invisible and visible are fast, in-place operations.
Invisible Index
17
SQL > create table not_here (id serial primary key,
a int,
b int invisible);
SQL > insert into not_here (a,b) values (1,2),(3,4);
SQL > select * from not_here;
+----+---+
| id | a |
+----+---+
| 1 | 1 |
| 2 | 3 |
+----+---+
SQL > select *,b from not_here;
+----+---+---+
| id | a | b |
+----+---+---+
| 1 | 1 | 2 |
| 2 | 3 | 4 |
+----+---+---+
Invisible Column
Suppose that an application uses
SELECT * queries to access a
table, and must continue to work
without modification even if the
table is altered to add a new
column that the application does
not expect to be there.
18
The asynchronous connection failover mechanism to automatically establish an asynchronous
(source to replica) replication connection to a new source after the existing connection from a
replica to its source fails.
The asynchronous connection failover mechanism can be used to keep a replica synchronized
with multiple MySQL servers or groups of servers that share data.
The list of potential source servers is stored on the replica, and in the event of a connection
failure, a new source is selected from the list based on a weighted priority that you set.
Group Replication also supported!
New Async Connection Failover
19
CREATE USER 'bill'@'localhost' COMMENT 'Bill Johnson room 114, x 1234';
select User_attributes from mysql.user where User='bill'G
*************************** 1. row ***************************
User_attributes: {"metadata": {"comment": "Bill Johnson room 114, x
1234"}}
ALTER USER 'mary'@'localhost' ATTRIBUTE '{"email":"mary.wu@example.com"}';
select User_attributes from mysql.user where User='mary'G
*************************** 1. row ***************************
User_attributes: {"metadata": {"email": "mary.wu@example.com", "comment":
"Mary Wu room 141, x 2234"}}
User Details
20
ALTER INSTANCE {ENABLE|DISABLE} INNODB REDO_LOG;
Turn off REDO logging for loading data
21
These support the export of all
schemas or a selected schema
from an on-premise MySQL
instance into an Oracle Cloud
Infrastructure Object Storage
bucket or a set of local files
And they provide parallel
dumping with multiple threads
and file compression, which
are not provided by mysqldump.
Progress information is
displayed during the dump.
Shell Backup Utilities - Mysqlsh util.dumpSchemas(), util.dumpInstance(), util.dumpTables() and util.loadDump()
util.dumpInstance("/tmp/instance",
{ "showProgress" : "true" })
1 thds dumping - 100% (52.82K rows / ~52.81K rows), 0.00
rows/s, 0.00 B/s uncompressed, 0.00 B/s compressed
Duration: 00:00:00s
Schemas dumped: 4
Tables dumped: 26
Uncompressed data size: 3.36 MB
Compressed data size: 601.45 KB
Compression ratio: 5.6
Rows written: 52819
Bytes written: 601.45 KB
Average uncompressed throughput: 3.36 MB/s
Average compressed throughput: 601.45 KB/s
22
Transaction payloads are compressed using zstd
algorithm on server as a single transaction.
Transferred to replica in compresses state and
written to relay log in their compressed state.
Binary Log Compression
23
SQL > create user 'Foo'@'%' IDENTIFIED BY RANDOM PASSWORD;
+------+------+----------------------+
| user | host | generated password |
+------+------+----------------------+
| Foo | % | Ld]5/Fkn[Kk29/g/M;>n |
+------+------+----------------------+
1 row in set (0.0090 sec)
https://elephantdolphin.blogspot.com/2019/10/mysql-random-password-generation.html
Random Passwords
24
EXPLAIN ANALYZE select city.Name, Country.Name
FROM city
JOIN country ON (city.CountryCode = country.code)
WHERE country.code= 'GBR'
ORDER by city.name
LIMIT 5;
| EXPLAIN
|
| -> Limit: 5 row(s) (actual time=0.102..0.103 rows=5 loops=1)
-> Sort: city.Name, limit input to 5 row(s) per chunk
(cost=80.76 rows=81) (actual time=0.102..0.102 rows=5 loops=1)
-> Index lookup on city using CountryCode
(CountryCode='GBR') (actual time=0.066..0.075 rows=81 loops=1)
|
1 row in set (0.0006 sec)
EXPLAIN ANALYZE
25
CREATE INDEX data__nbr_idx
ON a1( (CAST(data->'$.nbr' AS UNSIGNED ARRAY)) );
A Multi-Valued Index (MVI) is a secondary index defined on a column made up of an
array of values.
We are all used to traditional indexes where you have one value per index entry, a
1:1 ratio.
A MVI can have multiple records for each index record. So you can have multiple
postal codes, phone numbers, or other attributes from one JSON document indexed
for quick access.
https://elephantdolphin.blogspot.com/2019/08/improved-mysql-query-performance-with.html
Multi-Values Indexes
26
CREATE TABLE `testx` (
`col` JSON,
CONSTRAINT `myage_inRange`
CHECK (JSON_SCHEMA_VALID('{"type": "object",
"properties": {
"myage": {
"type" : "number",
"minimum": 28,
"maximum": 99
}
},"required": ["myage"]
}', `col`) = 1)
);
JSON Document Validation
mysql> insert into testx values('{"myage":27}');
ERROR 3819 (HY000): Check constraint
'myage_inRange' is violated.
mysql> insert into testx values('{"myage":97}');
Query OK, 1 row affected (0.02 sec)
https://elephantdolphin.blogspot.com/2019/07/json-schema-validation-with-mysql-8017.html
27
His script now runs automatically – no chance to forget it again!
No more running mysql_upgrade
28
CREATE TABLE t1 ( CHECK (c1 <> c2),
c1 INT CHECK (c1 > 10),
c2 INT CONSTRAINT c2_positive CHECK (c2 > 0),
c3 INT CHECK (c3 < 100),
CONSTRAINT c1_nonzero CHECK (c1 <> 0),
CHECK (c1 > c3)
);
Constraint Checks
29
ANALYZE TABLE t UPDATE HISTOGRAM ON c1, c2, c3 WITH 10 BUCKETS;
ANALYZE TABLE t DROP HISTOGRAM ON c2;
A histogram is created or updated only on demand, so it adds no overhead (unlike
an index) when table data is modified.
On the other hand, the statistics become progressively more out of date when table
modifications occur, until the next time they are updated.
Histograms
30
InnoDB uses the Contention-Aware Transaction Scheduling (CATS) algorithm to prioritize transactions
that are waiting for locks. When multiple transactions are waiting for a lock on the same object, the
CATS algorithm determines which transaction receives the lock first.
The CATS algorithm prioritizes waiting transactions by assigning a scheduling weight, which is
computed based on the number of transactions that a transaction blocks. For example, if two
transactions are waiting for a lock on the same object, the transaction that blocks the most
transactions is assigned a greater scheduling weight. If weights are equal, priority is given to the
longest waiting transaction.
This replaces the previous used First In First Out (FIFO) algorithm to schedule transactions.
CATS
31
mysql> select country_name, IndyYear
from countryinfo,
json_table(doc,"$" columns (
country_name char(20) path "$.Name",
IndyYear int path "$.IndepYear")
) as stuff
where IndyYear > 1992;
+----------------+----------+
| country_name | IndyYear |
+----------------+----------+
| Czech Republic | 1993 |
| Eritrea | 1993 |
| Palau | 1994 |
| Slovakia | 1993 |
+----------------+----------+
Better JSON Support including JSON_TABLE()
JSON_TABLE() is used for making JSON data a
temporary relational data, which is especially useful
when creating relational views over JSON data,
32
WITH
cte1 AS (SELECT a, b FROM table1),
cte2 AS (SELECT c, d FROM table2)
SELECT b, d FROM cte1 JOIN cte2
WHERE cte1.a = cte2.c;
Common Table Expressions or CTEs -- ..are like derived tables but the declaration is BEFORE the query
33
SELECT date, amount,
sum(amount)
OVER w AS ‘sum’
FROM payments
WINDOW w AS
(ORDER BY date
RANGE BETWEEN INTERVAL 1 WEEK
PRECEDING AND CURRENT ROW)
ORDER BY date;
Window Functions - More granular analysis
34
MySQL InnoDB cluster provides a
complete high availability solution for
MySQL. 
MySQL Shell includes AdminAPI which
enables you to easily configure and
administer a group of at least three
MySQL server instances to function as
an InnoDB cluster.
Each MySQL server instance runs
MySQL Group Replication, which
provides the mechanism to replicate
data within InnoDB clusters, with
built-in failover. 
InnoDB Cluster
35
The basic idea for InnoDB ReplicaSet is to do the same
for classic MySQL Replication as InnoDB Cluster did for
Group Replication and provides an easy-to-use
AdminAPI for it in the MySQL Shell.
In just a few easy to use Shell commands, a MySQL
Replication database architecture can be configured
from scratch including:
• Data provisioning using MySQL CLONE,
• Setting up replication
• Performing manual switchover/failover
Replica Set
36
The clone plugin permits cloning data locally or from a remote MySQL server instance.
Cloned data is a physical snapshot of data stored in InnoDB that includes schemas, tables,
tablespaces, and data dictionary metadata. The cloned data comprises a fully functional
data directory, which permits using the clone plugin for MySQL server provisioning.
CLONE INSTANCE FROM 'user'@'host':port IDENTIFIED BY 'password' [DATA
DIRECTORY [=] 'clone_dir'] [REQUIRE [NO] SSL];
Clone Plugin
37
MySQL without the SQL -- Oh My!!
38
MySQL Database Service
Oracle Cloud Infrastructure
39
Oracle MySQL Database Service is a fully managed database service that lets developers quickly
develop and deploy secure, cloud native applications using the world’s most popular open source
database.
Optimized for Oracle Cloud Infrastructure (OCI), MySQL Database Service is 100% built, managed,
and supported by the OCI and MySQL engineering teams.
MDS
40
“We have saved around 40% of our
costs and are able to reinvest that
back into the business. And we are
scaling across EMEA, and that’s
basically all because of Oracle.”
—Asser Smidt
CEO and Cofounder, BotSupply
Startups get cloud credits and a 70%
discount for 2 years, global exposure via
marketing, events, digital promotion, and
media, plus access to mentorship,
capital and Oracle’s 430,000+
customers
Customers meet vetted startups in
transformative spaces that help them
stay ahead of their competition
Oracle stays at the competitive edge
of innovation with solutions that
complement its technology stack
Oracle for Startups - enroll at oracle.com/startup
A Virtuous Cycle of Innovation, Everybody Wins.
41
Test Drive MySQL
Database Service For
Free Today
Get $300 in credits
and try MySQL Database Service
free for 30 days.
https://www.oracle.com/cloud/free/
Copyright © 2021, Oracle and/or its affiliates
42
Follow us on Social Media
Copyright © 2021, Oracle and/or its affiliates
43
If you are using
JSON & MYSQL
then you
need this book!
The second edition is
now on sale at
Amazon
44
Thank You!
slides -> slideshare.net/davestokes
45 Copyright © 2021, Oracle and/or its affiliates
Q&A
46
The High Availability option enables applications to meet higher uptime requirements and zero data
loss tolerance.
When you select the High Availability option, a MySQL DB System with three instances is provisioned
across different availability or fault domains.
The data is replicated among the instances using a Paxos-based consensus protocol implemented by
the MySQL Group Replication technology.
Your application connects to a single endpoint to read and write data to the database.
In case of failure, the MySQL Database Service will automatically failover within minutes to a
secondary instance without data loss and without requiring to reconfigure the application
MDS HA
47
HeatWave is a tightly integrated, high performance, in-memory query accelerator for the MySQL Database Service.
It allows customers to run very fast analytics queries directly against their MySQL databases entirely avoiding the step
of data ETL into a second analytics database.
HeatWave scales out to thousands of cores, is 1,100 times faster at query performance than Amazon Aurora, and is
2.7 times faster than Amazon Redshift—at one-third the cost.
MySQL AutoPilot provides machine-learning–based automation which helps configure, optimize, and tune MySQL
HeatWave. Autopilot uses data and queries from the application workload in the machine learning model to make
predictions. It enables customers to optimally provision, load, execute queries, and recover from failure without
requiring any human intervention.
MDS Heatwave + Autopilot
48

MySQL 8.0 New Features -- September 27th presentation for Open Source Summit

  • 1.
    MySQL 8.0 NewFeatures Dave Stokes MySQL Community Manager MySQL Community Team Linux Foundation Open Source Summit September 27th, 2021 1
  • 2.
    Me? ✔ Started usingMySQL when it first was available ✔ Used in many projects -> Open Source, used due to low $ ✔ Joined MySQL AB as PHP Programmer on the Certification Team MySQL AB -> Sun Microsystems -> Oracle ✔ MySQL Community Team ✔ MySQL 8.0 DBA & DEV Certified ✔ Live in Texas with required hound dog and pickup truck slides -> slideshare.net/davestokes @Stoker David.Stokes @Oracle.com 2
  • 3.
    Copyright © 2021,Oracle and/or its affiliates 3 MySQL is 25 Years Old!
  • 4.
    MySQL 5.6 reached‘end of life’ status in February of 2021! Please upgrade to MySQL 5.7 or 8.0 MySQL 5.6 EOL 4
  • 5.
    Generally Available inApril 2018 Releases every three months, or so -ci/cd bandwagon -software much more complex than the 5.5 era -better product gets to customers quicker Same release numbers for all products -server, clients, connectors, router, utilities, etc. -tested together MySQL 8.0 5
  • 6.
    No More WonderingWhich Version of What to Run – now all 8.0.26 ▪ In the past you had various versions for the server, the connectors, the tools, and etcetera. ▪ Now one release number for all products All tested together Pass Q/A Together ▪ MySQL Server – Community & Enterprise ▪ MySQL NDB Cluster ▪ MySQL Shell ▪ MySQL Workbench ▪ MySQL Router ▪ MySQL Connectors – C/C++, Java, .Net, Node.JS, ODBC, Python & PHP (MySQLnd & X DevAPI) 6
  • 7.
  • 8.
    The data dictionarythat stores information about database objects. In previous MySQL releases, dictionary data was stored in metadata files, non transactional tables, and storage engine-specific data dictionaries Data Dictionary 8
  • 9.
    Now stored inInnoDB storage engine. Excellent for point in time recovery Less inodes consumed, less mess Data Dictionary 9
  • 10.
    The good news: Youcan now have millions of tables in a schema. The bad news: You can now have millions of tables in a schema. Data Dictionary 10
  • 11.
    ● Unicode support ●4 bytes ● CJK Support ● and 💩 Optimized for UTF8MB4 11
  • 12.
    mysql> EXPLAIN FORMAT=TREESELECT * FROM t1 JOIN t2 ON t1.c1 < t2.c1G *************************** 1. row *************************** EXPLAIN: -> Filter: (t1.c1 < t2.c1) (cost=4.70 rows=12) -> Inner hash join (no condition) (cost=4.70 rows=12) -> Table scan on t2 (cost=0.08 rows=6) -> Hash -> Table scan on t1 (cost=0.85 rows=6) Beginning with MySQL 8.0.18, MySQL employs a hash join for any query for which each join has an equi-join condition, and in which there are no indexes that can be applied A hash join is usually faster than and is intended to be used in such cases instead of the block nested loop algorithm ( employed in previous versions of MySQL. Hash Joins 12
  • 13.
  • 14.
    NoSQL access vianew protocol based on Google Protobufs Not an ORM Will also work with relational data API follows modern design practices Using Structured Query Language or X DevAPI MySQL as a NoSQL JSON Document Store Database 14
  • 15.
    • Advanced Clientand Code Editor • Command Completion • Extensive help support • Three modes – SQL, Python, and JavaScript • Admin for InnoDB Cluster and ReplicaSet Replication • 5.7 to 8.0 upgrade checker • Bulk loader • Utilities for dumping schemas, or instances and restoration MySQL Shell 15
  • 16.
    Three Modes ● JavaScript ●Python ● SQL TLS 1.3 ● Secure by default Compression 16
  • 17.
    ALTER TABLE t1ALTER INDEX i_idx INVISIBLE; ALTER TABLE t1 ALTER INDEX i_idx VISIBLE; Invisible indexes make it possible to test the effect of removing an index on query performance, without making a destructive change that must be undone should the index turn out to be required. Dropping and re-adding an index can be expensive for a large table, whereas making it invisible and visible are fast, in-place operations. Invisible Index 17
  • 18.
    SQL > createtable not_here (id serial primary key, a int, b int invisible); SQL > insert into not_here (a,b) values (1,2),(3,4); SQL > select * from not_here; +----+---+ | id | a | +----+---+ | 1 | 1 | | 2 | 3 | +----+---+ SQL > select *,b from not_here; +----+---+---+ | id | a | b | +----+---+---+ | 1 | 1 | 2 | | 2 | 3 | 4 | +----+---+---+ Invisible Column Suppose that an application uses SELECT * queries to access a table, and must continue to work without modification even if the table is altered to add a new column that the application does not expect to be there. 18
  • 19.
    The asynchronous connectionfailover mechanism to automatically establish an asynchronous (source to replica) replication connection to a new source after the existing connection from a replica to its source fails. The asynchronous connection failover mechanism can be used to keep a replica synchronized with multiple MySQL servers or groups of servers that share data. The list of potential source servers is stored on the replica, and in the event of a connection failure, a new source is selected from the list based on a weighted priority that you set. Group Replication also supported! New Async Connection Failover 19
  • 20.
    CREATE USER 'bill'@'localhost'COMMENT 'Bill Johnson room 114, x 1234'; select User_attributes from mysql.user where User='bill'G *************************** 1. row *************************** User_attributes: {"metadata": {"comment": "Bill Johnson room 114, x 1234"}} ALTER USER 'mary'@'localhost' ATTRIBUTE '{"email":"mary.wu@example.com"}'; select User_attributes from mysql.user where User='mary'G *************************** 1. row *************************** User_attributes: {"metadata": {"email": "mary.wu@example.com", "comment": "Mary Wu room 141, x 2234"}} User Details 20
  • 21.
    ALTER INSTANCE {ENABLE|DISABLE}INNODB REDO_LOG; Turn off REDO logging for loading data 21
  • 22.
    These support theexport of all schemas or a selected schema from an on-premise MySQL instance into an Oracle Cloud Infrastructure Object Storage bucket or a set of local files And they provide parallel dumping with multiple threads and file compression, which are not provided by mysqldump. Progress information is displayed during the dump. Shell Backup Utilities - Mysqlsh util.dumpSchemas(), util.dumpInstance(), util.dumpTables() and util.loadDump() util.dumpInstance("/tmp/instance", { "showProgress" : "true" }) 1 thds dumping - 100% (52.82K rows / ~52.81K rows), 0.00 rows/s, 0.00 B/s uncompressed, 0.00 B/s compressed Duration: 00:00:00s Schemas dumped: 4 Tables dumped: 26 Uncompressed data size: 3.36 MB Compressed data size: 601.45 KB Compression ratio: 5.6 Rows written: 52819 Bytes written: 601.45 KB Average uncompressed throughput: 3.36 MB/s Average compressed throughput: 601.45 KB/s 22
  • 23.
    Transaction payloads arecompressed using zstd algorithm on server as a single transaction. Transferred to replica in compresses state and written to relay log in their compressed state. Binary Log Compression 23
  • 24.
    SQL > createuser 'Foo'@'%' IDENTIFIED BY RANDOM PASSWORD; +------+------+----------------------+ | user | host | generated password | +------+------+----------------------+ | Foo | % | Ld]5/Fkn[Kk29/g/M;>n | +------+------+----------------------+ 1 row in set (0.0090 sec) https://elephantdolphin.blogspot.com/2019/10/mysql-random-password-generation.html Random Passwords 24
  • 25.
    EXPLAIN ANALYZE selectcity.Name, Country.Name FROM city JOIN country ON (city.CountryCode = country.code) WHERE country.code= 'GBR' ORDER by city.name LIMIT 5; | EXPLAIN | | -> Limit: 5 row(s) (actual time=0.102..0.103 rows=5 loops=1) -> Sort: city.Name, limit input to 5 row(s) per chunk (cost=80.76 rows=81) (actual time=0.102..0.102 rows=5 loops=1) -> Index lookup on city using CountryCode (CountryCode='GBR') (actual time=0.066..0.075 rows=81 loops=1) | 1 row in set (0.0006 sec) EXPLAIN ANALYZE 25
  • 26.
    CREATE INDEX data__nbr_idx ONa1( (CAST(data->'$.nbr' AS UNSIGNED ARRAY)) ); A Multi-Valued Index (MVI) is a secondary index defined on a column made up of an array of values. We are all used to traditional indexes where you have one value per index entry, a 1:1 ratio. A MVI can have multiple records for each index record. So you can have multiple postal codes, phone numbers, or other attributes from one JSON document indexed for quick access. https://elephantdolphin.blogspot.com/2019/08/improved-mysql-query-performance-with.html Multi-Values Indexes 26
  • 27.
    CREATE TABLE `testx`( `col` JSON, CONSTRAINT `myage_inRange` CHECK (JSON_SCHEMA_VALID('{"type": "object", "properties": { "myage": { "type" : "number", "minimum": 28, "maximum": 99 } },"required": ["myage"] }', `col`) = 1) ); JSON Document Validation mysql> insert into testx values('{"myage":27}'); ERROR 3819 (HY000): Check constraint 'myage_inRange' is violated. mysql> insert into testx values('{"myage":97}'); Query OK, 1 row affected (0.02 sec) https://elephantdolphin.blogspot.com/2019/07/json-schema-validation-with-mysql-8017.html 27
  • 28.
    His script nowruns automatically – no chance to forget it again! No more running mysql_upgrade 28
  • 29.
    CREATE TABLE t1( CHECK (c1 <> c2), c1 INT CHECK (c1 > 10), c2 INT CONSTRAINT c2_positive CHECK (c2 > 0), c3 INT CHECK (c3 < 100), CONSTRAINT c1_nonzero CHECK (c1 <> 0), CHECK (c1 > c3) ); Constraint Checks 29
  • 30.
    ANALYZE TABLE tUPDATE HISTOGRAM ON c1, c2, c3 WITH 10 BUCKETS; ANALYZE TABLE t DROP HISTOGRAM ON c2; A histogram is created or updated only on demand, so it adds no overhead (unlike an index) when table data is modified. On the other hand, the statistics become progressively more out of date when table modifications occur, until the next time they are updated. Histograms 30
  • 31.
    InnoDB uses theContention-Aware Transaction Scheduling (CATS) algorithm to prioritize transactions that are waiting for locks. When multiple transactions are waiting for a lock on the same object, the CATS algorithm determines which transaction receives the lock first. The CATS algorithm prioritizes waiting transactions by assigning a scheduling weight, which is computed based on the number of transactions that a transaction blocks. For example, if two transactions are waiting for a lock on the same object, the transaction that blocks the most transactions is assigned a greater scheduling weight. If weights are equal, priority is given to the longest waiting transaction. This replaces the previous used First In First Out (FIFO) algorithm to schedule transactions. CATS 31
  • 32.
    mysql> select country_name,IndyYear from countryinfo, json_table(doc,"$" columns ( country_name char(20) path "$.Name", IndyYear int path "$.IndepYear") ) as stuff where IndyYear > 1992; +----------------+----------+ | country_name | IndyYear | +----------------+----------+ | Czech Republic | 1993 | | Eritrea | 1993 | | Palau | 1994 | | Slovakia | 1993 | +----------------+----------+ Better JSON Support including JSON_TABLE() JSON_TABLE() is used for making JSON data a temporary relational data, which is especially useful when creating relational views over JSON data, 32
  • 33.
    WITH cte1 AS (SELECTa, b FROM table1), cte2 AS (SELECT c, d FROM table2) SELECT b, d FROM cte1 JOIN cte2 WHERE cte1.a = cte2.c; Common Table Expressions or CTEs -- ..are like derived tables but the declaration is BEFORE the query 33
  • 34.
    SELECT date, amount, sum(amount) OVERw AS ‘sum’ FROM payments WINDOW w AS (ORDER BY date RANGE BETWEEN INTERVAL 1 WEEK PRECEDING AND CURRENT ROW) ORDER BY date; Window Functions - More granular analysis 34
  • 35.
    MySQL InnoDB clusterprovides a complete high availability solution for MySQL.  MySQL Shell includes AdminAPI which enables you to easily configure and administer a group of at least three MySQL server instances to function as an InnoDB cluster. Each MySQL server instance runs MySQL Group Replication, which provides the mechanism to replicate data within InnoDB clusters, with built-in failover.  InnoDB Cluster 35
  • 36.
    The basic ideafor InnoDB ReplicaSet is to do the same for classic MySQL Replication as InnoDB Cluster did for Group Replication and provides an easy-to-use AdminAPI for it in the MySQL Shell. In just a few easy to use Shell commands, a MySQL Replication database architecture can be configured from scratch including: • Data provisioning using MySQL CLONE, • Setting up replication • Performing manual switchover/failover Replica Set 36
  • 37.
    The clone pluginpermits cloning data locally or from a remote MySQL server instance. Cloned data is a physical snapshot of data stored in InnoDB that includes schemas, tables, tablespaces, and data dictionary metadata. The cloned data comprises a fully functional data directory, which permits using the clone plugin for MySQL server provisioning. CLONE INSTANCE FROM 'user'@'host':port IDENTIFIED BY 'password' [DATA DIRECTORY [=] 'clone_dir'] [REQUIRE [NO] SSL]; Clone Plugin 37
  • 38.
    MySQL without theSQL -- Oh My!! 38
  • 39.
    MySQL Database Service OracleCloud Infrastructure 39
  • 40.
    Oracle MySQL DatabaseService is a fully managed database service that lets developers quickly develop and deploy secure, cloud native applications using the world’s most popular open source database. Optimized for Oracle Cloud Infrastructure (OCI), MySQL Database Service is 100% built, managed, and supported by the OCI and MySQL engineering teams. MDS 40
  • 41.
    “We have savedaround 40% of our costs and are able to reinvest that back into the business. And we are scaling across EMEA, and that’s basically all because of Oracle.” —Asser Smidt CEO and Cofounder, BotSupply Startups get cloud credits and a 70% discount for 2 years, global exposure via marketing, events, digital promotion, and media, plus access to mentorship, capital and Oracle’s 430,000+ customers Customers meet vetted startups in transformative spaces that help them stay ahead of their competition Oracle stays at the competitive edge of innovation with solutions that complement its technology stack Oracle for Startups - enroll at oracle.com/startup A Virtuous Cycle of Innovation, Everybody Wins. 41
  • 42.
    Test Drive MySQL DatabaseService For Free Today Get $300 in credits and try MySQL Database Service free for 30 days. https://www.oracle.com/cloud/free/ Copyright © 2021, Oracle and/or its affiliates 42
  • 43.
    Follow us onSocial Media Copyright © 2021, Oracle and/or its affiliates 43
  • 44.
    If you areusing JSON & MYSQL then you need this book! The second edition is now on sale at Amazon 44
  • 45.
    Thank You! slides ->slideshare.net/davestokes 45 Copyright © 2021, Oracle and/or its affiliates Q&A
  • 46.
  • 47.
    The High Availabilityoption enables applications to meet higher uptime requirements and zero data loss tolerance. When you select the High Availability option, a MySQL DB System with three instances is provisioned across different availability or fault domains. The data is replicated among the instances using a Paxos-based consensus protocol implemented by the MySQL Group Replication technology. Your application connects to a single endpoint to read and write data to the database. In case of failure, the MySQL Database Service will automatically failover within minutes to a secondary instance without data loss and without requiring to reconfigure the application MDS HA 47
  • 48.
    HeatWave is atightly integrated, high performance, in-memory query accelerator for the MySQL Database Service. It allows customers to run very fast analytics queries directly against their MySQL databases entirely avoiding the step of data ETL into a second analytics database. HeatWave scales out to thousands of cores, is 1,100 times faster at query performance than Amazon Aurora, and is 2.7 times faster than Amazon Redshift—at one-third the cost. MySQL AutoPilot provides machine-learning–based automation which helps configure, optimize, and tune MySQL HeatWave. Autopilot uses data and queries from the application workload in the machine learning model to make predictions. It enables customers to optimally provision, load, execute queries, and recover from failure without requiring any human intervention. MDS Heatwave + Autopilot 48