Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 67AEBB5DBCA for ; Thu, 3 Nov 2011 13:08:20 -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 61849-09 for ; Thu, 3 Nov 2011 16:08:14 +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 BA0AFB5DBC8 for ; Thu, 3 Nov 2011 13:08:13 -0300 (ADT) Received: from sq.gransy.com (localhost [127.0.0.1]) by elizabeth.gransy.com (Postfix) with ESMTP id 8A10315E4113; Thu, 3 Nov 2011 17:08:11 +0100 (CET) Received: from 85.162.201.188 (SquirrelMail authenticated user tv@fuzzy.cz) by sq.gransy.com with HTTP; Thu, 3 Nov 2011 17:08:11 +0100 Message-ID: <65a8332e0128eda27f0345da80946dc6.squirrel@sq.gransy.com> In-Reply-To: <4EB2ACEF.8090305@gmx.at> References: <4EAFC29A.40509@engene.se> <24830.1320154980@sss.pgh.pa.us> <4EB2ACEF.8090305@gmx.at> Date: Thu, 3 Nov 2011 17:08:11 +0100 Subject: Re: Performance Problem with postgresql 9.03, 8GB RAM,Quadcore Processor Server--Need help!!!!!!! From: "Tomas Vondra" To: "Mario Weilguni" 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/55 X-Sequence-Number: 45566 On 3 Listopad 2011, 16:02, Mario Weilguni wrote: > Am 02.11.2011 08:12, schrieb Mohamed Hashim: >> Dear All >> >> Thanks for your suggestions & replies. >> >> The below are the sample query which i put for particular one bill_id >> >> EXPLAIN ANALYZE SELECT abd.bill_no as >> bill_no,to_char(abd.bill_date,'dd/mm/yyyy') AS date,mp.product_desc as >> product_desc,std.quantity,std.area,rip.price AS rate >> FROM acc_bill_items_106 abi >> JOIN acc_bill_details_106 abd ON abd.bill_id=abi.bill_id >> JOIN stk_source ss ON ss.source_detail[1]=1 and >> ss.source_detail[2]=abi.item_id >> JOIN stock_transaction_detail_106 std ON std.stock_id=ss.stock_id >> JOIN stock_details_106 sd106 ON sd106.stock_id=std.stock_id >> JOIN master_product_106 mp ON mp.product_id= sd106.product_id >> JOIN receipt_item_price_106 rip ON rip.receipt_item_id=abi.item_id >> WHERE abi.bill_id=12680; > > First I would try this: > explain analyze select * from stk_source where source_detail[1] = 1; > explain analyze select * from stk_source where source_detail[2] = 12356; > > Both times you'll get sequential scans, and that's the root of the > problem. Oh, you mentioned that you use partitioning, but there seems to > be no condition for that. > > You should really rethink your database schema, at least try to pull out > all indexable fields out of that int[] into columns, and use indices on > those fields. No doubt about that, querying tables using conditions on array columns is not the best direction in most cases, especially when those tables are huge. Still, the interesting part here is that the OP claims this worked just fine in the older version and after an upgrade the performance suddenly dropped. This could be caused by many things, and we're just guessing because we don't have any plans from the old version. Tomas