MySQL 5.7: Introduction for Operational DBAs · Peter Zaitsev, CEO, Percona February 16, 2016 Percona Technical Webinars MySQL 5.7 For Operational DBAs an Introduction

Post on 16-Jul-2020

5 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

Peter Zaitsev, CEO, Percona

February 16, 2016 Percona Technical Webinars

MySQL 5.7 For Operational DBAs an Introduction

www.percona.com 2

MySQL 5.7 is Great!

A lot of Worthy Changes for

Developers and DBAs

www.percona.com 3

What Developers Care about?

• JSON • GIS • Full Text Search Improvements

• Better Optimizer

Things they can use

while developing applications

www.percona.com 4

What DBAs Care About ?

Performance

Availability

Security

Agility

Visibility

Architecture

www.percona.com 5

Today

We focus on MySQL 5.7 for Operational

DBAs

www.percona.com 6

Performance Going Faster; Scaling Better

www.percona.com 7

High Concurrency

*Information from Oracle OpenWorld presentation by Geir Hoydalsvik

Starts with 8 Threads What about 2-4 threads?

www.percona.com 8

MySQL 5.7: Single-threaded workload

§  Multi-threaded workload looks great §  Single-threaded workload shows some regression https://bugs.mysql.com/bug.php?id=68825

http://smalldatum.blogspot.co.uk/2014/10/single-thread-performance-in-mysql-575.html

www.percona.com 9

Transparent Page Compression

Rely on File System “Hole Punching”

Much Simpler

File systems may have problems having “Hole” for each page

www.percona.com 10

Disk usage (Linkbench data set by Sunny Bains)

10

www.percona.com 11

Performance on Fast SSD (FusionIO NVMFS)

11

www.percona.com 12

Results on Slower SSD (Intel 730*2, EXT4)

12

www.percona.com 13

Parallel (MTS) Replication

•  Can run multiple parallel workers on the slave

•  Works even for one table !

www.percona.com 14

Speedup (by Vitor Oliveira)

www.percona.com 15

Improved Optimizer

UNION ALL Does not use TMP Table

Subqueries in FROM Clause handles same as in VIEW

Better Cost Model

Refactored Prepared Statements

Refactored Query Parser

www.percona.com 16

Can Change Costs

www.percona.com 17

New Hints

•  Try out different plans easily

www.percona.com 18

Innodb Temporary Tables

Separate Tablespace

No Redo Logging

No Change Buffering

Less Locking

Better performance than MyISAM

www.percona.com 19

Internal Oracle Benchmark

•  Sysbench OLTP read only

www.percona.com 20

Improved Index Creation

Up to 3x faster Index Build Speed

www.percona.com 21

Native Innodb Partitioning

Better performance with many partitions

Less memory usage with many partitions

www.percona.com 22

Availability Stay Up, Do not lose Data, Recover Faster

www.percona.com 23

Semi-Sync Replication

•  Eliminate loss of “visible” data •  rpl_semi_sync_master_wait_point=AFTER_SYNC •  Better Semi-Sync Performance As well

www.percona.com 24

Statement Timeout

Do not let run-away queries kill your server

SET GLOBAL MAX_STATEMENT_TIME=100;

Works for Read-Only Statements only

www.percona.com 25

Online GTID Deployment

Enable GTID without need to shut down Master and Slaves

www.percona.com 26

Improved Innodb Crash Recovery

Especially with many tables with

innodb_file_per_table

www.percona.com 27

Security Keep System Secure

www.percona.com 28

Secure by Default

•  No anonymous user •  Only root@localhost

created •  With secure random

password •  Password Strength

enforced

Install with

better security

by default

www.percona.com 29

AES256 Encryption •  SET block_encryption_mode = 'aes-256-cbc'; •  SET @key_str = SHA2('My secret passphrase',512); •  SET @init_vector = RANDOM_BYTES(16); •  SET @crypt_str =

AES_ENCRYPT('text',@key_str,@init_vector);

www.percona.com 30

Password

•  Password Strength Enforcement

•  Password Expiration Enforcement

