Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uwwIe-008wsU-QL for pgsql-admin@arkaria.postgresql.org; Fri, 12 Sep 2025 05:26:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uwwIb-00CLkg-Vj for pgsql-admin@arkaria.postgresql.org; Fri, 12 Sep 2025 05:26:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uwwIb-00CLjX-Ie for pgsql-admin@lists.postgresql.org; Fri, 12 Sep 2025 05:26:18 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uwwIZ-001y1f-2T for pgsql-admin@lists.postgresql.org; Fri, 12 Sep 2025 05:26:16 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3df35a67434so919723f8f.3 for ; Thu, 11 Sep 2025 22:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1757654769; x=1758259569; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=uyWQIyGznu5S75ohyRLQRT+ioG5FpE7gf7d0eTV3lB4=; b=paJK3lf76sWBrQEJT2sLQYGdi6N7G4fm9NnDoQ17WmO5984iODHu9Evg4EP3VNkYnk U4mhjyj5d1VmQRow917PNJDuO41n5HusbflQe+V8+uAiicTavrpgS4OFT81LyXM8FhTo cvaR/PVkLiJmAdqmzDs73VfPmhqGXNPzAa0A3yOUrD3PCrslm5cO8AL+sm0F224JpPIK sE00Uy+/GxHRviLvtPcoW1obc83CVeLv8n1w9Gcil8wnbNw4QjbuLoDtl9sr15wqK6yg 9Huvi6NSSS2SiJikYLy7FYslTh267mgd2HGP9T0JsVJmPXjcNMTsUHrPpedVzVPDrT3L p2Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757654769; x=1758259569; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=uyWQIyGznu5S75ohyRLQRT+ioG5FpE7gf7d0eTV3lB4=; b=O/ocbwNxdqNbL2tvI+2pv224rQC93Z1zugU/XoSAEFZPJTgZBfFknlSS2pOU1u48eG 4iwDec2lOToJldusjucrAiWVhjVl4O5O0GzTrYrMa8R/qkjUGHxCz7VSWhgEBGNthyah o+XzWpc7Fkj7KACEgwlmWavY7OYG8YQ4/5Os2suDcmsBECYkGZyVaonqHqg3uGT4IVhg ULBZYVYvOahFP9Vxt+/HDE/uDs4K2r/UEJxl2g0/sz8/x/1r2MmbyzEcb3jLTiuqs3qT 4S0KLfXM2SRin9Dogd9Aj0jt3nbeZ99sb1af4rS7FLLB4b63S+POx2fDj+EC1dCnPtGO X0vg== X-Gm-Message-State: AOJu0YxtoH/Q2bxOCPMkyKBRNRQjFy/X612pEMx9WEhWbq02eXZEeM7S /sndSLydOULxc0qC3Sd7CPLfoRsBXqzbmNepohIwkUwW0C/PPJVAOmXzLEYW7SvH3NE= X-Gm-Gg: ASbGncuZ+/nFPmFrKUhGPmxhIaRKxQg4Tsqd1z3D8A/COZieCGA3PFV6W+A9JhSwQtb Y7fHuXYol8ZUd9keEqJJxTfeHqAWtJSnbreJDnz+b063C8uASSdisnhPnSgSCm9hibFJBcayPGS ZUSRx3nTej6R+fRUZfNphFAeIDdzajyzqJdGlHYwmG24tMIz3EvpuY+6JMbjnlwn8Nb2PYo0fE4 tOMHz+m4LrBgzKkr71qAZ4bvgmwE8I2VN0gDZb8U3mp5SHmYtkbTh0F88i7uuP0netnrAxV2ylG YBkR3w5LgimiOWmFAa8rVCds6l/yh8Dca87vL/LySgztFTslR+InK0czPngzU5khRAX0wDsTiuO s8PiLqPMwh//LAi9k7U+NpEVrFDl5SfW34gXM0R/qlN1VHlrZctY3i7/2JNYOPWo= X-Google-Smtp-Source: AGHT+IG3Cw/QTqbiFfht9N3/KuKQh1Wa0vmFKOh2LSzBcrD+VCcv9GmWvYEn34S5UOYZFj6zA22opQ== X-Received: by 2002:a05:6000:3103:b0:3e7:47e3:5af0 with SMTP id ffacd0b85a97d-3e7659e7823mr1687982f8f.52.1757654769182; Thu, 11 Sep 2025 22:26:09 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:255:30a:2403:9037:2d08:c2c]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607e065fsm5170756f8f.54.2025.09.11.22.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 22:26:08 -0700 (PDT) Message-ID: <379ce1a5b087e6bcc621325d0935b771ed161d43.camel@cybertec.at> Subject: Re: Pgbouncer From: Laurenz Albe To: Raj , depesz@depesz.com Cc: Pgsql-admin Date: Fri, 12 Sep 2025 07:26:08 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2025-09-11 at 22:11 +0530, Raj wrote: > I am asking should we use pgbouncer? If so, what's the compelling situati= on > despite having postgres inbuilt timeout parameters. Timeouts and connection pooling have little to do with each other. You want timeouts so that statements and transactions cannot take too long, hog resources and damage your database. Connection pooling has a different purpose. It is necessary, because you cannot afford to have short-lived database sessions. So you want persisten= t database session, but you don't want too many of them because - the more you have, the bigger the risk of overloading the database - if you have many connections, you cannot set "work_mem" too high, which will be bad for the performance of your SQL statements - switching between processes means overhead for the kernel - the more sessions you have, the longer the snapshot PostgreSQL takes at the start of each statement will take If you have a single application server, you don't need pgBouncer. Simply use the connection pooler built into your application server. Only when yo= u start many instances of your application server (which would mean many pool= s) you need an external pooler like pgBouncer. If you want more reading material: https://www.cybertec-postgresql.com/estimating-connection-pool-size-with-po= stgresql-database-statistics/ https://www.cybertec-postgresql.com/tuning-max_connections-in-postgresql/ https://www.postgresql.eu/events/pgconfeu2022/sessions/session/3811/slides/= 327/1000_application_users.pdf Yours, Laurenz Albe