Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duIGy-00032K-1Q for pgsql-performance@arkaria.postgresql.org; Tue, 19 Sep 2017 13:09:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1duIGx-0006cp-7W for pgsql-performance@arkaria.postgresql.org; Tue, 19 Sep 2017 13:09:07 +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 1duIGw-0006Ye-1N for pgsql-performance@postgresql.org; Tue, 19 Sep 2017 13:09:06 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1duIGp-0007Uk-9L for pgsql-performance@postgresql.org; Tue, 19 Sep 2017 13:09:04 +0000 Received: by mail-wm0-x229.google.com with SMTP id e71so5071331wmg.4 for ; Tue, 19 Sep 2017 06:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=dmaHOko5gSC1hVpnRIxAgDnPW0OsksySySrSqtNgrjU=; b=ZdyHRYqp7wXL+UTq/EMKKvJoPNR88jTYgnosW52pT29bfvM0uaPqHbCWNcgGODDwwC lngBelqTkhGbDYdVTonIvFX2bA1i4jUKGRCQI01F+/OduGRY/XQwNteUSYoPLojxEF+F QmOD25HcEvaUGE42Urkxo7CMBu013B9oQJ1jjlIhFoYdRiQjIPE6EfZ2HSyFDI6Lar6Y tZ1iCWeXR+UP4/Q0Mr6KTyGZBEggrSjbYnalt3iUjspuaVhtChEI1Ut1PHKsgVkAsyhK wqn884bKnNx5Z4NKzX+567iDjs4//F308B0k6RMp1kueEmFB+bcM3HCVbnyhWC3kfKfD OYKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dmaHOko5gSC1hVpnRIxAgDnPW0OsksySySrSqtNgrjU=; b=mdAaEfc/Ohf3LsKJCGdwSScqMNZjLXi7bVymcrPP3/gOqtXiREdVGQRK9L82VoYQS4 iE/2mt9mOt7kM5cBPRKgVEPyA1/5+uBn843oDprGc+AAvAuQQN+uC/7cz7KtTTcGH6s0 5/logf0sjzL/xNkCeur64R7885GJSYAtklMAVNo9Omug/KXLRGy+hJIRCtpu2T1n6PUM XsUrdbGlyxP5WAKT6TSt/ct57b3BV9PXKTifiE1AxXRHLbVUiClP1X/fbSe2rdC3ItC+ SBkP8+fkYF6WUnwVs8co9xcPQTyDiPGRWPN66pTLMiAq6xU+rjRSJjelD05+591nyHyO zMow== X-Gm-Message-State: AHPjjUg7VKNj0f66lzBlr5QskC8/VX+rF/EtaZIh6SRMw09PUWaopF2K 557bZ0QLwIgxUnMrPOPmTvrRvi//BifrBw2f3Z87+NOR+mkjPl1y4Ha+gB8H9T7vy8F4KothuoZ P4imDIwmpB5wNSAFZXDxdpyzK0XHoQeEQeBaY98Llkf55VXroS4aMImaBGf+IQRoLY56J0ZACjc N8Lcm/0lnT66b/WaA/ X-Google-Smtp-Source: AOwi7QAVB9KDbEUIVSXJnE7hQkrsZKBvvAwXNYV4orPscEl6iO7ZJyWE4WIgNO7s7td2eN491pKW7g== X-Received: by 10.28.236.194 with SMTP id h63mr1137364wmi.159.1505826536682; Tue, 19 Sep 2017 06:08:56 -0700 (PDT) Received: from [10.137.2.17] ([212.24.157.174]) by smtp.gmail.com with ESMTPSA id 29sm10824201wrz.77.2017.09.19.06.08.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Sep 2017 06:08:55 -0700 (PDT) Subject: Re: https://stackoverflow.com/questions/28844170/how-to-limit-the-memory-that-is-available-for-postgressql-server To: pgsql-performance@postgresql.org References: From: Tomas Vondra Message-ID: <184477af-9ac6-6a29-40c5-be2699412d84@2ndquadrant.com> Date: Tue, 19 Sep 2017 15:08:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 09/19/2017 02:49 AM, 園田祥平 wrote: > Hi experts, > > For an academic experiment I need to *restrict the total amount of > memory that is available for a pgSQL server* to compute a given set of > queries. > > I know that I can do this through |postgressql.conf|file, where I can > adjust some parameters related with Resource Management. > > The problem is that: it's not clear for me--given the several parameters > available on the config file--which is the parameter that I should change.  > > When I first opened the config file I'm expecting someting like > this: |max_server_memmory|. Instead I found a lot > of: |shared_buffers|, |temp_buffers|, |work_mem|, and so on... > > Given that, I've consulted pgSQL docs. on Resource Consumption >  and > I come up with the |shared_buffers| as the best candidate for what I'm > looking for: *the parameter that restricts the total amount of memory > that a pgSQL server can use to perform its computation*. But I'm not > completely sure about this.  > > Can you guys give me some insight about which parameters should I adjust > to restrict the pgSQL server's memory, please? > The short answer is "You can't do that from within PostgreSQL alone." You can define size of some memory buffers, but not some hard total limit. One reason is that queries may use multiple work_mem buffers, we don't know how much memory the other queries are consuming, etc. We also don't have any control over page cache, for example. If you really need to do that, you'll need to do that at the OS level, e.g. by specifying "mem=X" kernel parameter, at the VM level, or something like that. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance