A small script to find slow queries from Postgresql log.
- Build it:
$ mix escript.build
- Parse the log file:
$ ./slow_query_finder <log_file>
ex: $ ./slow_query_finder postgresql.log.2016-06-16-02
Postgres logs slow query by a duration
keyword with a process id, such as:
2016-06-16 02:18:27 xxxxxxx:[10422]:LOG: execute xxxxx: SELECT * FROM users
... a lot of lines between the lines
2016-06-16 02:18:27 xxxxxxx:[10422]:LOG: duration: 1043.358 ms
SlowQueryFinder
find slow queries by:
- Find the process id of log with
duration
keyword - Find the query with the same process id which is nearest and before the
duration
line.
- Run test by:
$ mix espec
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
MIT