Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A5BB6B5DBC8 for ; Tue, 1 Nov 2011 10:13:42 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 62504-10 for ; Tue, 1 Nov 2011 13:13:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from elizabeth.gransy.com (ns2.gransy.com [89.187.132.100]) by mail.postgresql.org (Postfix) with ESMTP id 5AB49B5D803 for ; Tue, 1 Nov 2011 10:13:36 -0300 (ADT) Received: from sq.gransy.com (localhost [127.0.0.1]) by elizabeth.gransy.com (Postfix) with ESMTP id 34FD915E4307; Tue, 1 Nov 2011 14:13:34 +0100 (CET) Received: from 85.161.233.75 (SquirrelMail authenticated user tv@fuzzy.cz) by sq.gransy.com with HTTP; Tue, 1 Nov 2011 14:13:34 +0100 Message-ID: In-Reply-To: <4EAFC29A.40509@engene.se> References: <4EAFC29A.40509@engene.se> Date: Tue, 1 Nov 2011 14:13:34 +0100 Subject: Re: Performance Problem with postgresql 9.03, 8GB RAM,Quadcore Processor Server--Need help!!!!!!! From: "Tomas Vondra" To: "Marcus Engene" 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: 201111/4 X-Sequence-Number: 45515 On 1 Listopad 2011, 10:57, Marcus Engene wrote: > Hi Hashim, > > One workaround I've done is if something looking like this.... > > select > ... > from > table_linking_massive_table tlmt > ,massive_table mt > ,some_table1 st1 > ,some_table2 st2 > ,some_table3 st3 > ,some_table4 st4 > where > tlmt.group_id = 123223 AND > mt.id = tmlt.massive_table AND > st1.massive_table = mt.id AND > st2.massive_table = mt.id AND > st3.massive_table = mt.id AND > st4.massive_table = mt.id > > ...suddenly gets slow, it has helped to rewrite it as.... > > select > ... > from > ( > select > ... > from > table_linking_massive_table tlmt > ,massive_table mt > where > tlmt.group_id = 123223 AND > mt.id = tmlt.massive_table AND > ) as mt > ,some_table1 st1 > ,some_table2 st2 > ,some_table3 st3 > ,some_table4 st4 > where > tlmt.group_id = 123223 AND > mt.id = tmlt.massive_table AND > st1.massive_table = mt.id AND > st2.massive_table = mt.id AND > st3.massive_table = mt.id AND > st4.massive_table = mt.id > Can you please post EXPLAIN ANALYZE of those queries? It's difficult to see what's wrong when we don't know the plan (and the actual stats gathered during execution). Use explain.depesz.com to post the output. Tomas