Modern Development With MySQL

Similar documents
NoSQL + SQL = MySQL. Nicolas De Rico Principal Solutions Architect

NoSQL and SQL: The Best of Both Worlds

MySQL JSON. Morgan Tocker MySQL Product Manager. Copyright 2015 Oracle and/or its affiliates. All rights reserved.

Combining SQL and NoSQL with MySQL

MySQL as a Document Store. Ted Wennmark

Using the MySQL Document Store

MySQL High available by design

MySQL 5.7: What s New in the Optimizer?

What's New in MySQL 5.7?

MARIADB & JSON: FLEXIBLE DATA MODELING

3 / 120. MySQL 8.0. Frédéric Descamps - MySQL Community Manager - Oracle

State of the Dolphin Developing new Apps in MySQL 8

MySQL 5.7 News. Abel Flórez Technical Account Manager Copyright 2016 Oracle and/or its affiliates. All rights reserved.

Flexible Data Modeling in MariaDB

Introduction to the MySQL Document Store Alfredo Kojima, Rui Quelhas, Mike Zinner MySQL Middleware and Clients Team October 22, 2018

Practical JSON in MySQL 5.7 and Beyond

MySQL Next An overview of the MySQL 8 Beta

MySQL Document Store. How to replace a NoSQL database by MySQL without effort but with a lot of gains?

MySQL InnoDB Cluster. MySQL HA Made Easy! Miguel Araújo Senior Software Developer MySQL Middleware and Clients. FOSDEM 18 - February 04, 2018

Introduction to MySQL InnoDB Cluster

Everything You Need to Know About MySQL Group Replication

Part 1: IoT demo Part 2: MySQL, JSON and Flexible storage

NoSQL + SQL = MySQL Get the Best of Both Worlds

What s New in MySQL 5.7 Geir Høydalsvik, Sr. Director, MySQL Engineering. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

MySQL & NoSQL: The Best of Both Worlds

<Insert Picture Here> MySQL Cluster What are we working on

How to Use JSON in MySQL Wrong

MySQL Cluster Web Scalability, % Availability. Andrew

Safe Harbor Statement

Building Highly Available and Scalable Real- Time Services with MySQL Cluster

MySQL HA Solutions Selecting the best approach to protect access to your data

<Insert Picture Here> Upcoming Changes in MySQL 5.7 Morgan Tocker, MySQL Community Manager

MySQL for Developers. Duration: 5 Days

MySQL for Developers. Duration: 5 Days

MySQL Group Replication. Bogdan Kecman MySQL Principal Technical Engineer

Develop Python Applications with MySQL Connector/Python DEV5957

Upgrading to MySQL 8.0+: a More Automated Upgrade Experience. Dmitry Lenev, Software Developer Oracle/MySQL, November 2018

Continuous delivery of Java applications. Marek Kratky Principal Sales Consultant Oracle Cloud Platform. May, 2016

MySQL for Developers Ed 3

MySQL High Availability

Drupal 7 Sql Schema Api Datetime

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

MySQL Group Replication in a nutshell

Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, 2016

DATABASE SYSTEMS. Database programming in a web environment. Database System Course,

MySQL for Developers Ed 3

Javaentwicklung in der Oracle Cloud

Advanced Database Project: Document Stores and MongoDB

MySQL 8.0 What s New in the Optimizer

Creating and Working with JSON in Oracle Database

MySQL Cluster An Introduction

Safe Harbor Statement

MySQL Database Administrator Training NIIT, Gurgaon India 31 August-10 September 2015

Oracle Database 18c and Autonomous Database

Using MySQL Containers

MySQL for Database Administrators Ed 3.1

How we build TiDB. Max Liu PingCAP Amsterdam, Netherlands October 5, 2016

ITS. MySQL for Database Administrators (40 Hours) (Exam code 1z0-883) (OCP My SQL DBA)

Improvements in MySQL 5.5 and 5.6. Peter Zaitsev Percona Live NYC May 26,2011

InnoDB: Status, Architecture, and Latest Enhancements

High Availability Using MySQL Group Replication

