Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id AC4A7B5DBD6 for ; Thu, 18 Aug 2011 02:46:03 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 94452-02 for ; Thu, 18 Aug 2011 05:45:57 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f42.google.com (mail-pz0-f42.google.com [209.85.210.42]) by mail.postgresql.org (Postfix) with ESMTP id 28B00B5DBD9 for ; Thu, 18 Aug 2011 02:45:57 -0300 (ADT) Received: by pzk37 with SMTP id 37so4004902pzk.15 for ; Wed, 17 Aug 2011 22:45:56 -0700 (PDT) Received: by 10.142.201.19 with SMTP id y19mr197311wff.150.1313646356595; Wed, 17 Aug 2011 22:45:56 -0700 (PDT) Received: from [192.168.3.155] (office1.postnewspapers.com.au [150.101.171.128]) by mx.google.com with ESMTPS id s14sm838005wfh.4.2011.08.17.22.45.54 (version=SSLv3 cipher=OTHER); Wed, 17 Aug 2011 22:45:55 -0700 (PDT) Message-ID: <4E4CA70C.9050209@ringerc.id.au> Date: Thu, 18 Aug 2011 13:45:48 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: hyelluas CC: pgsql-performance@postgresql.org Subject: Re: tunning strategy needed References: <1313620811606-4710245.post@n5.nabble.com> In-Reply-To: <1313620811606-4710245.post@n5.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201108/222 X-Sequence-Number: 44669 On 18/08/2011 6:40 AM, hyelluas wrote: > Hello, > > I have an old application that was written on Postgres 8.1. > There are a few hundreds tables, 30-40 columns per table, hundreds of > views, and all the sql is inside java code. > > We are moving it to 8.4, it seems to be VERY slow. > There are 20-30 tables transactions - the objects are spread acrross > multiple tables and some tables have data from different objects. > > I need a short term tuning strategy minimizing rewrite& redesign. > > - Turn on auto explain and slow query logging - Examine the slow queries and plans. Run them manually with EXPLAIN ANALYZE. Check that the statistics make sense and if they're inaccurate, increase the statistics targets on those columns/tables then re-ANALYZE. - If the stats are accurate but the query is still slow, try playing with the cost parameters and see if you get a better result, then test those settings server-wide to see if they improve overall performance. -- Craig Ringer