state of the dolphin - percona · copyright © 2017, oracle and/or its affiliates. all rights...

36
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | State of the Dolphin Geir Høydalsvik Senior Software Development Director Copyright © 2017, Oracle and/or its affiliates. All rights reserved.

Upload: others

Post on 17-Jun-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

State of the DolphinGeir HøydalsvikSenior Software Development Director

Copyright © 2017, Oracle and/or its affiliates. All rights reserved.

Page 2: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()
Page 3: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Safe Harbor Statement

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

3

Page 4: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL 8.0 RC1 Now Available!• 2 years in Development

• 400+ Worklogs

• 5000+ Bugs Fixed

• 500 new tests

4

Page 5: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 5

Building a Sample ApplicationTicket Booking System

Page 6: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 6

Case Study: Our Booking System

Page 7: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL 8.0 Enables Modern Web Applications1. Mobile First

2. Developer First

3. Data Driven

4. 24x7 at Scale

7

Page 8: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Where are our bookings coming from?• Many orders will be placed on mobile

• It is not just a theme:

• Need to reduce clicking between screens

• Use user location for context

8

Page 9: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 9

SELECT events.id, events.name, DATE(events.event_date) as date,

ROUND(st_distance_sphere(venues.location, POINT(-6.2603, 53.3498)), 2)

AS distance_in_meters

FROM events

INNER JOIN venues ON events.venue_id=venues.id

WHERE event_date > NOW()

ORDER BY distance_in_meters;

+----+-----------------------------+----------------+--------------------------

-+

| id | name | date | distance_in_meters |

+----+-----------------------------+----------------+--------------------------

-+

| 1 | Percona Live | 2017-09-25 | 0.00 |

| 2 | Oracle OpenWorld | 2017-10-01 | 8176613.65 |

| 3 | Percona Live | 2018-04-24 | 8192496.25 |

+----+-----------------------------+----------------+--------------------------

-+

3 rows in set (0.00 sec)

Page 10: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Mobile also means• Emoji characters used as input

• MySQL 8.0 defaults to utf8mb4

• Latest Unicode 9.0 Support

• New collations based on DUCET, accent and case sensitive collations, Japanese, Russian

10

Page 11: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL 8.0 vs MySQL 5.7 utf8mb4

11

+300-350% in OLTP RO+176-233% in OLTP RW+1500-1800% in SELECT DISTINCT_RANGES

Page 12: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL 8.0 Enables Modern Web Applications1. Mobile First

2. Developer First

3. Data Driven

4. 24x7 at Scale

12

Page 13: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Javascript Everywhere

13

+

Backend:

Frontend:

Page 14: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

What’s New in the MySQL Shell• Customizable prompt

• Include context and session information

• Custom font and color support

• Persistent command line history

• Auto-complete / Content Assistance

• Full Unicode support

14

Page 15: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Replication with InnoDB Cluster• Complete HA Solution for MySQL

• Based on MySQL Group Replication

• Clients route via MySQL Router

• Management by MySQL Shell

15

Page 16: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Flexible Schema

16

Page 17: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

mysql> SELECT id, doc FROM seats WHERE id = 28100\G

*************************** 1. row ***************************

id: 28100

