Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 498741337B43 for ; Wed, 6 Apr 2011 10:16:18 -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 49507-06 for ; Wed, 6 Apr 2011 13:16:07 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from elizabeth.gransy.com (elizabeth.gransy.com [89.187.132.199]) by mail.postgresql.org (Postfix) with ESMTP id E6A1F1337A5D for ; Wed, 6 Apr 2011 10:16:06 -0300 (ADT) Received: from sq.gransy.com (localhost [127.0.0.1]) by elizabeth.gransy.com (Postfix) with ESMTP id 4910B15E4166; Wed, 6 Apr 2011 15:16:05 +0200 (CEST) Received: from 85.161.177.145 (SquirrelMail authenticated user tv@fuzzy.cz) by sq.gransy.com with HTTP; Wed, 6 Apr 2011 15:16:05 +0200 Message-ID: <1b572fb7e416cc09ec31ea1a16d0442f.squirrel@sq.gransy.com> In-Reply-To: <4D9B6CBA.2050609@nasa.gov> References: <4D9B6CBA.2050609@nasa.gov> Date: Wed, 6 Apr 2011 15:16:05 +0200 Subject: Re: help speeding up a query in postgres 8.4.5 From: tv@fuzzy.cz To: Maria.L.Wilson-1@nasa.gov Cc: "pgsql-performance@postgresql.org" User-Agent: SquirrelMail/1.4.21 MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal 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: 201104/45 X-Sequence-Number: 43107 > some additional info..... > the table inventory is about 4481 MB and also has postgis types. > the table gran_ver is about 523 MB > the table INVSENSOR is about 217 MB > > the server itself has 32G RAM with the following set in the postgres conf > shared_buffers = 3GB > work_mem = 64MB > maintenance_work_mem = 512MB > wal_buffers = 6MB Not sure how to improve the query itself - it's rather simple and the execution plan seems reasonable. You're dealing with a lot of data, so it takes time to process. Anyway, I'd try to bump up the shared buffers a bit (the tables you've listed have about 5.5 GB, so 3GB of shared buffers won't cover it). OTOH most of the data will be in pagecache maintained by the kernel anyway. Try to increase the work_mem a bit, that might speed up the hash joins (the two hash joins consumed about 15s, the whole query took 17s). This does not require a restart, just do set work_mem = '128MB' (or 256MB) and then run the query in the same session. Let's see if that works. regards Tomas