Deploying Spatial Applications in Oracle Public Cloud

Oracle Application Container Cloud

Oracle 1Z0-882 Exam. Volume: 100 Questions. Question No: 1 Consider the table structure shown by this output: Mysql> desc city:

Covering indexes. Stéphane Combaudon - SQLI

State of MySQL Group Replication

MariaDB 10.3 vs MySQL 8.0. Tyler Duzan, Product Manager Percona

Why we re excited about MySQL 8

Oracle NoSQL Database Enterprise Edition, Version 18.1

What is MariaDB 5.5? w: e: Daniel Bartholomew Oct 2012

Oracle NoSQL Database Enterprise Edition, Version 18.1

MySQL Storage Engines Which Do You Use? April, 25, 2017 Sveta Smirnova

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

Mysql Tutorial Show Table Like Name Not >>>CLICK HERE<<<

Oracle APEX 18.1 New Features

Oracle Exam 1z0-883 MySQL 5.6 Database Administrator Version: 8.0 [ Total Questions: 100 ]

Docker and Oracle Everything You Wanted To Know

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2015 Lecture 14 NoSQL

SQL Gone Wild: Taming Bad SQL the Easy Way (or the Hard Way) Sergey Koltakov Product Manager, Database Manageability

NOSQL DATABASE CLOUD SERVICE. Flexible Data Models. Zero Administration. Automatic Scaling.

<Insert Picture Here> Looking at Performance - What s new in MySQL Workbench 6.2

#MySQL #oow16. MySQL Server 8.0. Geir Høydalsvik

MySQL in the Cloud: Creating a Market-Leading DBaaS

<Insert Picture Here> MySQL Web Reference Architectures Building Massively Scalable Web Infrastructure

Welcome to Virtual Developer Day MySQL!

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015

replic8 The Eighth Generation of MySQL Replication Sven Sandberg MySQL Replication Core Team Lead

JBPM Course Content. Module-1 JBPM overview, Drools overview

MySQL Port Reference

STARCOUNTER. Technical Overview

Safe Harbor Statement

Oracle 1Z MySQL 5.6 Database Administrator. Download Full Version :

MySQL Replication Update

What Is New in Optmizer and Executor?

CONTAINER CLOUD SERVICE. Managing Containers Easily on Oracle Public Cloud

WHITE PAPER. RedHat OpenShift Container Platform. Benefits: Abstract. 1.1 Introduction

InnoDB: What s new in 8.0

Oracle Enterprise Manager 12c IBM DB2 Database Plug-in

Exam Questions 1z0-882

Transcription:

Modern Development With MySQL Nicolas De Rico nicolas.de.rico@oracle.com

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.

5.7

MySQL Document Store

NoSQL JSON Cluster Document Store

New! Native JSON Data Type CREATE TABLE employees (data JSON); INSERT INTO employees VALUES ('{"id": 1, "name": "Jane"}'); INSERT INTO employees VALUES ('{"id": 2, "name": "Joe"}'); SELECT * FROM employees; +---------------------------+ data +---------------------------+ {"id": 1, "name": "Jane"} {"id": 2, "name": "Joe"} +---------------------------+ 2 rows in set (0,00 sec)

JSON Data Type Specifications utf8mb4 character set Optimized for read intensive workload Parse and validation on insert only Dictionary: Sorted objects' keys Fast access to array cells by index Full type range supported: Standard: numbers, string, bool, objects, arrays Extended: date, time, timestamp, datetime, others

SQL Example mysql> SELECT DISTINCT data-> $.zoning AS Zoning FROM lots; +--------------+ Zoning +--------------+ "Commercial" +--------------+ 1 row in set (1.22 sec) Special new syntax to access data inside JSON documents

Advantages of Native JSON Provides Document Validation: > INSERT INTO employees VALUES ('some random text'); ERROR 3130 (22032): Invalid JSON text: "Expect a value here." at position 0 in value (or column) 'some random text'. Efficient Binary Format. Allows quicker access to object members and array elements Well suited for InnoDB Barracuda file format

Naive Comparison JSON Vs. TEXT Unindexed traversal of 206K documents JSON type SELECT DISTINCT feature->"$.type" as json_extract FROM features; +--------------+ json_extract +--------------+ "Feature" +--------------+ 1 row in set (1.25 sec) TEXT type SELECT DISTINCT feature->"$.type" as json_extract FROM features; +--------------+ json_extract +--------------+ "Feature" +--------------+ 1 row in set (12.85 sec) Explanation: Binary format of JSON type is very efficient at searching. Storing as TEXT performs over 10x worse at traversal.

New! JSON Functions Functions to CREATE, SEARCH, MODIFY and RETURN JSON values: JSON_ARRAY_APPEND() JSON_ARRAY_INSERT() JSON_ARRAY() JSON_CONTAINS_PATH() JSON_CONTAINS() JSON_DEPTH() JSON_EXTRACT() JSON_INSERT() JSON_KEYS() JSON_LENGTH() JSON_MERGE() JSON_OBJECT() JSON_QUOTE() JSON_REMOVE() JSON_REPLACE() JSON_SEARCH() JSON_SET() JSON_TYPE() JSON_UNQUOTE() JSON_VALID()

New! Generated Columns id my_integer my_integer_plus_one 1 10 11 2 20 21 3 30 31 4 40 41 CREATE TABLE t1 ( id INT NOT NULL PRIMARY KEY auto_increment, my_integer INT, my_integer_plus_one INT AS (my_integer+1) ); Column automatically maintained based on your specification

JSON and Generated Columns Available as either VIRTUAL (default) or STORED: ALTER TABLE features ADD feature_type varchar(30) AS (feature->>"$.type") VIRTUAL; Query OK, 206560 rows affected (4.70 sec) Records: 206560 Duplicates: 0 Warnings: 0 Both types of computed columns permit for indexes to be added as functional indexes Use ALTER TABLE ADD INDEX(generated_column) Use virtual generated columns to index JSON fields!

Have Both Schema + Schemaless! Unstructured is usually semi-structured Some fixed-schema columns can complement flexible-schema JSON Best of both worlds performance and flexibility CREATE TABLE pc_components ( id INT NOT NULL PRIMARY KEY, description VARCHAR(60) NOT NULL, vendor VARCHAR(30) NOT NULL, serial_number VARCHAR(30) NOT NULL, attributes JSON NOT NULL );

New! NoSQL Fluent API, method chaining, stateless sessions CRUD for Collections of Documents and Tables Documents as simple basic domain objects Search expressions match SQL SELECT expressions Implemented in MySQL Shell & MySQL X DevAPI Connectors Javascript Python C# Java C++

Node.js Example // Create a new collection db.createcollection('mycollection').then(function(mycoll)) { // Insert a document mycoll.add( { name: 'Sakila', age: 21 } ).execute(); // Insert several documents at once mycoll.add( [ { name: 'Sastry', age: 45 } { name: 'Nicolas', age: 25 } ] ).execute(); }); var mydocs = mycoll.find('name like :name').bind('name', 'S%').execute();

Tables or Collections? A collection is a table with 2+ columns: Primary key: `_id` JSON document: `doc` The document s `_id` field can be supplied or automatically generated as UUID This field is also used to populate the primary key Can add extra columns and indexes to a collection SQL, NoSQL, tables, collections, all can be used simultaneously Operations compatible with replication

