MySQL Performance Schema vs SQL Server DMVs

By Tom Nonmacher

In the ever-evolving world of database technology, having the right tools for performance analysis is crucial. Two such tools are MySQL's Performance Schema and SQL Server's Dynamic Management Views (DMVs). Both provide valuable insights into the functionality of your databases, but each has its own unique strengths and weaknesses. This blog post will explore these tools, comparing and contrasting their capabilities and usage.

Performance Schema was introduced in MySQL 5.5 and has been significantly improved in MySQL 5.6. It provides a way to inspect internal execution of the server at runtime, with a focus on performance. It is implemented as a storage engine and collects data about server execution while having minimal impact on overall server performance. Here's a sample snippet of how you might use Performance Schema to get a count of table locks:

SELECT OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, SUM_TIMER_WAIT
FROM performance_schema.table_lock_waits_summary_by_table
WHERE SUM_TIMER_WAIT > 0;

On the other hand, SQL Server DMVs, available in SQL Server 2012 and later, offer a window into the performance and health of SQL Server instances. DMVs return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance. Here's a sample T-SQL query to find the top 5 most expensive queries:

SELECT TOP 5 sql_text.text,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(req.sql_handle) AS sql_text
ORDER BY req.total_elapsed_time DESC;

While both tools provide similar functionality, there are notable differences. Performance Schema is always on, while DMVs must be enabled. Additionally, DMVs provide a historical view of server performance, while Performance Schema provides a present snapshot. This is an essential consideration when deciding which tool to use for performance analysis.

Another significant difference lies in the areas of focus. While Performance Schema focuses on server execution, DMVs provide a broader range of information, including index usage statistics, query execution plans, and IO statistics. This makes DMVs a more comprehensive tool for performance analysis.

In conclusion, both MySQL Performance Schema and SQL Server DMVs are powerful tools for performance analysis. Whether you are using MySQL 5.6, SQL Server 2012/2014, DB2 10.5, or Azure SQL, understanding the features and limitations of these tools will enable you to better diagnose and resolve performance issues in your databases. Choose the one best suited to your specific needs.




8517F5
Please enter the code from the image above in the box below.