Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 58ACC2E003F for ; Sat, 23 Feb 2008 23:17:13 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 57392-07 for ; Sat, 23 Feb 2008 23:17:01 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.178]) by postgresql.org (Postfix) with ESMTP id EBA182E0035 for ; Sat, 23 Feb 2008 23:17:09 -0400 (AST) Received: by wa-out-1112.google.com with SMTP id m38so1198921waf.5 for ; Sat, 23 Feb 2008 19:17:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=YP7GKHNOV3LR3nxR9iexRVcjx+3Cgx6kXHx7wWlICBo=; b=wsZtjX/2diQ/pZUWkbXU1fTL9GrIuCThZI1/6QDrolOZ6mfuW0pDu9ptZqkC0sra7W8ToqJJZ+W+4hQ7BtLrtAX56+eOEI8mLByb1uf1Ab+CJDKUzU5IKkQAFLgLSdWsD+KAhkflVdGszPBdB6p9WGyzU2uc4hXFwWFGArpNQYI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=YYa8OGHE9uXaAjUB8NjyKCLN/bzsLrNj0d0nH7/t1OvLU2WMPbzrsFQ4LfdaLjeLneSTS54D4i53ZYArhVOD0rwg9JTtmxQc7ANQO/1zprCM3ql6Xuij6kKk5F3KcKex/oIXBg9Ob4uRunoZ1MCB0qpxR9zWuN3wFS9Ti7dsPd4= Received: by 10.115.46.9 with SMTP id y9mr1376436waj.129.1203823028573; Sat, 23 Feb 2008 19:17:08 -0800 (PST) Received: by 10.114.199.20 with HTTP; Sat, 23 Feb 2008 19:17:08 -0800 (PST) Message-ID: <4544e0330802231917x2045466s735989836698df2@mail.gmail.com> Date: Sat, 23 Feb 2008 21:17:08 -0600 From: "Peter Koczan" To: "Tom Lane" Subject: Re: PL/pgSQL memory consumption? Cc: "Dawid Kuroczko" , "pgsql-admin@postgresql.org" In-Reply-To: <3216.1203692055@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <758d5e7f0802220523x12a444ap679e51b990190ccc@mail.gmail.com> <3216.1203692055@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/294 X-Sequence-Number: 28368 On Fri, Feb 22, 2008 at 8:54 AM, Tom Lane wrote: > "Dawid Kuroczko" writes: > > I have recently found a nice utility called memstat (which shows how > > much of private > > (not shared)) memory each process uses. What kind of surprised me was > > the amount > > of memory that is used by PL/pgSQL (one more reason not to provide it > > by default? ;-)). > > Why should we put any credence whatsoever in these numbers? > I rather doubt that "memstat" knows anything about our palloc > mechanism, so I don't see how it could possibly give reliable > answers about how much memory one portion or another of Postgres > is using. > > Having said that, it would be interesting to know exactly what it > *is* measuring. Correct me if I'm wrong, as well, but I believe that Linux (and probably other modern Unices) does code-sharing, meaning that separate processes referring to the same code/libraries will refer to the same copy in physical memory. So, even though each process is seeing 40 MB of libpgsql, there's likely only 1 copy in physical memory. So, the total memory consumption in the system from this library is 40 MB, not 40*num_processes MB. Peter