Real time query monitoring on MySQL using the SYS schema

1 comment
On an earlier post I wrote about real time query monitoring on MySQL with a third party tool and without one. The script is useful as it works with MySQL 5.5 and later.
However, if you're using a later version of MySQL, you should look at the SYS schema. It is a collection of views, functions and procedures to help MySQL administrators get insight in to MySQL Database usage. It's available to install on Github and works with versions 5.6 and higher. For MySQL 5.6 you should manually install though scripts or using MySQL Workbench 6.1 or later. Since MySQL 5.7.6 the sys schema is already included.
To start using the SYS schema to check what SQL statements are being executed on a MySQL instance, open a MySQL prompt and run the following query on the 'session' view:

To find more about this view and the SYS schema, I recommend you read the following:

Don't forget to check the documentation for a complete overview, as well as the examples on project's github page.

1 comment :

  1. Check out ps_history and sys_history in my github repository -

    I'm working on a new version of sys_history that materializes data from the sys schema instead of using actual views over ps_history, but what is there should work sufficiently for now. But ps_history itself will allow you to report over time data from the performance schema, which is very cool.