What's new in MySQL 5.6

26
2 copyright (c) 2012 Shlomi Noach Seminar: What's new in MySQL 5.6? Presenter: Shlomi Noach Oracle ACE MySQL Community Member http://openark.org

description

A brief overview of notable new features in MySQL 5.6; mostly user-oriented. Presented in OracleWeek, Israel, 2012.

Transcript of What's new in MySQL 5.6

Page 1: What's new in MySQL 5.6

2 copyright (c) 2012 Shlomi Noach

Seminar:What's new in MySQL 5.6?

Presenter: Shlomi NoachOracle ACEMySQL Community Memberhttp://openark.org

Page 2: What's new in MySQL 5.6

3 copyright (c) 2012 Shlomi Noach

The state of MySQL 5.6● MySQL 5.6 is being under development

since early 2011● Uses a milestone based release model:

milestone features are assumed to have RC quality

● 5.6.7 (Release Candidate) recently announced

Page 3: What's new in MySQL 5.6

4 copyright (c) 2012 Shlomi Noach

The state of MySQL 5.6● While 5.5 (first release under Oracle's stewardship)

was focused on performance, scale up and integrity, and had little focus on new features, 5.6 offers:– Loads of new usability features

– Major improvements to InnoDB architecture

– Optimizer enhancements

– Major replication improvements

– PERFORMANCE_SCHEMA: dozens new tables

Page 4: What's new in MySQL 5.6

5 copyright (c) 2012 Shlomi Noach

New in MySQL 5.6● We discuss new & noteworthy under the

following:– InnoDB

– Replication

– Optimizer

– Partitioning

Page 5: What's new in MySQL 5.6

6 copyright (c) 2012 Shlomi Noach

InnoDB● Once acquired both InnoBase and Sun

Microsystems, Oracle directed more resources at InnoDB development as integral part of MySQL

● InnoDB is today the default storage engine for MySQL

● 5.6 brings new usability, maintainability and performance improvements to InnoDB

Page 6: What's new in MySQL 5.6

7 copyright (c) 2012 Shlomi Noach

InnoDB: online DDL● Arguably the #1 reason one would want to

upgrade to 5.6● InnoDB now supports online, non-blocking

ALTER TABLE operations for many DDL statements:– ADD/MODIFY/DROP COLUMN, ADD/DROP INDEX,

ADD/DROP Foreign Keys, change of AUTO_INCREMENT, change of row format, compression, and more.

http://dev.mysql.com/doc/refman/5.6/en/innodb-online-ddl.html

Page 7: What's new in MySQL 5.6

8 copyright (c) 2012 Shlomi Noach

InnoDB: FULLTEXT● FULLTEXT indexes now available on InnoDB● Support same syntax as with MyISAM

– Boolean search– Stopwords– Proximity

● Fills the last gap for MyISAM users to migrate to InnoDB

http://dev.mysql.com/doc/refman/5.6/en/innodb-table-and-index.html#innodb-fulltext-index

Page 8: What's new in MySQL 5.6

9 copyright (c) 2012 Shlomi Noach

InnoDB: Transportable tables● “move around” InnoDB tables by copying them via

file system● Allows for fast table duplicate; fast export of table

between servers● via:

– FLUSH TABLES … FOR EXPORT– ALTER TABLE … DISCARD TABLESPACE– ALTER TABLE … IMPORT TABLESPACE

http://blogs.innodb.com/wp/2012/04/innodb-transportable-tablespaces/

Page 9: What's new in MySQL 5.6

10 copyright (c) 2012 Shlomi Noach

InnoDB: NoSQL access● It is possible to access InnoDB via memcache API

– Uses embedded memcached server

– Via standard memcache clients

– No need for SQL, avoids parsing, preparing, QEP evaluation● However fully utilizing transactions; ACID compliant!

– At current supporting single table

– memcache writes batched; may require READ UNCOMMITED on SQL side

http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached.html

Page 10: What's new in MySQL 5.6

11 copyright (c) 2012 Shlomi Noach

InnoDB: performance● InnoDB 5.6 performance improvements include:

– Preloading buffer pool (cache flush to disk)

– Adaptive REDO logs flushing

– Better, more concurrent buffer flushing

– Configurable tablespace location

– UNDO logs on separate tablespace

– Persistent stats

– More...

Page 11: What's new in MySQL 5.6

12 copyright (c) 2012 Shlomi Noach

Partitions● Introduced in 5.1● Features RANGE, LIST, HASH & KEY partitioning

– 5.1 RANGE and LIST limited to integer partitioning keys

● 5.5 introduced:– RANGE COLUMNS and LIST COLUMNS partitioning,

removing said limitation

– ALTER TABLE … TRUNCATE PARTITION

● 5.6 boasts major partition improvements

Page 12: What's new in MySQL 5.6

13 copyright (c) 2012 Shlomi Noach

Partition exchange● Swap a partition with a table of the exact

same structure– Either or both may contain data

– Allows for quick insertion or extraction of data into/from partitioned table

● via: ALTER TABLE part_tbl EXCHANGE PARTITION part_name WITH TABLE tbl;

http://dev.mysql.com/doc/refman/5.6/en/partitioning-management-exchange.html

Page 13: What's new in MySQL 5.6

14 copyright (c) 2012 Shlomi Noach

Explicit partition selection● Limit a DML statement to a specific partition or set

of partitions– Similar to partition pruning, but manual, and applies for

SELECT, UPDATE, INSERT, REPLACE, DELETE, LOAD

– Avoid partition lookup on complex search terms, or otherwise based on known heuristic

● via:UPDATE tbl PARTITION (p2, p3, p5) SET c=1 WHERE condition_holds

http://dev.mysql.com/doc/refman/5.6/en/partitioning-selection.html

Page 14: What's new in MySQL 5.6

15 copyright (c) 2012 Shlomi Noach

Partitions: lock pruning● Ever since partitions were introduced in 5.1, locking has

been an issue● Even with partition pruning, locks were held over all table

partitions– And although InnoDB uses row-level locking and is supposedly

unaffected by table locks, the lock mechanism is still invoked

– This caused for a known scenario of reduced performance on intensive INSERTs to a partitioned table

● With 5.6 this is alleviated; locks are expected to be placed only on relevant partitions.

http://dev.mysql.com/doc/refman/5.6/en/partitioning-limitations-locking.html

Page 15: What's new in MySQL 5.6

16 copyright (c) 2012 Shlomi Noach

Execution plans● Query Execution Plan (QEP) is boosted in

5.6 both internally (optimized plans) and usability-wise

● Some notorious limitations are removed, and infamous QEP scenarios now fixed

Page 16: What's new in MySQL 5.6

17 copyright (c) 2012 Shlomi Noach

Execution plans: subqueries● Up till 5.5, subqueries & derived tables:

– Evaluated as non-indexed temporary tables

– Would, in common scenarios, re-evaluate throughout the query

● select * from actor where actor_id in (select actor_id from film_actor where film_id = 7)

● 5.6 introduces:– Indexes on derived tables

– Semijoins avoid re-evaluation and skip execution phaseshttps://dev.mysql.com/doc/refman/5.6/en/semi-joins.html

Page 17: What's new in MySQL 5.6

18 copyright (c) 2012 Shlomi Noach

Execution plans: indexes● Index optimizations include:

– Index condition pushdown: better execution plans for queries where index can satisfy conditions

● This reduces MySQL-SE data transfer and allows for storage engine internal handling of conditions.

– Improved index mergehttps://dev.mysql.com/doc/refman/5.6/en/index-condition-pushdown-optimization.html

http://dev.mysql.com/doc/refman/5.6/en/index-merge-optimization.html

Page 18: What's new in MySQL 5.6

19 copyright (c) 2012 Shlomi Noach

Execution plans: EXPLAIN● EXPLAIN will now work on INSERT,

UPDATE & DELETE statements– Previously only on SELECT

– Hacks used to convert UPDATE/DELETE statements into SELECT statements so as to guess QEP. The result was not authoritative.

http://dev.mysql.com/doc/refman/5.6/en/explain.html

Page 19: What's new in MySQL 5.6

20 copyright (c) 2012 Shlomi Noach

Execution plans: EXPLAIN● EXPLAIN FORMAT=JSON is introduced

– Presenting execution plan in a JSON-tree format– Much more accurate output than EXPLAIN– Easy to parse and diagnose by automated tools

● Optimizer trace presents with actual execution steps taken after fact– Also in JSON format

http://dev.mysql.com/doc/internals/en/optimizer-tracing.html

Page 20: What's new in MySQL 5.6

21 copyright (c) 2012 Shlomi Noach

Replication● New replication features make for:

– Faster replication

– Safer replication

– Easier to maintain replication

Page 21: What's new in MySQL 5.6

22 copyright (c) 2012 Shlomi Noach

Replication: GTID● Global Transaction IDs are introduced into the binary logs,

such that every statement has a globally unique ID● A slave can connect to its master and auto-detect binlog

position via GTID● Easier to failover to another slave, or to move slaves along

replication tree● via:

CHANGE MASTER TO MASTER_AUTO_POSITION = 1http://dev.mysql.com/doc/refman/5.6/en/replication-gtids.html

Page 22: What's new in MySQL 5.6

23 copyright (c) 2012 Shlomi Noach

Multithreaded slaves● Based on a thread-per-database

– Assumes different schemas completely unrelated

● Multithreaded replication breaks the years-old “single threaded slave” paradigm– In this paradigm a slave had to do all master's work

utilizing one thread only– Very quickly leads to replication lag issues

https://blogs.oracle.com/MySQL/entry/benchmarking_mysql_replication_with_multi

Page 23: What's new in MySQL 5.6

24 copyright (c) 2012 Shlomi Noach

Crashsafe replication● “Standard” replication uses master.info and relay-

log.info files to manage records of current replication status– These files not flushed to disk upon update– Cause for replication break (or worse – integrity loss)

● With 5.6, replication status can be written to system InnoDB tables– Being transactional, these are fully ACID

http://mysqlmusings.blogspot.co.il/2011/04/crash-safe-replication.html

Page 24: What's new in MySQL 5.6

25 copyright (c) 2012 Shlomi Noach

Replication: more● Time delayed replication available via

CHANGE MASTER TO MASTER_DELAY=...● Binary log checksums allow for safer log transfer between

hosts● New set of utilities allows for easier replication maintenance● Optimized row-based replication: only transfer actual row

changes, not complete changed rowhttp://dev.mysql.com/tech-resources/articles/mysql-5.6-replication.html

Page 25: What's new in MySQL 5.6

26 copyright (c) 2012 Shlomi Noach

Thank you!● I blog at http://openark.org● Free and open source projects:

– common_schema: DBA's framework for MySQL

– openark-kit: common utilities for MySQL

– mycheckpoint: lightweight, SQL oriented monitoring for MySQL

● shlomi[at]openark.org

Page 26: What's new in MySQL 5.6

27 copyright (c) 2012 Shlomi Noach