•  SET GLOBAL default_password_lifetime = 180; •  ALTER USER 'jeffrey'@'localhost' PASSWORD

EXPIRE INTERVAL 90 DAY; •  ALTER USER 'jeffrey'@'localhost' PASSWORD

EXPIRE NEVER;

www.percona.com 31

LOCK/UNLOCK Accounts

•  Can Lock account for whatever reason •  ALTER USER locked@localhost ACCOUNT

LOCK; •  Locked Users

•  Logged to the error log •  Locked_connects incremented

www.percona.com 32

Easier to use SSL

SSL Enabled by default

Easier to configure SSL

www.percona.com 33

Tablespace Encryption

•  Fresh in MySQL 5.7.11 •  CREATE TABLE t1 (c1 INT)

ENCRYPTION='Y'; •  Only Tablespace content is encrypted at

this point

www.percona.com 34

Agility Implement Changes Faster

www.percona.com 35

More Online ALTER TABLE

Enlarge VARCHAR

Rename Index

www.percona.com 36

Dynamic Variables

New Variables are mostly Dynamic

Old Variables are being converted

www.percona.com 37

Online Buffer Pool Resize

•  Chunk for Resize •  innodb_buffer_pool_chunk_size

•  SET  GLOBAL  innodb_buffer_pool_size=4*1024*1024*1024;  

 http://dev.mysql.com/doc/refman/5.7/en/innodb-­‐buffer-­‐pool-­‐online-­‐resize.html    

www.percona.com 38

Warm not Hot

www.percona.com 39

Query Rewrite Plugin

• Rewrite them to nice ones

• Or make to cause and error

Have developers

running nasty

queries ?

www.percona.com 40

Mysqldump -> mysqlpump

Parallel MySQLDump

Not as parallel as mydumper

www.percona.com 41

Automatic Undo Space Management

•  Protection from run-away undo space •  Works only when dedicated undo

tablespaces are used •  innodb_undo_tablespaces=4 •  innodb_undo_log_truncate=ON; •  innodb_max_undo_log_size=1G

www.percona.com 42

Visibility Prevent Problems; Resolve them faster

www.percona.com 43

Performance Schema improvements

Memory Instrumentations

Memory used (bytes)

Operation counts Type of memory

used (caches, internal buffers, etc)

Statement Instrumentations

Stored Procedures

Stored Functions Prepared

Statements Transactions

Other Instrumentation

Replication slave status

MDL lock instrumentation

User variables per thread

Server stage tracking

Track long running SQL

www.percona.com 44

SYS Schema Included in MySQL 5.7

Get the memory usage per user with SYS schema:        

mysql>  update  performance_schema.setup_instruments    set  enabled='YES',  timed='YES'    where  name  like  'memory/%';  Query  OK,  375  rows  affected  (0.00  sec)  Rows  matched:  375    Changed:  375    Warnings:  0      mysql>  select  *  from  sys.memory_global_total\G  ***************************  1.  row  ***************************  total_allocated:  90.20  MiB  1  row  in  set  (0.01  sec)    

mysql>  select  *  from  sys.memory_by_user_by_current_bytes\G  ***************************  1.  row  ***************************                              user:  root  current_count_used:  42    current_allocated:  361.03  KiB    current_avg_alloc:  8.60  KiB    current_max_alloc:  248.04  KiB        total_allocated:  46.34  GiB  ***************************  2.  row  ***************************                              user:  background  current_count_used:  0    current_allocated:  0  bytes    current_avg_alloc:  0  bytes    current_max_alloc:  0  bytes        total_allocated:  14.72  KiB  2  rows  in  set  (0.01  sec)  

www.percona.com 45

Better Integration with OS

www.percona.com 46

INNODB_METRICS

www.percona.com 47

INFORMATION_SCHEMA

www.percona.com 48

Explain on a Running Query

mysql>  show  processlist\G  ...            Id:  8  Command:  Query        Time:  90      State:  Sending  data        Info:  select  count(*),  osm_id  from  points_new  group  by  osm_id    mysql>  explain  for  connection  8\G    ***************************  1.  row  ***************************                        id:  1      select_type:  SIMPLE                  table:  points_new        partitions:  NULL                    type:  ALL  possible_keys:  NULL                      key:  NULL              key_len:  NULL                      ref:  NULL                    rows:  11368798            filtered:  100.00                  Extra:  Using  temporary;  Using  filesort    

 

Shows query plan on connection <id> Applicable for SELECT/INSERT/DELETE/UPDATE

www.percona.com 49

JSON Explain

www.percona.com 50

Architecture Architect Better Applications

www.percona.com 51

JSON Datatype

Build Hybrid SQL-Document based applications

Optimized Binary Internal Storage

Optimizer Support for JSON references

www.percona.com 52

Multi Source Replication

Master > Slave

Masters > Slave (Multi-Source), Since 5.7

Master > Slaves

Master > Slave > Slaves

•  Now 1 replication slave can have many master servers! •  Important for BI/Data Science/Ad-hoc analytics

www.percona.com 53

Generated Columns

Define Column as function of other columns

Can be persistent or always computed

Can be indexed (even if virtual)

total_eur DOUBLE AS (price_eur * amount),

www.percona.com 54

Multiple Triggers on same event

Allows Developers to create triggers independently

CREATE TRIGGER t1_bi_1_1 BEFORE INSERT ON t1 FOR EACH ROW FOLLOWS t1_bi

www.percona.com 55

Additional Information You want to know this too

www.percona.com 56

Time to kill MyISAM Feature MyISAM InnoDB

Full Text Indexes yes Since MySQL 5.6

Portable tables (tablespaces) yes Since MySQL 5.6

Spatial Indexes/RTREE (GIS) yes Since MySQL 5.7

Last update for table yes Since MySQL 5.7 (http://dev.mysql.com/worklog/task/?id=6658)

Suitable for temp tables yes Since MySQL 5.7 Also complex selects uses InnoDB ondisk temp tables

Fast count(*) yes *Faster in MySQL 5.7 but does not store counter

www.percona.com 57

Defaults Changes

•  sql_mode •  binlog_format=ROW •  Innodb_file_format=barracuda •  Innodb_checksum_algorithm=crc32

Number of

Important Changes

www.percona.com 58

Comple list of Features ?

•  There are more than 150! •  Great list maintained by Morgan

Tocker •  http://www.thecompletelistoffeatures.com/

www.percona.com 59

Percona Server 5.7 Better way to access MySQL 5.7 Features

www.percona.com 60

Percona Server 5.7

All MySQL 5.7 Community

features included

Alternatives to many “Enterprise

Only” features

100% GPL with no restrictions

RC2 Out now. GA Imminent

www.percona.com 61

Even More Visibility

Low Overhead Table/User/Index access statistics

Query Response Time Analyses

Enhanced Slow Query Log

More Information Schema Tables

www.percona.com 62

Query Response Time example

www.percona.com 63

More Control

Utility User for DBaaS Deployment

Enforcing Storage Engine

Set Variable for Statement

www.percona.com 64

Variable for Statement Example

SET STATEMENT sort_buffer_size=100000,

max_statement_time=1000 FOR SELECT name FROM name ORDER

BY name;

www.percona.com 65

Enterprise Security

PAM Authentication

Plugin Audit Plugin

www.percona.com 66

Better Performance

Low impact backups with Backup Locks

True Incremental Backups with Change Tracking

Scale to 10K+ connections with ThreadPool

Ongoing work Optimizing for real customer workloads

www.percona.com 67

TokuDB Storage Engine

The only Mature Transactional

Storage engine alternative to Innodb

Write Optimized High Compression

Great with Slow Storage

Saves money in the Cloud

www.percona.com 68

Can get a lot of compression 68

www.percona.com 69 www.percona.com

Percona Live Data Performance Conference

•  April 18-21 in Santa Clara, CA at the Santa Clara Convention Center

•  Register with code “WebinarPL” to receive 15% off at registration

•  MySQL, NoSQL, Data in the Cloud

www.perconalive.com

www.percona.com 70 www.percona.com

Peter Zaitsev pz@percona.com

@PeterZaitsev bit.ly/PerconaJobs

Thank You!

top related