X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8F364D704F for ; Tue, 23 Aug 2005 14:26:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01799-05 for ; Tue, 23 Aug 2005 17:26:18 +0000 (GMT) Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) by svr1.postgresql.org (Postfix) with ESMTP id 96673D6F66 for ; Tue, 23 Aug 2005 14:26:14 -0300 (ADT) Received: from juju.arbash-meinel.com ([12.214.18.81]) by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP id <20050823172613m9100g70one>; Tue, 23 Aug 2005 17:26:13 +0000 Received: by juju.arbash-meinel.com (Postfix, from userid 505) id 75C5B55FA6; Tue, 23 Aug 2005 12:26:13 -0500 (CDT) Received: from [10.10.0.181] (unknown [85.20.238.130]) by juju.arbash-meinel.com (Postfix) with ESMTP id 9B9CC55F9C; Tue, 23 Aug 2005 12:26:01 -0500 (CDT) Message-ID: <430B5C27.9030007@arbash-meinel.com> Date: Tue, 23 Aug 2005 12:25:59 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: gokulnathbabu manoharan Cc: pgsql-performance@postgresql.org Subject: Re: Caching by Postgres References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> In-Reply-To: <20050823171045.12112.qmail@web51309.mail.yahoo.com> X-Enigmail-Version: 0.92.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig6B9A2DFC2643B98ED6BD6B74" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/345 X-Sequence-Number: 14092 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6B9A2DFC2643B98ED6BD6B74 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit gokulnathbabu manoharan wrote: > Hi all, > > I like to know the caching policies of Postgresql. > What parameter in the postgresql.conf affects the > cache size used by the Postgresql? As far as I have > searched my knowledge of the parameters are In general, you don't. The OS handles caching based on file usage. So if you are using the files, the OS should cache them. Just like it does with any other program. > > 1. shared_buffers - Sets the limit on the amount of > shared memory used. If I take this is as the cache > size then my performance should increase with the > increase in the size of shared_buffers. But it seems > it is not the case and my performance actually > decreases with the increase in the shared_buffers. I > have a RAM size of 32 GB. The table which I use more > frequently has around 68 million rows. Can I cache > this entire table in RAM? There is a portion of this which is used for caching. But I believe before 8.1 there was code that went linearly through all of the shared_buffers and checked for dirty/clean pages. So there was a tradeoff that the bigger you make it, the longer that search goes. So you got diminishing returns, generally around 10k shared buffers. I think it is better in 8.1, but if the OS is going to cache it anyway (since it does), then having a Postgres cache is just wasting memory, and not letting cache as much. So I'm guessing that with 8.1 there would be 2 sweet spots. Low shared_buffers (<= 10k), and really high shared buffers (like all of available ram). But because postgres has been tuned for the former I would stick with it (I don't think shared_buffers can go >2GB, but that might just be work_mem/maintenance_work_mem). > > 2. work_mem - It is the amount of memory used by an > operation. My guess is once the operation is complete > this is freed and hence has nothing to do with the > caching. > > 3. effective_cache_size - The parameter used by the > query planner and has nothing to do with the actual > caching. This is important from a planner issue. Because the planner can then expect that the OS is doing its job and caching the tables, so index scans are cheaper than they would be otherwise. John =:-> > > So kindly help me in pointing me to the correct > parameter to set. > > It will be great if you can point me to the docs that > explains the implementation of caching in Postgresql > which will help me in understanding things much > clearly. > > Thanks in advance. > Gokul. > --------------enig6B9A2DFC2643B98ED6BD6B74 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Darwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDC1woJdeBCYSNAAMRAo5oAKDK1553m7IjY7NssS5Ot/I7lDwKjQCfW21x 1B1z4H/JdL58uUMxS1ma3Ac= =QG/Q -----END PGP SIGNATURE----- --------------enig6B9A2DFC2643B98ED6BD6B74--