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 1st7j8-00DkD4-A9 for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Sep 2024 15:45:23 +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 1st7j7-009bz9-66 for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Sep 2024 15:45:21 +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 1st7j6-009bz0-GI for pgsql-bugs@lists.postgresql.org; Tue, 24 Sep 2024 15:45:20 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1st7j3-000pmg-9V for pgsql-bugs@lists.postgresql.org; Tue, 24 Sep 2024 15:45:19 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a90349aa7e5so850424466b.0 for ; Tue, 24 Sep 2024 08:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1727192716; x=1727797516; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=iHmAHGUHU1OuVeh67wl4U73+/xbO1AMCDWbXf7D0NuE=; b=h8ffyrNv/5vBOqldT78fu3X4BsbbyhtSSvx+OsG/LdwU8jaj0LuEgLczyopxlIRHz2 0qhw/xeaJJTmck2zydQLZmMy44tmVJgE1OwveWSrJUlPxSlv1jsJ0ouhRoSgDfMF1iS7 HCXNFQ+ifUGM2zM2DflCSbBqZLNRnb1A+LToEywP/yhA7Va9k7BRoQMpQwbIU5nlQAko uD77X+022ORNZ8m4fY7hc9zN22PpqXA+PXX/g9susNiuQsyZB046revZvYn2Lg3GAszv GkTX79V22sfkFGZAXHGjl1PJDkOSHahRK3h/TbEGYqKdAMugz1xmX783eoA4/84EL149 qvoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727192716; x=1727797516; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iHmAHGUHU1OuVeh67wl4U73+/xbO1AMCDWbXf7D0NuE=; b=hWBH2Toqjx4q6mFJW+S/xAPmk4yiyR4SfrZZz9rGQh5uq7adrIoaNv0iSBk7xZmlN5 qzeMq2u8DrUyujNcNNfGRpXL8TlMhm8mwejac5Q4GwltY1QGEmeSkImID3eBVTiY7gt5 mzleQ6CZNSXMhqGjQzUYsD9nG2zIg7kUNYCU+jqETTWyTh62HM1sDnsb8k9FwcEy4I0y FNMAUvZ//V7BdoogS03du1mQeX109NSvgl/VO8zaNd01hrTf7YQ7hGvvZ+CHI/BPk6+I V4PCw8HxownMByjFdzyOOA72cBo6WCeOCeKVfKG+g+KjCI4MwTwNEhHuplzaRG5rNqFu D0IQ== X-Forwarded-Encrypted: i=1; AJvYcCVWIhlJD3ZApm5LxbzLtJA6NAqE1dKSw1d+5BZZxi+es5M1lU3DXz4IENJ4SXQrvbGHJ3cGFxPKQk09@lists.postgresql.org X-Gm-Message-State: AOJu0YyJP7zSrnjgdg8mBVKA4rKXOcKprUcEaUR3bqac442PwTJihmD2 SzEGcOF/mMPtYKlget47nC+eRSZ/mjJg1sQ+OJO7lTkgwbsGt5F+P9KqjSpK55jTJC3/TWMcyzo C X-Google-Smtp-Source: AGHT+IGRveCpkTqI8eZsGJc7LmJ8OJqRiw5oC1UHRKuQqJQCwirTVFB+KrGYCplvwYNJwVUF0QdUiA== X-Received: by 2002:a17:907:368d:b0:a8d:5133:c426 with SMTP id a640c23a62f3a-a90d5925759mr1365248966b.45.1727192715599; Tue, 24 Sep 2024 08:45:15 -0700 (PDT) Received: from dynamic-pd01.res.v6.highway.a1.net ([2001:871:5e:690b:6d50:7600:f199:2095]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93930d1126sm95869566b.114.2024.09.24.08.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 08:45:15 -0700 (PDT) Message-ID: <5f727153d2593bcd0454d4897eb387da60c90c94.camel@cybertec.at> Subject: Re: Using a lot of memory in each session. From: Laurenz Albe To: DBA , "pgsql-bugs@lists.postgresql.org" Date: Tue, 24 Sep 2024 17:45:14 +0200 In-Reply-To: <20240924075811.BDA2C10AA13@wsmtpa1.ecounterp.com> References: <20240924075811.BDA2C10AA13@wsmtpa1.ecounterp.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.4 (3.52.4-1.fc40) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2024-09-24 at 16:58 +0900, DBA wrote: > We set shared_buffer =3D 70GB, max_connections =3D 300, work_mem =3D 300M= B. >=20 > We thought the session memory could be adjusted with the work_mem variabl= e, but no. > noticed that each session consumed more than 500MB. work_mem limits the memory used by a single execution plan step, so a singl= e backend can use way more memory. Moreover, there is hash_mem_multiplier, which defaults to 2 in v15, so a hash may use twice as much memory. You didn't tell us how much RAM you have, but your setting of shared_buffer= s is probably too high, and you most likely should also reduce work_mem, particularly if you allow hundreds of connections. Anyway, I see no bug here. Yours, Laurenz Albe