Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRhU4-0003mn-Ub for pgsql-general@arkaria.postgresql.org; Wed, 20 Dec 2017 16:44:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRhU3-0002Bi-NC for pgsql-general@arkaria.postgresql.org; Wed, 20 Dec 2017 16:44:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eRhU3-0002BZ-5p for pgsql-general@lists.postgresql.org; Wed, 20 Dec 2017 16:44:43 +0000 Received: from o168245124x4.outbound-mail.sendgrid.net ([168.245.124.4]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eRhTy-000598-KZ for pgsql-general@lists.postgresql.org; Wed, 20 Dec 2017 16:44:41 +0000 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=oss4u.com; h=from:to:cc:subject:in-reply-to:references:mime-version:content-type; s=smtpapi; bh=ibCHVNQdfpXS6AzvxFVDRG3KUgU=; b=Z3Qc3qcKBV5Rrp1w82 G2xsDFUAmM7gNLBe8XLUS5wU8+eudVAdKpxq/tgYOkibO1F4oJHZR9FjDyZRRA70 iOVkz9NSTnXdg4IvdLlU8EZ8fb3x+3yeExchiRK6cDzBUCRsk2WF9tUr/u6N4yhz CvKQhEATrONNGyP6APlNH7y8k= Received: by filter0016p3iad2.sendgrid.net with SMTP id filter0016p3iad2-6500-5A3A9374-52 2017-12-20 16:44:36.714418013 +0000 UTC Received: from gw.bunspace.com (c-24-130-43-244.hsd1.ca.comcast.net [24.130.43.244]) by ismtpd0022p1las1.sendgrid.net (SG) with ESMTP id HpocXIr0SrONqD4sg1oa6w for ; Wed, 20 Dec 2017 16:44:36.405 +0000 (UTC) Received: (qmail 12738 invoked by uid 453); 20 Dec 2017 16:44:35 -0000 X-Virus-Checked: by ClamAV 0.99.2 on bunspace.com X-Virus-Found: No Authentication-Results: bunspace.com; auth=pass (login) smtp.auth=uwe Received: from tiburon.bunspace.com (HELO tiburon.localnet) (192.168.1.4) by bunspace.com (qpsmtpd/0.96) with ESMTPSA (ECDHE-RSA-AES256-SHA encrypted); Wed, 20 Dec 2017 08:44:35 -0800 From: Uwe To: pgsql-general@lists.postgresql.org Cc: mark Subject: Re: postgresql 9.5 has ocuuered OOM Date: Wed, 20 Dec 2017 16:44:36 +0000 (UTC) Message-ID: <7244900.kHztgW4kYm@tiburon> User-Agent: KMail/5.1.3 (Linux/4.4.0-104-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <2fd6f5eb.10a25.160747856ec.Coremail.pgroad@163.com> References: <2fd6f5eb.10a25.160747856ec.Coremail.pgroad@163.com> MIME-Version: 1.0 Content-type: multipart/alternative; boundary="----------=_1513788276-27136-88" X-SG-EID: 6TR2v6KcNcEnOw+lAT2uNz00q31R1WNHCqxZtoYvwbmykWxXdfjEwVmQb/7MRkZ8+oX3yvkfp39Msc c/A8wAjhMr8pbXyHZXwzmMbTkJAR2Dxq3HjzxbfMKKvlFz655LnRkWw5pu4C7s52TptMOhULBU7wrL bvDNuxsBzfcaT1rmh5AxxoS27qvHmZZzqldJKWmZoohpSCnNWVVRpuuBFQ== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format... ------------=_1513788276-27136-88 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Wednesday, December 20, 2017 11:08:51 PM PST mark wrote: > I have set shared_buffers is 1/4 of memory. > work_mem is 2% of memory. > max_connections is 50. > momery size is 16GB. > postgresql process used over 70% of memory and occuered OOM. > what should I do to deal with this problem? IIRC work_mem is a PER CONNECTION setting, that means every connection can use 2% of your total memory. I'd try setting work_mem to something like 16MB or 32MB and see if the queries still execute properly. You want to set work_mem as high as needed to allow proper query execution but as low as possible to avoid running out of memory. ------------=_1513788276-27136-88 Content-Type: text/html; charset="us-ascii" Content-Disposition: inline Content-Transfer-Encoding: 7Bit

On Wednesday, December 20, 2017 11:08:51 PM PST mark wrote:

I have set shared_buffers is 1/4 of memory. work_mem is 2% of memory. max_connections is 50. momery size is 16GB. postgresql process used over 70% of memory and occuered OOM. what should I do to deal with this problem?

IIRC work_mem is a PER CONNECTION setting, that means every connection can use 2% of your total memory. I'd try setting work_mem to something like 16MB or 32MB and see if the queries still execute properly. You want to set work_mem as high as needed to allow proper query execution but as low as possible to avoid running out of memory.

------------=_1513788276-27136-88--