What's new in MySQL 5.6


Published on

A brief overview of notable new features in MySQL 5.6; mostly user-oriented.

Presented in OracleWeek, Israel, 2012.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

What's new in MySQL 5.6

  1. 1. Seminar:Whats new in MySQL 5.6?Presenter: Shlomi NoachOracle ACEMySQL Community Memberhttp://openark.org 2 copyright (c) 2012 Shlomi Noach
  2. 2. 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 3 copyright (c) 2012 Shlomi Noach
  3. 3. The state of MySQL 5.6● While 5.5 (first release under Oracles 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 4 copyright (c) 2012 Shlomi Noach
  4. 4. New in MySQL 5.6● We discuss new & noteworthy under the following: – InnoDB – Replication – Optimizer – Partitioning 5 copyright (c) 2012 Shlomi Noach
  5. 5. 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 6 copyright (c) 2012 Shlomi Noach
  6. 6. 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 7 copyright (c) 2012 Shlomi Noach
  7. 7. 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 InnoDBhttp://dev.mysql.com/doc/refman/5.6/en/innodb-table-and-index.html#innodb-fulltext-index 8 copyright (c) 2012 Shlomi Noach
  8. 8. 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 TABLESPACEhttp://blogs.innodb.com/wp/2012/04/innodb-transportable-tablespaces/ 9 copyright (c) 2012 Shlomi Noach
  9. 9. 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 sidehttp://dev.mysql.com/doc/refman/5.6/en/innodb-memcached.html 10 copyright (c) 2012 Shlomi Noach
  10. 10. 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... 11 copyright (c) 2012 Shlomi Noach
  11. 11. 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 12 copyright (c) 2012 Shlomi Noach
  12. 12. 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 13 copyright (c) 2012 Shlomi Noach
  13. 13. 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_holdshttp://dev.mysql.com/doc/refman/5.6/en/partitioning-selection.html 14 copyright (c) 2012 Shlomi Noach
  14. 14. 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 15 copyright (c) 2012 Shlomi Noach
  15. 15. 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 16 copyright (c) 2012 Shlomi Noach
  16. 16. 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 17 copyright (c) 2012 Shlomi Noach
  17. 17. 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.htmlhttp://dev.mysql.com/doc/refman/5.6/en/index-merge-optimization.html 18 copyright (c) 2012 Shlomi Noach
  18. 18. 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 19 copyright (c) 2012 Shlomi Noach
  19. 19. 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 formathttp://dev.mysql.com/doc/internals/en/optimizer-tracing.html 20 copyright (c) 2012 Shlomi Noach
  20. 20. Replication● New replication features make for: – Faster replication – Safer replication – Easier to maintain replication 21 copyright (c) 2012 Shlomi Noach
  21. 21. 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 22 copyright (c) 2012 Shlomi Noach
  22. 22. 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 masters work utilizing one thread only – Very quickly leads to replication lag issueshttps://blogs.oracle.com/MySQL/entry/benchmarking_mysql_replication_with_multi 23 copyright (c) 2012 Shlomi Noach
  23. 23. 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 ACIDhttp://mysqlmusings.blogspot.co.il/2011/04/crash-safe-replication.html 24 copyright (c) 2012 Shlomi Noach
  24. 24. 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 25 copyright (c) 2012 Shlomi Noach
  25. 25. Thank you!● I blog at http://openark.org● Free and open source projects: – common_schema: DBAs framework for MySQL – openark-kit: common utilities for MySQL – mycheckpoint: lightweight, SQL oriented monitoring for MySQL● shlomi[at]openark.org 26 copyright (c) 2012 Shlomi Noach
  26. 26. 27copyright (c) 2012 Shlomi Noach