Skip to content

Instantly share code, notes, and snippets.

@benoittgt
Created August 7, 2023 09:28
Show Gist options
  • Save benoittgt/1c7e50ce6a51e06f11501f79e4704a04 to your computer and use it in GitHub Desktop.
Save benoittgt/1c7e50ce6a51e06f11501f79e4704a04 to your computer and use it in GitHub Desktop.
How to fetch slower queries in postgresql logs (from RDS)
You well get query that greater than 5000ms with the next line that as often query parameter if you use prepared statements. This commande requires ripgrep.
rg --pcre2 '[6-9][0-9][0-9][0-9]\.[0-9][0-9][0-9] ms.*' -A=1
Get queries that timeout, exclude the one with a COUNT but with a filter on `rented_at`
rg --pcre2 'STATEMENT: SELECT(?:(?!COUNT).)*rented_at >'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment