Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 686F99FBD88 for ; Wed, 13 Jun 2007 11:08:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 62417-06 for ; Wed, 13 Jun 2007 11:08:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id F012F9FBD7A for ; Wed, 13 Jun 2007 11:08:33 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l5DE8TD1009525; Wed, 13 Jun 2007 10:08:30 -0400 (EDT) To: arnaulist@andromeiberica.com cc: "pgsql-admin@postgresql.org >> \"pgsql-admin@postgresql.org\"" Subject: Re: A question about memory usage In-reply-to: <466ECFF1.1010302@androme.es> References: <466ECFF1.1010302@androme.es> Comments: In-reply-to Arnau Rebassa i Villalonga message dated "Tue, 12 Jun 2007 18:55:13 +0200" Date: Wed, 13 Jun 2007 10:08:29 -0400 Message-ID: <9524.1181743709@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/110 X-Sequence-Number: 25778 Arnau Rebassa i Villalonga writes: > I have a server with 4GB of RAM and I wanted to know how much memory > is being used by a PostgreSQL. To do so I have executed the following: > ps -A -o rss,vsz,command|grep postgres | awk '{rss += $1; vsz += $2 } > END { print "Real: ",rss/1024"MB Virtual: ",vsz/1024"MB" }' Depending on the details of your ps command, this is likely counting Postgres' shared memory area over again for each backend. It's definitely counting the executable-program image over again for each backend, even though on any modern system those pages will be shared. So it's no surprise that you get a number a lot larger than the actual RAM footprint. I don't know of any good portable way to get the number you want :-(. If your ps can distinguish shared and unshared pages, adding up all the unshared pages and counting one instance of the shared pages will be reasonably close. regards, tom lane