Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 8E5C62E0054 for ; Thu, 10 Apr 2008 15:48:29 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 40558-02-8 for ; Thu, 10 Apr 2008 15:48:20 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from westnet.com (westnet.com [216.187.52.2]) by developer.postgresql.org (Postfix) with ESMTP id EEA372E002F for ; Thu, 10 Apr 2008 15:48:12 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m3AIm0mf019705; Thu, 10 Apr 2008 14:48:00 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m3AIlxkx019696; Thu, 10 Apr 2008 14:47:59 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Thu, 10 Apr 2008 14:47:59 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: Bill Moran cc: John Beaver , Gaetano Mendola , Pgsql-Performance Subject: Re: large tables and simple "= constant" queries using indexes In-Reply-To: <20080410130854.f3a3f110.wmoran@collaborativefusion.com> Message-ID: References: <47FD2DF3.80500@gmail.com> <47FD3350.4060504@tweakers.net> <47FD4212.8040404@gmail.com> <47FDBE23.8020402@tweakers.net> <47FE27EB.8050804@gmail.com> <47FE3DC7.4010700@gmail.com> <47FE4259.7030704@gmail.com> <20080410130854.f3a3f110.wmoran@collaborativefusion.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/134 X-Sequence-Number: 29627 On Thu, 10 Apr 2008, Bill Moran wrote: > If you install the pg_buffercache addon, you can actually look into > PostgreSQL's internals and see what tables are in the buffer in real > time. The "Inside the PostgreSQL Buffer Cache" talk I did at the recent East conference is now on-line at http://www.westnet.com/~gsmith/content/postgresql/ The slides explain how that information gets updated and used internally, and the separate "sample queries" file there shows some more complicated views I've written against pg_buffercache. Here's a sample one: relname |buffered| buffers % | % of rel accounts | 306 MB | 65.3 | 24.7 accounts_pkey | 160 MB | 34.1 | 93.2 This shows that 65.3% of the buffer cache is filled with the accounts table, which is caching 24.7% of the full table. These are labeled "relations" because there's a mix of table and index data there. accounts_pkey is an index for example, which is why almost all of it is staying inside the buffer cache. The queries that use usage_count only work against 8.3, that one above should work on older versions as well. -- * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD