I want to profile all mysql sessions using mysql profiler, how can I turn on profiling globally?
thanks!
Enable profiling by setting profiling to 1 or ON : mysql> SET profiling = 1; SHOW PROFILES displays a list of the most recent statements sent to the server. The size of the list is controlled by the profiling_history_size session variable, which has a default value of 15.
You can profile a query by doing following: mysql> SET SESSION profiling = 1; mysql> USE database_name; mysql> SELECT * FROM table WHERE column = 'value'; mysql> SHOW PROFILES; First line enables profiling for current mysql interactive session only. Global profiling is not recommended.
Query Profiler generates profiling results that can help you analyze and maximize query performance in SQL Server databases. The tool allows you to collect detailed statistics about executed queries, reveal and force slow queries and troubleshoot performance issues.
I think you can run these commands to enable profiling:
SET GLOBAL slow_query_log = 'ON';
SET GLOBAL slow_query_log_file = '/var/log/mysql/localhost-slow.log';
SET GLOBAL log_queries_not_using_indexes = 'ON';
SET SESSION long_query_time = 1;
SET SESSION min_examined_row_limit = 100;
The settings will not persist after you reboot the server - if you want these enabled upon the next server restart, you can add them to your my.cnf
configuration file:
[mysqld]
slow-query-log = 1
slow-query-log-file = /var/log/mysql/localhost-slow.log
long_query_time = 1
log-queries-not-using-indexes
Info from this page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With