Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 0D2F09FBF8F for ; Wed, 11 Jul 2007 13:58:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 03660-02 for ; Wed, 11 Jul 2007 13:58:33 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 6F3CB9FBF92 for ; Wed, 11 Jul 2007 13:58:33 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1I8fWJ-00026y-Ap for pgsql-performance@postgresql.org; Wed, 11 Jul 2007 12:58:31 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 04CCB4050; Wed, 11 Jul 2007 12:58:26 -0400 (EDT) Date: Wed, 11 Jul 2007 12:58:26 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Two questions.. shared_buffers and long reader issue Message-ID: <20070711165825.GW1241@phlogiston.dyndns.org> References: <4694F8C5.2040005@p-dw.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4694F8C5.2040005@p-dw.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/102 X-Sequence-Number: 25786 On Wed, Jul 11, 2007 at 05:35:33PM +0200, Patric de Waha wrote: > Mainly updates on 1 tuple. Are you vacuuming that table enough? > And more or less complex SELECT statements. > I noticed that the overall performance of postgres is decreasing > when one or more long > readers are present. Where a long reader here is already a Select > count(*) from table. SELECT count(*) is expensive in Postgres. Do you really need it? Unqualified count() in PostgreSQL is just a bad thing to do, so if you can work around it (by doing limited subselects, for instance, where you never scan more than 50 rows, or by keeping counts using triggers, or various other tricks), it's a good idea. > Why do long readers influence the rest of the transactions in such a > heavy way? It could be because of all those updated tuples not getting vacuumed (which results in a bad plan). Or it could be that your connection pool is exhausted: note that when someone hits "reload", that doesn't mean your old query goes away. It is still crunching through whatever work it was doing. > Second question. What is the right choice for the shared_buffers size? > On a dedicated postgres server with 4 Giga RAM. Is there any rule of > thumb? > Actually I set it to +-256M. There has been Much Discussion of this lately on this list. I suggest you have a look through the recent archives on that topic. A -- Andrew Sullivan | ajs@crankycanuck.ca "The year's penultimate month" is not in truth a good way of saying November. --H.W. Fowler