You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
904 B
Plaintext
34 lines
904 B
Plaintext
5 years ago
|
--
|
||
|
-- vim:ts=4:sts=4:sw=4:et:filetype=sql
|
||
|
--
|
||
|
-- Author: Hari Sekhon
|
||
|
-- Date: 2020-03-16 10:14:28 +0000 (Mon, 16 Mar 2020)
|
||
|
--
|
||
|
-- https://github.com/harisekhon/bash-tools
|
||
|
--
|
||
|
-- License: see accompanying Hari Sekhon LICENSE file
|
||
|
--
|
||
|
-- If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||
|
--
|
||
|
-- https://www.linkedin.com/in/harisekhon
|
||
|
--
|
||
|
|
||
|
-- \set PROMPT1 '%[%033[33;1m%]%x%[%033[0m%]%[%033[1m%]%/%[%033[0m%]%R%# '
|
||
|
|
||
|
-- enable timings for every query
|
||
|
\timing
|
||
|
|
||
|
-- must be loaded in postgresql.conf - https://www.postgresql.org/docs/9.4/pgstatstatements.html
|
||
|
--
|
||
|
-- call like so:
|
||
|
--
|
||
|
-- :show_slow_queries
|
||
|
--
|
||
|
-- \set show_slow_queries
|
||
|
-- 'SELECT
|
||
|
-- (total_time / 1000 / 60) as total_minutes,
|
||
|
-- (total_time/calls) as average_time, query
|
||
|
-- FROM pg_stat_statements
|
||
|
-- ORDER BY 1 DESC
|
||
|
-- LIMIT 100;'
|