Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z4Vpx-0006j3-EZ for pgsql-performance@arkaria.postgresql.org; Mon, 15 Jun 2015 14:58:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z4Vpw-0001KA-Ga for pgsql-performance@arkaria.postgresql.org; Mon, 15 Jun 2015 14:58:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z4Vpv-0001K1-Dw for pgsql-performance@postgresql.org; Mon, 15 Jun 2015 14:58:07 +0000 Received: from mail-ig0-f177.google.com ([209.85.213.177]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z4Vpn-0007zb-GU for pgsql-performance@postgresql.org; Mon, 15 Jun 2015 14:58:06 +0000 Received: by igblz2 with SMTP id lz2so52272379igb.1 for ; Mon, 15 Jun 2015 07:57:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=0v1GBkPhebRysn6epuZ4WYY38xduR5L7740fLbawURs=; b=O52r1hEIwguTN2jN5TLKD53x1svqScBQzdb+/FBRgjlCX3xtswXehGUZAk6hIPPPdF n4Osn3N9scE1X+Jpg2E2rx2S3rHpc+x1GHJNOBeUcO8ZA94LdAt9Y3onZNFKyEpdME3K dODjXzOsnbjr7suitjYOHelBKTcX8SigAziGLBhCD20S5OjnNGJjrcKUlZeIOAQKJVPI GhrYBvsyU28KIyc4BeEI+vR4GoYY5BRvgG7dtsDV+o0zPs12FcETfSUDQ4DiI7MW4BmY 4F5ZTZTvMpVzhpqQKoNpk96L5+3doZxN2oq9b0mE7BvoHCKnQDBC1ZDND+orJ83WJ5FG 03LA== X-Gm-Message-State: ALoCoQlhkE2taOkFljK0rexh0LNjMf+qxOM6HJIMKDBDnYrLrKPJaemq6veOcAuFdLF1l+OGHF4FsXWNjG7jpVA9Sifj91DYqUAbqz/oazgp2udGHlo3bk6yevUmlc90on3j6P27qtGAcMhN7NWeB3kKmSU+2cn1GXSQdRKcAX3PjBgm7fmc/z7/lX8+Vs/L62G04nbA7inEoRJ35zaQhxUIMRS8ENs9/Q== X-Received: by 10.50.114.40 with SMTP id jd8mr7277560igb.47.1434380276264; Mon, 15 Jun 2015 07:57:56 -0700 (PDT) Received: from [10.137.2.12] (BW-VICTORIA-PARK-OTTAWA.SITES.INTELLO.COM. [216.13.52.59]) by mx.google.com with ESMTPSA id a139sm8985244ioa.14.2015.06.15.07.57.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jun 2015 07:57:55 -0700 (PDT) Message-ID: <557EE7F1.9000901@2ndquadrant.com> Date: Mon, 15 Jun 2015 16:57:53 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Do work_mem and shared buffers have 1g or 2g limit on 64 bit linux? References: <557C6BA8.7030805@commandprompt.com> <557C7213.8000704@joeconway.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 06/15/15 05:44, Kaijiang Chen wrote: > I've checked the source codes in postgresql 9.2.4. In function > static bool > grow_memtuples(Tuplesortstate *state) > > the codes: > /* > * On a 64-bit machine, allowedMem could be high enough to get us into > * trouble with MaxAllocSize, too. > */ > if ((Size) (state->memtupsize * 2) >= MaxAllocSize / sizeof(SortTuple)) > return false; > > Note that MaxAllocSize == 1GB - 1 > that means, at least for sorting, it uses at most 1GB work_mem! And > setting larger work_mem has no use at all... That's not true. This only limits the size of 'memtuples' array, which only stores pointer to the actual tuple, and some additional data. The tuple itself is not counted against MaxAllocSize directly. The SortTuple structure has ~24B which means you can track 33M tuples in that array, and the tuples may take a lot more space. 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