Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

turn on mysql profiler globally

I want to profile all mysql sessions using mysql profiler, how can I turn on profiling globally?

thanks!

like image 816
makstaks Avatar asked Oct 06 '10 22:10

makstaks


People also ask

How do I find my MySQL profiling?

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.

How do I profile a query in MySQL?

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.

What is query profiling?

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.


1 Answers

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.

like image 111
Mark Madej Avatar answered Nov 11 '22 12:11

Mark Madej