Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id F0E4663287E for ; Fri, 11 Jun 2010 10:28:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 48405-04 for ; Fri, 11 Jun 2010 13:28:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mh5.mail.rice.edu (mh5.mail.rice.edu [128.42.199.32]) by mail.postgresql.org (Postfix) with ESMTP id 3D8F3632712 for ; Fri, 11 Jun 2010 10:28:21 -0300 (ADT) Received: from mh5.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh5.mail.rice.edu (Postfix) with ESMTP id 665D915C002; Fri, 11 Jun 2010 08:28:18 -0500 (CDT) X-Virus-Scanned: by amavis-2.6.0 at mh5.mail.rice.edu Received: from mh5.mail.rice.edu ([127.0.0.1]) by mh5.mail.rice.edu (mh5.mail.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I5V9Jne4CjnU; Fri, 11 Jun 2010 08:28:18 -0500 (CDT) Received: from aart.is.rice.edu (aart.is.rice.edu [168.7.56.48]) by mh5.mail.rice.edu (Postfix) with ESMTP id 318D815C01B; Fri, 11 Jun 2010 08:28:18 -0500 (CDT) Received: by aart.is.rice.edu (Postfix, from userid 18612) id BB7902D5A6; Fri, 11 Jun 2010 08:28:17 -0500 (CDT) Date: Fri, 11 Jun 2010 08:28:17 -0500 From: Kenneth Marshall To: Anj Adu Cc: Robert Haas , Tom Lane , Andy Colson , pgsql-performance@postgresql.org Subject: Re: slow query performance Message-ID: <20100611132817.GQ3063@aart.is.rice.edu> References: <4C07F7C9.3060401@squeakycode.net> <5860.1276138520@sss.pgh.pa.us> <20100611124424.GO3063@aart.is.rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.16 (2007-06-09) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.21 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/208 X-Sequence-Number: 39064 If you check the archives, you will see that this is not easy to do because of the effects of caching. The default values were actually chosen to be a good compromise between fully cached in RAM and totally un-cached. The actual best value depends on the size of your database, the size of its working set, your I/O system and your memory. The best recommendation is usually to use the default values unless you know something about your system that moves it out of that arena. Regards, Ken On Fri, Jun 11, 2010 at 06:23:31AM -0700, Anj Adu wrote: > Is there a way to determine a reasonable value for random_page_cost > via some testing with OS commands. We have several postgres databases > and determining this value on a case by case basis may not be viable > (we may have to go with the defaults) > > On Fri, Jun 11, 2010 at 5:44 AM, Kenneth Marshall wrote: > > Hi Anj, > > > > That is an indication that your system was less correctly > > modeled with a random_page_cost=2 which means that the system > > will assume that random I/O is cheaper than it is and will > > choose plans based on that model. If this is not the case, > > the plan chosen will almost certainly be slower for any > > non-trivial query. You can put a 200mph speedometer in a > > VW bug but it will never go 200mph. > > > > Regards, > > Ken > > > > On Thu, Jun 10, 2010 at 07:54:01PM -0700, Anj Adu wrote: > >> I changed random_page_cost=4 (earlier 2) and the performance issue is gone > >> > >> I am not clear why a page_cost of 2 on really fast disks would perform badly. > >> > >> Thank you for all your help and time. > >> > >> On Thu, Jun 10, 2010 at 8:32 AM, Anj Adu wrote: > >> > Attached > >> > > >> > Thank you > >> > > >> > > >> > On Thu, Jun 10, 2010 at 6:28 AM, Robert Haas wrote: > >> >> On Wed, Jun 9, 2010 at 11:17 PM, Anj Adu wrote: > >> >>> The plan is unaltered . There is a separate index on theDate as well > >> >>> as one on node_id > >> >>> > >> >>> I have not specifically disabled sequential scans. > >> >> > >> >> Please do "SHOW ALL" and attach the results as a text file. > >> >> > >> >>> This query performs much better on 8.1.9 on a similar sized > >> >>> table.(althought the random_page_cost=4 on 8.1.9 and 2 on 8.4.0 ) > >> >> > >> >> Well that could certainly matter... > >> >> > >> >> -- > >> >> Robert Haas > >> >> EnterpriseDB: http://www.enterprisedb.com > >> >> The Enterprise Postgres Company > >> >> > >> > > >> > >> -- > >> Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) > >> To make changes to your subscription: > >> http://www.postgresql.org/mailpref/pgsql-performance > >> > > >