MySQL 5.6 is truly a better MySQL and reflects Oracle's commitment to the evolution of the most popular and widely
used open source database on the planet. The feature-complete 5.6 release candidate was announced at MySQL Connect in late September and the production-ready, generally available ("GA") product should be available in early 2013.
While the message around 5.6 has been focused mainly on mass appeal, advanced topics like performance/scale, high availability, and self-healing replication clusters, (http://www.mysql.com/news-and-events/web-seminars/display-733.html) MySQL 5.6 also provides many developer-friendly nuggets that
are designed to enable those who are building the next generation of web-based and embedded applications and services. Boiling down the 5.6 feature set into a smaller set, of simple, easy to use goodies designed with developer agility in mind, these things deserve a quick look:
Using semi-JOINs and late materialization, the MySQL 5.6 Optimizer delivers greatly improved subquery performance. Specifically, the optimizer is now more efficient in handling subqueries in the FROM clause; materialization of subqueries in the FROM clause is now postponed until their contents are needed during execution. Additionally, the optimizer may add an index to derived tables during execution to speed up row retrieval. Internal tests run using the DBT-3 benchmark Query #13, shown below, demonstrate an order of magnitude improvement in execution times (from days to seconds) over previous versions.
select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity)
from customer, orders, lineitem
where o_orderkey in (
group by l_orderkey
having sum(l_quantity) > 313
and c_custkey = o_custkey
and o_orderkey = l_orderkey
group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice
order by o_totalprice desc, o_orderdate
What does this mean for developers? For starters, simplified subqueries can now be coded instead of complex joins for cross table lookups:
SELECT title FROM film WHERE film_id IN
(SELECT film_id FROM film_actor
GROUP BY film_id HAVING count(*) > 12);
And even more importantly subqueries embedded in packaged applications no longer need to be re-written into joins. This is good news for both ISVs and their customers who have access to the underlying queries and who have spent development cycles writing, testing and maintaining their own versions of re-written queries across updated versions of a packaged app.
The details are in the MySQL 5.6 docs.
Online DDL Operations
Today's web-based applications are designed to rapidly evolve and adapt to meet business and revenue-generation
requirements. As a result, development SLAs are now most often measured in minutes vs days or weeks. For example, when an application must quickly support new product lines or new products within existing product lines, the backend database schema must adapt in kind, and most commonly while the application remains available for normal business operations. MySQL 5.6 supports this level of online schema flexibility and agility by providing the following new ALTER TABLE online DDL syntax additions:
- CREATE INDEX
- DROP INDEX
- Change AUTO_INCREMENT value for a column
- ADD/DROP FOREIGN KEY
- Rename COLUMN
- Change ROW FORMAT, KEY_BLOCK_SIZE for a table
- Change COLUMN NULL, NOT_NULL
- Add, drop, reorder COLUMN
Again, the details are in the MySQL 5.6 docs.
Key-value access to InnoDB via Memcached API
Many of the next generation of web, cloud, social and mobile applications require fast operations against simple
Key/Value pairs. At the same time, they must retain the ability to run complex queries against the same data, as
well as ensure the data is protected with ACID guarantees. With the new NoSQL API for InnoDB, developers have all
the benefits of a transactional RDBMS, coupled with the performance capabilities of Key/Value store.
MySQL 5.6 provides simple, key-value interaction with InnoDB data via the familiar Memcached API. Implemented via a new Memcached daemon plug-in to mysqld, the new Memcached protocol is mapped directly to the native InnoDB API and enables developers to use existing Memcached clients to bypass the expense of query parsing and go directly to InnoDB data for lookups and transactional compliant updates. The API makes it possible to re-use standard Memcached libraries and clients, while extending Memcached functionality by integrating a persistent, crash-safe, transactional database back-end. The implementation is shown here:
So does this option provide a performance benefit over SQL? Internal performance benchmarks using a customized
Java application and test harness show some very promising results with a 9X improvement in overall throughput for SET/INSERT operations:
You can follow the InnoDB team blog for the methodology, implementation and internal test cases that generated these results here.
How to get started with Memcached API to InnoDB is here.
New Instrumentation in Performance Schema
The MySQL Performance Schema was introduced in MySQL 5.5 and is designed to provide point in time metrics for key performance indicators. MySQL 5.6 improves the Performance Schema in answer to the most common DBA and Developer problems. New instrumentations include:
- What are my most resource intensive queries? Where do they spend time?
- Table/Index I/O, Table Locks
- Which application tables/indexes cause the most load or contention?
- Which application users, hosts, accounts are consuming the most resources?
- Network I/O
- What is the network load like? How long do sessions idle?
- Aggregated statistics grouped by statement, thread, user, host, account or object.
The MySQL 5.6 Performance Schema is now enabled by default in the my.cnf file with optimized and auto-tune settings that minimize overhead (< 5%, but mileage will vary), so using the Performance Schema on
a production server to monitor the most common application use cases is less of an issue. In addition, new atomic levels of instrumentation enable the capture of granular levels of resource consumption by users, hosts, accounts, applications, etc. for billing and chargeback purposes in cloud computing environments.
The MySQL docs are an excellent resource for all that is available and that can be done with the 5.6 Performance Schema.
Better Condition Handling - GET DIAGNOSTICS
MySQL 5.6 enables developers to easily check for error conditions and code for exceptions by introducing the new
MySQL Diagnostics Area and corresponding GET DIAGNOSTICS interface command. The Diagnostic Area can be populated via multiple options and provides 2 kinds of information:
Condition - which provides error codes and messages for all conditions that were returned by a previous operation
The addressable items for each are:
The new GET DIAGNOSTICS command provides a standard interface into the Diagnostics Area and can be used via the CLI or from within application code to easily retrieve and handle the results of the most recent statement execution. An example of how it is used might be:
mysql> DROP TABLE test.no_such_table;
ERROR 1051 (42S02): Unknown table 'test.no_such_table'
mysql> GET DIAGNOSTICS CONDITION 1
-> @p1 = RETURNED_SQLSTATE, @p2 = MESSAGE_TEXT;
mysql> SELECT @p1, @p2;
| @p1 | @p2 |
| 42S02 | Unknown table 'test.no_such_table' |
Options for leveraging the MySQL Diagnotics Area and GET DIAGNOSTICS are detailed in the MySQL Docs.
While the above is a summary of some of the key developer enabling 5.6 features, it is by no means exhaustive. You can dig deeper into what MySQL 5.6 has to offer by reading this developer zone article or checking out "What's New in MySQL 5.6" in the MySQL docs.
BONUS ALERT! If you are developing on Windows or are considering MySQL as an alternative to SQL Server for your next project, application or shipping product, you should check out the MySQL Installer for Windows. The installer includes the MySQL 5.6 RC database, all drivers, Visual Studio and Excel plugins, tray monitor and development tools all a single download and GUI installer.
So what are your next steps?
- Register (http://www.mysql.com/news-and-events/web-seminars/display-733.html)for Dec. 12 "MySQL Replication: Simplifying Scaling and HA with GTIDs" live web event to learn about the new Replication features in MySQL 5.6.
- Register (http://www.mysql.com/news-and-events/web-seminars/display-734.html)for Dec. 13 "MySQL 5.6: Building the Next Generation of Web-Based Applications and Services" live web event. Hurry! Seats are limited.
- Download the MySQL 5.6 Release Candidate (look under the Development Releases tab)
- Provide Feedback <link to http://bugs.mysql.com/>
- Join the Developer discussion on the MySQL Forums
- Explore (http://www.mysql.com/) all MySQL Products and Developer Tools
As always, thanks for your continued support of MySQL!