Re: more problems with count(*) on large table

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Bill Moran <wmoran(at)potentialtech(dot)com>
Cc: Mike Charnoky <noky(at)nextbus(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Alban Hertroys <a(dot)hertroys(at)magproductions(dot)nl>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: more problems with count(*) on large table
Date: 2007-10-02 07:47:19
Message-ID: 20071002074719.GB12469@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Oct 01, 2007 at 01:34:32PM -0400, Bill Moran wrote:
> This sounds like a caching issue. My guess at what's happening is that
> other operations are pushing this data out of the shared_buffers, so
> when you run it, the system has to pull a bunch of tuples off the disk
> to check them. If you run it again immediately, the tuples are still in
> memory, and it runs very fast.

You should check your ratio of system cache to shared_buffers. Pushing
things out of shared buffers isn't bad if you've got a much bigger OS
behind it. The cost of pulling something out of the OS cache is
negligable compared to really going to disk.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2007-10-02 08:34:29 Re: windows and pg 8.2 (change database to another server)
Previous Message Tomasz Ostrowski 2007-10-02 07:42:36 Re: more problems with count(*) on large table