SHOW CREATE TABLE `mycollection`\g Table: mycollection Create Table: CREATE TABLE `mycollection` ( `doc` json DEFAULT NULL, `_id` varchar(32) GENERATED ALWAYS AS (json_unquote(json_extract(`doc`,'$._id'))) STORED NOT NULL, PRIMARY KEY (`_id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

InnoDB Cluster High Availability becomes a core first class feature of MySQL!

Shard 1 Shard 2 Long Term Goal: Automatically Sharded Document Store Application MySQL Connector Application MySQL Connector Application MySQL Connector Application MySQL Connector MySQL Router MySQL Router MySQL Router MySQL Router M HA M HA MySQL Shell M M M M S1 S2 S3 S4 S S1 S2 S3 S4 S

MySQL Document Store Built on Proven SQL/InnoDB/Replication Schema-less/Relational/Hybrid ACID/Transactions CRUD/JSON/Documents NoSQL and SQL Modern/Efficient Protocol SQL Queries/Analytics over JSON Documents Transparent and Easy HA/Scaling/Sharding

MySQL K/V Store

mysqld Memcached Plug-in for InnoDB Clients and Applications SQL Memcached protocol Memcached plug-in MySQL Server innodb_memcached optional local cache Handler API InnoDB API InnoDB storage engine

InnoDB Memcached Plug-in Tables mysql> USE innodb_memcache; mysql> SHOW TABLES; +---------------------------+ Tables_in_innodb_memcache +---------------------------+ cache_policies config_options containers +---------------------------+ mysql> USE test; mysql> SHOW TABLES; +----------------+ Tables_in_test +----------------+ demo_test +----------------+ mysql> SELECT * FROM innodb_memcache.containers\g ************* 1. row ************* name: aaa db_schema: test db_table: demo_test key_columns: c1 value_columns: c2 flags: c3 cas_column: c4 expire_time_column: c5 unique_idx_name_on_key: PRIMARY mysql> SELECT * FROM test.demo_test; +----+------------------+------+------+------+ c1 c2 c3 c4 c5 +----+------------------+------+------+------+ AA HELLO, HELLO 8 0 0 +----+------------------+------+------+------+

Basic Memcached Operations All language interfaces support the following methods for storing and retrieving cache information: Method get(key) Purpose Retrieves the value for key if the key exists set(key, value, [expiry]) add(key, value, [expiry]) replace(key, value, [expiry]) delete(key, [time]) incr(key, [value]) decr(key, [value]) flush_all() Sets existing key to provided value, or adds a new item if the key does not exist Adds a new key-value pair to cache Replaces the value associated with the key with the specified value Deletes the key-value pair Adds 1 or value to the value for specified key Subtracts 1 or value from the value for specified key Expires all items in the cache

MySQL K/V Store Built on Proven SQL/InnoDB/Replication Schema-less/Relational/Hybrid ACID/Transactions CRUD/JSON/Documents Memcached and SQL

Mobile MySQL

Geospatial Support (GIS) Spatial indexing in InnoDB R-Tree bounding box implementation Fully transactional support Currently Eucledian plan, more later CREATE GeoHash TABLE (B-Tree eventsindexing) ( name VARCHAR(100), date TIMESTAMP, location GEOMETRY, SPATIAL KEY i_location(location) ); GeoJSON format

Choosing The Nearest Event SELECT name, venue, description, date, SPATIAL KEY column thumbnail, ST_distance_sphere(POINT(@X,@Y), location) AS distance FROM events ORDER BY distance;

Choosing The Nearest Event Within 1 Mile SELECT ST_distance_sphere(POINT(@X,@Y), location) AS distance FROM events WHERE Only locations within square bounding box ST_Contains(ST_MakeEnvelope(POINT(@X+(1/69),@Y+(1/69)), POINT(@X-(1/69),@Y-(1/69))), location) ORDER BY distance; 69 miles per degree

Agile Deployment

Containers A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.

Making Your Own Containers Dockerfile where you define the container (also corresponding CLI arguments) ARG : arguments for use within the Dockerfile ENV : set environment variables for the container RUN : run command inside the container VOLUME : define volumes/mount points in the container ADD / COPY: add/copy files from the host to the container ENTRYFILE : where you define what s run in the container when it starts CMD : the process to run inside the container EXPOSE : expose ports from the container HEALTHCHECK : exec something periodically to check the health of the container

Official MySQL Containers Official Server Release product Part of each release, e.g. 5.7.20 Community and Enterprise Fully supported Containers for all products MySQL (NDB) Cluster InnoDB Cluster Router, Shell, Workbench, Utilities, MySQL Enterprise Edition

Thank you! Nicolas De Rico nicolas.de.rico@oracle.com