SlideShare a Scribd company logo
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.1
Insert Picture Here
MySQL's NoSQL
Dave Stokes
MySQL Community Manager
David.Stokes@Oracle.com
@stoker
Slideshare.net/davidmstokes
Insert Picture Here
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2
Safe Harbor
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 decision. The development, release, and timing
of any features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.3
MySQL
 Most popular database on the web
 Ubiquitous
 16+ million instances
 Feeds 80% of Hadoop installs
 20 Years Old
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.4
But what
have you
done for us
lately??
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.5
http://www.thecompletelistoffeatures.com/
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.6
Relational Data
● Based on relational calculus, set theory
● Been heavily used for decades
● Many vendors
● Goal: Store data efficiently
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.7
Relational Data
● ACID (from Wikipedia https://en.wikipedia.org/wiki/ACID)
● Atomicity – requires that each transaction be "all or nothing": if one part of the
transaction fails, the entire transaction fails, and the database state is left unchanged
● Consistency – ensures that any transaction will bring the database from one valid
state to another.
● Isolation – the concurrent execution of transactions results in a system state that
would be obtained if transactions were executed serially
● Durability – means that once a transaction has been committed, it will remain so,
even in the event of power loss, crashes, or errors.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.8
So why NoSQL?!?
● A NoSQL (often interpreted as Not only SQL) database provides
a mechanism for storage and retrieval of data that is modeled in
means other than the tabular relations used in relational
databases. (https://en.wikipedia.org/wiki/NoSQL)
● Motivations for this approach include simplicity of design,
presumed better "horizontal" scaling to clusters of machine,
which is a problem for relational databases, and presumed finer
control over availability.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.9
CAP Theorem
CAP theorem states that it is impossible for a distributed computer
system to simultaneously provide all three of the following guarantees:
● Consistency (all nodes see the same data at the same time)
● Availability (a guarantee that every request receives a response about
whether it succeeded or failed)
● Partition tolerance (the system continues to operate despite arbitrary
partitioning due to network failures)
(https://en.wikipedia.org/wiki/CAP_theorem)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.10
Want BOTH! What to do?!?!?!
● Polyglot Databases – Use best storage approach for the data
● Oracle, Postgresql, MySQL, etc. all adopting some NoSQL features
● NoSQL trying to adopt SQL
● Vendors not dumb!
● Better for consumers
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.11
Access SQL
and NoSQL
One set of disks
Simultaneous access
MySQL InnoDB tables and NDB tables
Use SQL and/or Key/Value pair
2,000,000,000 writes a minute with MySQL Cluster
At the same time!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.12
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.13
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.14
Benefits
Raw performance for simple lookups. Direct access to the InnoDB storage engine avoids the
parsing and planning overhead of SQL. Running memcached in the same process space as
the MySQL server avoids the network overhead of passing requests back and forth.
Data is stored in a MySQL database to protect against crashes, outages, and corruption.
The transfer between memory and disk is handled automatically, simplifying application logic.
Data can be unstructured or structured, depending on the type of application. You can make
an all-new table for the data, or map the NoSQL-style processing to one or more existing
tables.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.15
Benefits continued
You can still access the underlying table through SQL, for reporting, analysis, ad hoc queries, bulk
loading, set operations such as union and intersection, and other operations well suited to the
expressiveness and flexibility of SQL.
You can ensure high availability of the NoSQL data by using this feature on a master server in
combination with MySQL replication.
The integration of memcached with MySQL provides a painless way to make the in-memory data
persistent, so you can use it for more significant kinds of data. You can put more add, incr, and similar
write operations into your application, without worrying that the data could disappear at any moment.
You can stop and start the memcached server without losing updates made to the cached data. To
guard against unexpected outages, you can take advantage of InnoDB crash recovery, replication, and
backup procedures.
The way InnoDB does fast primary key lookups is a natural fit for memcached single-item queries. The
direct, low-level database access path used by the memcached plugin is much more efficient for key-
value lookups than equivalent SQL queries.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.16
More Benefits Continued
The serialization features of memcached, which can turn complex data structures, binary files, or even
code blocks into storeable strings, offer a simple way to get such objects into a database.
Because you can access the underlying data through SQL, you can produce reports, search or update
across multiple keys, and call functions such as AVG() and MAX() on the memcached data. All of
these operations are expensive or complicated with the standalone memcached.
You do not need to manually load data into memcached at startup. As particular keys are requested
by an application, the values are retrieved from the database automatically, and cached in memory
using the InnoDB buffer pool.
Because memcached consumes relatively little CPU, and its memory footprint is easy to control, it can
run comfortably alongside a MySQL instance on the same system.
Because data consistency is enforced through the usual mechanism as with regular InnoDB tables,
you do not have to worry about stale memcached data or fallback logic to query the database in the
case of a missing key
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.17
Installation
mysql> install plugin daemon_memcached soname "libmemcached.so";
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.18
Here is an example using telnet to send memcached commands and receive
results through the ASCII protocol:
● telnet 127.0.0.1 11211
● set a11 10 0 9
● 123456789
● STORED
● get a11
● VALUE a11 0 9
● 123456789
● END
● quit
Set memory location 'a11'
to hold 9 characters
'123456789' – 10 & 0 are
TTL and flags
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.19
Can it be used with MySQL Replication?
Because the InnoDB memcached daemon plugin supports the
MySQL binary log, any updates made on a master server through the
memcached interface can be replicated for backup, balancing
intensive read workloads, and high availability. All memcached
commands are supported for binlogging.
You do not need to set up the InnoDB memcached plugin on the
slave servers. In this configuration, the primary advantage is
increased write throughput on the master. The speed of the
replication mechanism is not affected
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.20
With MySQL Cluster
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.21
Bypass MySQL daemon!
● 4.2 billions reads/min
● 1.2 billion updates/min
● 2 billion writes a min
● MySQL Cluster
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.22
Can MySQL Replication work with Hadoop?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.23
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.24
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.25
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.26
Native JSON Data Type
mysql> CREATE TABLE employees (data JSON);
Query OK, 0 rows affected (0,01 sec)
mysql> INSERT INTO employees VALUES ('{"id": 1, "name": "Jane"}');
Query OK, 1 row affected (0,00 sec)
mysql> INSERT INTO employees VALUES ('{"id": 2, "name": "Joe"}');
Query OK, 1 row affected (0,00 sec)
mysql> select * from employees;
+---------------------------+
| data |
+---------------------------+
| {"id": 1, "name": "Jane"} |
| {"id": 2, "name": "Joe"} |
+---------------------------+
2 rows in set (0,00 sec)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.27
Validation and Effiency
Document Validation
● Only valid JSON documents can be stored in a JSON column, so you get automatic
validation of your data. If you try to store an invalid JSON document in a JSON column, you
will get an error
Efficient Access
● JSON document in a JSON column it is stored in an optimized binary format that allows for
quicker access to object members and array elements.
● The binary format of a JSON column contains a preamble with a lookup table. The lookup
table has pointers to every key/value pair in the JSON document, sorted on the key. The
json_EXTRACT function to perform a binary search for the ‘name’ key in the table and read
the corresponding value directly, without having to parse the ‘id’ key/value pair that precedes
it within the JSON document.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.28
JSON Functions
● Manipulating JSON documents:
● json_array()
● json_object()
● json_insert()
● json_remove()
● json_set()
● json_replace()
● json_append()
● json_merge()
● json_extract()
● JSON Query:
● json_SEARCH()
● json_CONTAINS()
● json_CONTAINS_PATH()
● json_VALID()
● json_TYPE()
● json_KEYS()
● json_LENGTH()
● json_DEPTH()
● json_UNQUOTE()
● json_QUOTE()
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.29
Quick Example
mysql> desc colors;
+--------------+----------+------+-----+---------+-------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+----------+------+-----+---------+-------------------+
| popular_name | char(10) | YES | | NULL | |
| hue | json | YES | | NULL | |
+--------------+----------+------+-----+---------+-------------------+
2 rows in set (0.00 sec)
INSERT INTO `colors` VALUES ('red','{"value": "f00"}'),
('green','{"value": "0f0"}'),('blue','{"value": "00f"}'),('cyan','{"value":
"0ff"}'),('magenta','{"value": "f0f"}'),('yellow','{"value": "ff0"}'),
('black','{"value": "000"}');
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.30
Using json_extract
mysql> SELECT json_extract(hue, '$.value') FROM colors WHERE
popular_name = 'magenta';
+-----------------------------+
| json_extract(hue, '$.value') |
+-----------------------------+
| "f0f" |
+-----------------------------+
1 row in set (0.00 sec)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.31
That is great but ...
That JSON_EXTRACT stuffs seems to
make using regular MySQL Indexes pretty
messy.
● Yup, the previous query results in a full
table scan (bad)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.32
Indexing JSON Data
● Use GENERATED columns
● mysql> ALTER TABLE colors ADD value_ext char(10) GENERATED
ALWAYS AS (jsn_extract(hue, '$.value')) VIRTUAL;
● Two types of generated columns
● VIRTUAL – when read
● STORED – when written
● mysql> CRATE INDEX value_ext_index ON colors(value_ext);
● Now the query uses the index and efficiently gets data (yea!!)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.33
For More Information
● Mysql.com
● Labs.mysql.com
● Planet.mysql.com
● Thecompletelistoffeatures.com
– MySQL 5.7 new features
● Dave Stokes
David.Stokes@Oracle.com
@stoker
slideshare.net/davidmstokes

More Related Content

PDF
MySQL Utilities -- PyTexas 2015
PDF
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
PDF
PNWPHP -- What are Databases so &#%-ing Difficult
PDF
MySQL Performance Best Practices
PDF
My sql 5.6&MySQL Cluster 7.3
PPTX
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
PDF
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
PDF
MySQL Server Defaults
MySQL Utilities -- PyTexas 2015
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
PNWPHP -- What are Databases so &#%-ing Difficult
MySQL Performance Best Practices
My sql 5.6&MySQL Cluster 7.3
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
MySQL Server Defaults

What's hot (20)

PDF
MySQL JSON Functions
PDF
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
PDF
My sql 5.7-upcoming-changes-v2
PDF
Midwest PHP Presentation - New MSQL Features
PDF
MySQL 5.7 -- SCaLE Feb 2014
PDF
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014
PPTX
Confoo 2021 -- MySQL New Features
PDF
MySql's NoSQL -- best of both worlds on the same disks
ODP
MySQL 5.7 - What's new and How to upgrade
KEY
Perf Tuning Short
PDF
MySQL 5.7 in a Nutshell
PPTX
Proxysql use case scenarios fosdem17
PDF
Tx lf propercareandfeedmysql
PDF
New awesome features in MySQL 5.7
PDF
MySQL Cluster Performance Tuning - 2013 MySQL User Conference
PDF
MySQL 8.0.16 New Features Summary
PDF
MySQL Replication Update - DEbconf 2020 presentation
PDF
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
PDF
From single MySQL instance to High Availability: the journey to MySQL InnoDB ...
PDF
MySQL Group Replication
MySQL JSON Functions
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
My sql 5.7-upcoming-changes-v2
Midwest PHP Presentation - New MSQL Features
MySQL 5.7 -- SCaLE Feb 2014
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014
Confoo 2021 -- MySQL New Features
MySql's NoSQL -- best of both worlds on the same disks
MySQL 5.7 - What's new and How to upgrade
Perf Tuning Short
MySQL 5.7 in a Nutshell
Proxysql use case scenarios fosdem17
Tx lf propercareandfeedmysql
New awesome features in MySQL 5.7
MySQL Cluster Performance Tuning - 2013 MySQL User Conference
MySQL 8.0.16 New Features Summary
MySQL Replication Update - DEbconf 2020 presentation
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
From single MySQL instance to High Availability: the journey to MySQL InnoDB ...
MySQL Group Replication
Ad

Viewers also liked (20)

PDF
MySQL 5.7 Tutorial Dutch PHP Conference 2015
PDF
MySQL's NoSQL -- SCaLE 13x Feb. 20, 2015
PDF
Triangle MySQL User Group MySQL Fabric Presentation Feb 12th, 2015
PDF
MySQL's new Secure by Default Install -- All Things Open October 20th 2015
PDF
SQL For PHP Programmers
ODP
Vernieuwde acl 1
PDF
RMOUG MySQL 5.7 New Features
PDF
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
PDF
The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...
PDF
SQL For Programmers -- Boston Big Data Techcon April 27th
ODP
Linux command-line-magic-jdnl15
PDF
MySQL Workbench for DFW Unix Users Group
PPTX
MySQL Replication Alternative: Pros and Cons
PDF
SkiPHP -- Database Basics for PHP
PDF
MySQL 5.7. Tutorial - Dutch PHP Conference 2015
PPTX
Git basics
PDF
SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015
PPTX
Understanding iptables
PPTX
PPTX
Network sockets
MySQL 5.7 Tutorial Dutch PHP Conference 2015
MySQL's NoSQL -- SCaLE 13x Feb. 20, 2015
Triangle MySQL User Group MySQL Fabric Presentation Feb 12th, 2015
MySQL's new Secure by Default Install -- All Things Open October 20th 2015
SQL For PHP Programmers
Vernieuwde acl 1
RMOUG MySQL 5.7 New Features
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...
SQL For Programmers -- Boston Big Data Techcon April 27th
Linux command-line-magic-jdnl15
MySQL Workbench for DFW Unix Users Group
MySQL Replication Alternative: Pros and Cons
SkiPHP -- Database Basics for PHP
MySQL 5.7. Tutorial - Dutch PHP Conference 2015
Git basics
SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015
Understanding iptables
Network sockets
Ad

Similar to Ohio Linux Fest -- MySQL's NoSQL (20)

PDF
MySQL NoSQL APIs
PDF
NoSQL and MySQL: News about JSON
PDF
Mysql User Camp : 20-June-14 : Mysql New features and NoSQL Support
PDF
Mysql User Camp : 20th June - Mysql New Features
PDF
NoSQL and MySQL
PPTX
A Step by Step Introduction to the MySQL Document Store
PDF
MySQL Cluster
PDF
MySQL 5.6, news in 5.7 and our HA options
PDF
MySQL For Linux Sysadmins
PDF
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
PDF
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
PDF
MySQL Cluster as Transactional NoSQL (KVS)
PDF
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
ODP
Inno db 5_7_features
PPTX
OUG Scotland 2014 - NoSQL and MySQL - The best of both worlds
PDF
Introduction to MySQL
PDF
MySQL for Oracle DBAs
PDF
MySQL 5.7: Focus on InnoDB
PDF
MySQL & Oracle Linux Keynote at Open Source India 2014
PDF
NoSQL & SQL - Best of both worlds - BarCamp Berkshire 2013
MySQL NoSQL APIs
NoSQL and MySQL: News about JSON
Mysql User Camp : 20-June-14 : Mysql New features and NoSQL Support
Mysql User Camp : 20th June - Mysql New Features
NoSQL and MySQL
A Step by Step Introduction to the MySQL Document Store
MySQL Cluster
MySQL 5.6, news in 5.7 and our HA options
MySQL For Linux Sysadmins
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL Cluster as Transactional NoSQL (KVS)
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
Inno db 5_7_features
OUG Scotland 2014 - NoSQL and MySQL - The best of both worlds
Introduction to MySQL
MySQL for Oracle DBAs
MySQL 5.7: Focus on InnoDB
MySQL & Oracle Linux Keynote at Open Source India 2014
NoSQL & SQL - Best of both worlds - BarCamp Berkshire 2013

More from Dave Stokes (20)

PDF
Valkey 101 - SCaLE 22x March 2025 Stokes.pdf
PPTX
Locking Down Your MySQL Database.pptx
PPTX
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
PDF
MySQL Indexes and Histograms - RMOUG Training Days 2022
PDF
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
PDF
Windowing Functions - Little Rock Tech fest 2019
PDF
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
PPTX
Develop PHP Applications with MySQL X DevAPI
PDF
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
PDF
The Proper Care and Feeding of MySQL Databases
PDF
MySQL without the SQL -- Cascadia PHP
PDF
MySQL 8 Server Optimization Swanseacon 2018
PDF
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
PDF
Presentation Skills for Open Source Folks
PPTX
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
PPTX
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
PPTX
ConFoo MySQL Replication Evolution : From Simple to Group Replication
PDF
Advanced MySQL Query Optimizations
PPTX
Making MySQL Agile-ish
PPTX
PHP Database Programming Basics -- Northeast PHP
Valkey 101 - SCaLE 22x March 2025 Stokes.pdf
Locking Down Your MySQL Database.pptx
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
Windowing Functions - Little Rock Tech fest 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
Develop PHP Applications with MySQL X DevAPI
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
The Proper Care and Feeding of MySQL Databases
MySQL without the SQL -- Cascadia PHP
MySQL 8 Server Optimization Swanseacon 2018
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
Presentation Skills for Open Source Folks
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
ConFoo MySQL Replication Evolution : From Simple to Group Replication
Advanced MySQL Query Optimizations
Making MySQL Agile-ish
PHP Database Programming Basics -- Northeast PHP

Recently uploaded (20)

PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
innovation process that make everything different.pptx
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPT
tcp ip networks nd ip layering assotred slides
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PDF
The Internet -By the Numbers, Sri Lanka Edition
PPTX
Funds Management Learning Material for Beg
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
SAP Ariba Sourcing PPT for learning material
introduction about ICD -10 & ICD-11 ppt.pptx
Unit-1 introduction to cyber security discuss about how to secure a system
Slides PDF The World Game (s) Eco Economic Epochs.pdf
presentation_pfe-universite-molay-seltan.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
An introduction to the IFRS (ISSB) Stndards.pdf
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
innovation process that make everything different.pptx
Design_with_Watersergyerge45hrbgre4top (1).ppt
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
tcp ip networks nd ip layering assotred slides
Module 1 - Cyber Law and Ethics 101.pptx
Introuction about ICD -10 and ICD-11 PPT.pptx
Cloud-Scale Log Monitoring _ Datadog.pdf
PptxGenJS_Demo_Chart_20250317130215833.pptx
INTERNET------BASICS-------UPDATED PPT PRESENTATION
The Internet -By the Numbers, Sri Lanka Edition
Funds Management Learning Material for Beg
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION

Ohio Linux Fest -- MySQL's NoSQL

  • 1. Copyright © 2013, Oracle and/or its affiliates. All rights reserved.1 Insert Picture Here MySQL's NoSQL Dave Stokes MySQL Community Manager David.Stokes@Oracle.com @stoker Slideshare.net/davidmstokes Insert Picture Here
  • 2. Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2 Safe Harbor 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 decision. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 3. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.3 MySQL  Most popular database on the web  Ubiquitous  16+ million instances  Feeds 80% of Hadoop installs  20 Years Old
  • 4. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.4 But what have you done for us lately??
  • 5. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.5 http://www.thecompletelistoffeatures.com/
  • 6. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.6 Relational Data ● Based on relational calculus, set theory ● Been heavily used for decades ● Many vendors ● Goal: Store data efficiently
  • 7. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.7 Relational Data ● ACID (from Wikipedia https://en.wikipedia.org/wiki/ACID) ● Atomicity – requires that each transaction be "all or nothing": if one part of the transaction fails, the entire transaction fails, and the database state is left unchanged ● Consistency – ensures that any transaction will bring the database from one valid state to another. ● Isolation – the concurrent execution of transactions results in a system state that would be obtained if transactions were executed serially ● Durability – means that once a transaction has been committed, it will remain so, even in the event of power loss, crashes, or errors.
  • 8. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.8 So why NoSQL?!? ● A NoSQL (often interpreted as Not only SQL) database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases. (https://en.wikipedia.org/wiki/NoSQL) ● Motivations for this approach include simplicity of design, presumed better "horizontal" scaling to clusters of machine, which is a problem for relational databases, and presumed finer control over availability.
  • 9. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.9 CAP Theorem CAP theorem states that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees: ● Consistency (all nodes see the same data at the same time) ● Availability (a guarantee that every request receives a response about whether it succeeded or failed) ● Partition tolerance (the system continues to operate despite arbitrary partitioning due to network failures) (https://en.wikipedia.org/wiki/CAP_theorem)
  • 10. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.10 Want BOTH! What to do?!?!?! ● Polyglot Databases – Use best storage approach for the data ● Oracle, Postgresql, MySQL, etc. all adopting some NoSQL features ● NoSQL trying to adopt SQL ● Vendors not dumb! ● Better for consumers
  • 11. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.11 Access SQL and NoSQL One set of disks Simultaneous access MySQL InnoDB tables and NDB tables Use SQL and/or Key/Value pair 2,000,000,000 writes a minute with MySQL Cluster At the same time!
  • 12. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.12
  • 13. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.13
  • 14. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.14 Benefits Raw performance for simple lookups. Direct access to the InnoDB storage engine avoids the parsing and planning overhead of SQL. Running memcached in the same process space as the MySQL server avoids the network overhead of passing requests back and forth. Data is stored in a MySQL database to protect against crashes, outages, and corruption. The transfer between memory and disk is handled automatically, simplifying application logic. Data can be unstructured or structured, depending on the type of application. You can make an all-new table for the data, or map the NoSQL-style processing to one or more existing tables.
  • 15. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.15 Benefits continued You can still access the underlying table through SQL, for reporting, analysis, ad hoc queries, bulk loading, set operations such as union and intersection, and other operations well suited to the expressiveness and flexibility of SQL. You can ensure high availability of the NoSQL data by using this feature on a master server in combination with MySQL replication. The integration of memcached with MySQL provides a painless way to make the in-memory data persistent, so you can use it for more significant kinds of data. You can put more add, incr, and similar write operations into your application, without worrying that the data could disappear at any moment. You can stop and start the memcached server without losing updates made to the cached data. To guard against unexpected outages, you can take advantage of InnoDB crash recovery, replication, and backup procedures. The way InnoDB does fast primary key lookups is a natural fit for memcached single-item queries. The direct, low-level database access path used by the memcached plugin is much more efficient for key- value lookups than equivalent SQL queries.
  • 16. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.16 More Benefits Continued The serialization features of memcached, which can turn complex data structures, binary files, or even code blocks into storeable strings, offer a simple way to get such objects into a database. Because you can access the underlying data through SQL, you can produce reports, search or update across multiple keys, and call functions such as AVG() and MAX() on the memcached data. All of these operations are expensive or complicated with the standalone memcached. You do not need to manually load data into memcached at startup. As particular keys are requested by an application, the values are retrieved from the database automatically, and cached in memory using the InnoDB buffer pool. Because memcached consumes relatively little CPU, and its memory footprint is easy to control, it can run comfortably alongside a MySQL instance on the same system. Because data consistency is enforced through the usual mechanism as with regular InnoDB tables, you do not have to worry about stale memcached data or fallback logic to query the database in the case of a missing key
  • 17. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.17 Installation mysql> install plugin daemon_memcached soname "libmemcached.so";
  • 18. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.18 Here is an example using telnet to send memcached commands and receive results through the ASCII protocol: ● telnet 127.0.0.1 11211 ● set a11 10 0 9 ● 123456789 ● STORED ● get a11 ● VALUE a11 0 9 ● 123456789 ● END ● quit Set memory location 'a11' to hold 9 characters '123456789' – 10 & 0 are TTL and flags
  • 19. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.19 Can it be used with MySQL Replication? Because the InnoDB memcached daemon plugin supports the MySQL binary log, any updates made on a master server through the memcached interface can be replicated for backup, balancing intensive read workloads, and high availability. All memcached commands are supported for binlogging. You do not need to set up the InnoDB memcached plugin on the slave servers. In this configuration, the primary advantage is increased write throughput on the master. The speed of the replication mechanism is not affected
  • 20. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.20 With MySQL Cluster
  • 21. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.21 Bypass MySQL daemon! ● 4.2 billions reads/min ● 1.2 billion updates/min ● 2 billion writes a min ● MySQL Cluster
  • 22. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.22 Can MySQL Replication work with Hadoop?
  • 23. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.23
  • 24. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.24
  • 25. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.25
  • 26. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.26 Native JSON Data Type mysql> CREATE TABLE employees (data JSON); Query OK, 0 rows affected (0,01 sec) mysql> INSERT INTO employees VALUES ('{"id": 1, "name": "Jane"}'); Query OK, 1 row affected (0,00 sec) mysql> INSERT INTO employees VALUES ('{"id": 2, "name": "Joe"}'); Query OK, 1 row affected (0,00 sec) mysql> select * from employees; +---------------------------+ | data | +---------------------------+ | {"id": 1, "name": "Jane"} | | {"id": 2, "name": "Joe"} | +---------------------------+ 2 rows in set (0,00 sec)
  • 27. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.27 Validation and Effiency Document Validation ● Only valid JSON documents can be stored in a JSON column, so you get automatic validation of your data. If you try to store an invalid JSON document in a JSON column, you will get an error Efficient Access ● JSON document in a JSON column it is stored in an optimized binary format that allows for quicker access to object members and array elements. ● The binary format of a JSON column contains a preamble with a lookup table. The lookup table has pointers to every key/value pair in the JSON document, sorted on the key. The json_EXTRACT function to perform a binary search for the ‘name’ key in the table and read the corresponding value directly, without having to parse the ‘id’ key/value pair that precedes it within the JSON document.
  • 28. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.28 JSON Functions ● Manipulating JSON documents: ● json_array() ● json_object() ● json_insert() ● json_remove() ● json_set() ● json_replace() ● json_append() ● json_merge() ● json_extract() ● JSON Query: ● json_SEARCH() ● json_CONTAINS() ● json_CONTAINS_PATH() ● json_VALID() ● json_TYPE() ● json_KEYS() ● json_LENGTH() ● json_DEPTH() ● json_UNQUOTE() ● json_QUOTE()
  • 29. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.29 Quick Example mysql> desc colors; +--------------+----------+------+-----+---------+-------------------+ | Field | Type | Null | Key | Default | Extra | +--------------+----------+------+-----+---------+-------------------+ | popular_name | char(10) | YES | | NULL | | | hue | json | YES | | NULL | | +--------------+----------+------+-----+---------+-------------------+ 2 rows in set (0.00 sec) INSERT INTO `colors` VALUES ('red','{"value": "f00"}'), ('green','{"value": "0f0"}'),('blue','{"value": "00f"}'),('cyan','{"value": "0ff"}'),('magenta','{"value": "f0f"}'),('yellow','{"value": "ff0"}'), ('black','{"value": "000"}');
  • 30. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.30 Using json_extract mysql> SELECT json_extract(hue, '$.value') FROM colors WHERE popular_name = 'magenta'; +-----------------------------+ | json_extract(hue, '$.value') | +-----------------------------+ | "f0f" | +-----------------------------+ 1 row in set (0.00 sec)
  • 31. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.31 That is great but ... That JSON_EXTRACT stuffs seems to make using regular MySQL Indexes pretty messy. ● Yup, the previous query results in a full table scan (bad)
  • 32. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.32 Indexing JSON Data ● Use GENERATED columns ● mysql> ALTER TABLE colors ADD value_ext char(10) GENERATED ALWAYS AS (jsn_extract(hue, '$.value')) VIRTUAL; ● Two types of generated columns ● VIRTUAL – when read ● STORED – when written ● mysql> CRATE INDEX value_ext_index ON colors(value_ext); ● Now the query uses the index and efficiently gets data (yea!!)
  • 33. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.33 For More Information ● Mysql.com ● Labs.mysql.com ● Planet.mysql.com ● Thecompletelistoffeatures.com – MySQL 5.7 new features ● Dave Stokes David.Stokes@Oracle.com @stoker slideshare.net/davidmstokes