- Tools
- PostgreSQL and MySQL query log analyzer
PostgreSQL and MySQL query log analyzer
Analyze slow query logs from PostgreSQL or MySQL and view them on a timeline to identify and fix performance issues.
Upload a slow query log file
To learn how to export the slow query log, see the FAQ.
Slow queries log visualizer FAQ
Yes. Your data is processed locally in the browser and is not stored or sent to any server.
Closing the browser window deletes your data automatically.
To capture slow queries in PostgreSQL:
- Open the postgresql.conf file and set the following parameters:
log_min_duration_statement = 1000 # log queries taking longer than 1 second
log_statement = 'none'
logging_collector = on log_directory = 'log'
log_filename = 'postgresql-slow.log'
- Restart PostgreSQL for the changes to take effect.
- To find the config file path, run:
psql -U postgres -c 'SHOW config_file'
To enable slow query logging in MySQL (self-hosted):
- Edit the my.cnf file and add:
slow_query_log = 1
long_query_time = 1
log_output = FILE
slow_query_log_file = /var/lib/mysql/slow.log
- Restart MySQL to apply the changes.
To enable logging without a restart, run:
SET GLOBAL slow_query_log_file = '/var/lib/mysql/slow.log';
SET GLOBAL long_query_time = 1;
SET GLOBAL slow_query_log = ON;
FLUSH LOGS;
To enable slow query logs on AWS RDS-managed instances:
MySQL:
Update your DB parameter group:
slow_query_log = 1
long_query_time = 1
log_output = FILE
Download the logs from the Logs & events tab in the RDS Console.
PostgreSQL: Update your parameter group:
log_min_duration_statement = 500
logging_collector = on
Download the logs from the Logs & events tab in the RDS Console.
To convert slow query entries from the slow_log table into a file:
mysql -h <host> -u <user> -p --raw --skip-column-names --quick --silent --no-auto-rehash --compress -e "
SELECT CONCAT(
'# Time: ', DATE_FORMAT(start_time, '%y%m%d %H:%i:%s'), '\n',
'# User@Host: ', user_host, '\n','# Query_time: ', TIME_TO_SEC(query_time), 'Rows_sent: ', rows_sent, ' Rows_examined: ', rows_examined, '\n',
'SET timestamp=', UNIX_TIMESTAMP(start_time), ';', '\n',
sql_text, ';'
) FROM mysql.slow_log;" > slow_queries.log
Replace <host> and <user> with your values.
Check the following:
- Slow query logging is enabled
- The threshold is set correctly:
long_query_timefor MySQLlog_min_duration_statementfor PostgreSQL
- The log file path is set and accessible
The log visualizer supports:
- Plaintext logs (the default format for MySQL)
- CSV logs from PostgreSQL (if CSV logging is enabled)
Make sure:
- The file follows the MySQL or PostgreSQL slow query log format
- The file is complete and not truncated or corrupted
- See the documentation for help with exporting and formatting log files