doc: {"row": 10, "seat": 13, "section": 215, "properties":

{"amenities": [{"type": "washroom", "distance_in_meters":

38.564358156700024}, {"type": "bar", "distance_in_meters":

152.33173722618423}, {"type": "snacks", "distance_in_meters":

35.965617807550004}, {"type": "souvenirs", "distance_in_meters":

215.66576701185272}], "accessible": false, "emergency_exits":

[{"exit 1": 100.66892563427699}, {"exit 2": 374.19603448751946},

{"exit 3": 563.9332987311606}, {"exit 4": 886.7355222969646}, {"exit

5": 1900.9778593955355}], "entrance_number": 2}}

1 row in set (0.00 sec)

17

Page 18: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

JSON Functions

18

MySQL 5.7 and 8.0

JSON_ARRAY_APPEND()

JSON_ARRAY_INSERT()

JSON_ARRAY()

JSON_CONTAINS_PATH()

JSON_CONTAINS()

JSON_DEPTH()

JSON_EXTRACT()

JSON_INSERT()

JSON_KEYS()

JSON_LENGTH()

JSON_MERGE[_PRESERVE]()

JSON_OBJECT()

JSON_QUOTE()

JSON_REMOVE()

JSON_REPLACE()

JSON_SEARCH()

JSON_SET()

JSON_TYPE()

JSON_UNQUOTE()

JSON_VALID()

JSON_PRETTY()

JSON_STORAGE_SIZE()

JSON_STORAGE_FREE()

JSON_ARRAYAGG()

JSON_OBJECTAGG()

JSON_MERGE_PATCH()

JSON_TABLE() *labs

Page 19: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

SELECT JSON_ARRAYAGG(

JSON_OBJECT('Event id', id,

'Event date', event_date,

'Event name', name))

FROM events

WHERE venue_id = 10

AND event_date > NOW()

ORDER BY event_date;

*************************** 1. row

***************************

[ {“Event id": 100, “Event date": “2017-09-25”, “Event

name": “Percona Live”},

{“Event id": 101, “Event date": “2017-10-25”, “Event name":

“Dublin Live”} ]

19

Page 20: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

SELECT * FROM seats,

JSON_TABLE(doc, "$.properties.amenities[*]" COLUMNS (

id for ordinality,

amenity_type VARCHAR(100) PATH "$.type",

distance float PATH '$.distance_in_meters')

) AS amenities

WHERE seats.id = 28100

AND amenities.amenity_type IN ('snacks', 'bar')

ORDER BY amenities.distance;

+------+------------------+------------+

| id | amenity_type | distance |

+------+------------------+------------+

| 2 | bar | 100.538 |

| 3 | snacks | 136.647 |

+------+------------------+------------+

2 rows in set (0.00 sec)

20

Labs

Page 21: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL 8.0 Enables Modern Web Applications1. Mobile First

2. Developer First

3. Data Driven

4. 24x7 at Scale

21

Page 22: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

New SQL Syntax• Two of our most requested features:

• Common Table Expressions (CTEs)

• Window Functions

22

Feature Requestfrom Developers

Page 23: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

WITH tickets_filtered AS (

SELECT tickets.*, seats.doc

FROM tickets

INNER JOIN seats ON tickets.seat_id=seats.id

WHERE tickets.event_id = 3

)

SELECT * FROM tickets_filtered

WHERE doc->"$.section" = 201\G

*************************** 1. row ***************************

id: 14447

event_id: 3

seat_id: 16430

order_id: NULL

doc: {"row": 2, "seat": 1, "section": 201, "properties":

{"amenities": [{"type": "washroom", "distance_in_meters":

171.80304788220957}, {"type": "bar", "distance_in_meters":

58.53288591702737}, {"type": "snacks", "distance_in_meters":

..

23

Page 24: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

SELECT

seats.doc->"$.row" as row_no,

seats.doc->"$.seat" as seat_no,

LAG(seats.doc->"$.seat", 1) OVER w AS prev_seat,

LEAD(seats.doc->"$.seat", 1) OVER w AS next_seat

FROM tickets

JOIN seats ON tickets.seat_id=seats.id

WHERE seats.doc->"$.section" = 201

WINDOW w AS

(PARTITION BY seats.doc->"$.row"

ORDER BY seats.doc->"$.seat")

ORDER BY row_no, seat_no;

+----------+-----------+--------------+-------------+

| row_no | seat_no | prev_seat | next_seat |

+----------+-----------+--------------+-------------+

| 1 | 1 | NULL | 2 |

| 1 | 2 | 1 | 3 |

| 1 | 3 | 2 | 4 |

+----------+-----------+--------------+-------------+

24

Page 25: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL 8.0 Enables Modern Web Applications1. Mobile First

2. Developer First

3. Data Driven

4. 24x7 at Scale

25

Page 26: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

New! Better Handling of Hot Row Contention

26

SELECT * FROM tickets

WHERE id IN (1,2,3,4)

AND order_id IS NULL

FOR UPDATE

NOWAIT;

SELECT * FROM tickets

WHERE id IN (1,2,3,4)

AND order_id IS NULL

FOR UPDATE

SKIP LOCKED;

Error immediately if a row is already locked

Non deterministically skip over locked rows

Page 27: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

New! Invisible Indexes• Indexes are “hidden” to the MySQL Optimizer

– Not the same as “disabled indexes”

– Contents are fully up to date and maintained by DML

• Two use cases:– Soft Delete (Recycle Bin)

– Staged Rollout

27

Feature Requestfrom DBAs

Page 28: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 28

Evolution from MySQL 5.5 to 8.0Performance Schema

Feature Requestfrom DBAs

MySQL 8.0HistogramsIndexesData Locks instrumentationSQL Errors instrumentationVariables InstrumentationTable pluginImproved Defaults

MySQL 5.7Memory InstrumentationPrepared Statements InstrumentationTransactions InstrumentationScalable Memory AllocationBundled SYS schemaLower Overhead

MySQL 5.6Statement InstrumentationLower Overhead

MySQL 5.5Event WaitsMutexesFilesThreads

Page 29: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 29

Performance Comparison Over 30x faster!

SELECT * FROM sys.session1000 active sessions

Time in Seconds (Lower is better)

Page 30: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

New! Transactional Data Dictionary• Crash-safe Database

• Common data dictionary for the server and InnoDB

• Crash-safe & Atomic DDL

• CREATE USER <userlist>, DROP DATABASE with all-or-none semantic

• Simplifies replication failure cases

30

• Meta-data locking for FK constraints

• FK moved from InnoDB to server layer

• Scalable Information Schema

• Queries are now executed as set of SQL views on tables

• Large performance improvements

Page 31: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Performance Improvements• Improved Query Consistency

• Histograms

• Improved Cost Model

• Faster Table/Range Scans

31

• Parallel Replication

• UTF8MB4

• Information Schema

• Performance Schema Indexes

Page 32: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL 8.0 Labs: Sysbench Benchmark: IO-bound OLTP RW Updates-only

Intel(R) Xeon(R) Platinum 8168 CPU2CPU-sockets, 48cores-HT 2x Intel Optane Oracle Linux 7.3

Page 33: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL 8.0 Labs: Sysbench Benchmark: IO-bound OLTP RO Point-Selects

Intel(R) Xeon(R) Platinum 8168 CPU2CPU-sockets, 48cores-HT 2x Intel Optane Oracle Linux 7.3

1,000,000+ QPS

Page 34: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL 8.0 RC: Resource Group Example

System Configuration :Oracle Linux 7, Intel(R) Xeon(R) CPU E7-4860 2.27GHz 40 cores-HT

(40 Cores Shared)

(40 Cores for Select)(10 Cores for Update RG)

Page 35: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 35

Page 36: State of the Dolphin - Percona · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Functions 18 MySQL 5.7 and 8.0 JSON_ARRAY_APPEND() JSON_ARRAY_INSERT()