Skip to content

Instantly share code, notes, and snippets.

@moraisaugusto
Last active January 28, 2021 22:15
Show Gist options
  • Save moraisaugusto/0a5870c8751649708e5a3c6e0f154113 to your computer and use it in GitHub Desktop.
Save moraisaugusto/0a5870c8751649708e5a3c6e0f154113 to your computer and use it in GitHub Desktop.
Dealing with idle connections in Azure Postgres

This changes the postgresql idle connection timeout on Azure Postgres: ref: https://techcommunity.microsoft.com/t5/azure-database-for-postgresql/connection-handling-best-practice-with-postgresql/ba-p/790883

  • idle in transaction
  • idle
  1. Connection to psql db on azure
$ psql -h HOST -p 5432 -U USER DBNAME --set=sslmode=require
  1. Change idle transaction connections (600000 = 10m)
DBNAME=> alter database DBNAME set statement_timeout = 600000;
  1. Change idle connections (300000 = 5m)
DBNAME=> alter database DBNAME set idle_in_transaction_session_timeout = 300000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment