Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 6E4051337B6F for ; Wed, 29 Sep 2010 05:03:30 -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 33898-03 for ; Wed, 29 Sep 2010 08:03:17 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.catalyst.net.nz (bertrand.catalyst.net.nz [202.78.240.40]) by mail.postgresql.org (Postfix) with ESMTP id BA3AE1337B69 for ; Wed, 29 Sep 2010 05:03:16 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.catalyst.net.nz (Postfix) with ESMTP id 908053201F for ; Wed, 29 Sep 2010 21:03:10 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at catalyst.net.nz Received: from mail.catalyst.net.nz ([127.0.0.1]) by localhost (bertrand.catalyst.net.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eZzBEsb7W1kx for ; Wed, 29 Sep 2010 21:03:09 +1300 (NZDT) Received: from [192.168.1.11] (122-58-208-29.jetstream.xtra.co.nz [122.58.208.29]) (Authenticated sender: mark.kirkwood) by mail.catalyst.net.nz (Postfix) with ESMTPSA id 7F38C31FF8 for ; Wed, 29 Sep 2010 21:03:09 +1300 (NZDT) Message-ID: <4CA2F2BC.8090307@catalyst.net.nz> Date: Wed, 29 Sep 2010 21:03:08 +1300 From: Mark Kirkwood User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Memory usage - indexes References: In-Reply-To: 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.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201009/202 X-Sequence-Number: 40405 On 29/09/10 19:41, Tobias Brox wrote: > I just got this crazy, stupid or maybe genius idea :-) > > > Now, my idea is to drop that fat index and replace it with conditional > indexes for a dozen of heavy users - like those: > > acc_trans(trans_type, created) where customer_id=224885; > acc_trans(trans_type, created) where customer_id=643112; > acc_trans(trans_type, created) where customer_id=15; > > or maybe like this: > > acc_trans(customer_id, trans_type, created) where customer_id in ( ... ); > > Any comments? > > My sysadmin is worried that it would be a too big hit on performance > when doing inserts. It may also cause more overhead when planning the > queries. Is that significant? Is this idea genius or stupid or just > somewhere in between? > > Yeah, I think the idea of trying to have a few smaller indexes for the 'hot' customers is a good idea. However I am wondering if just using single column indexes and seeing if the bitmap scan/merge of smaller indexes is actually more efficient is worth testing - i.e: acc_trans(trans_type); acc_trans(created); acc_trans(customer_id); It may mean that you have to to scrutinize your effective_cache_size and work_mem parameters, but could possibly be simpler and more flexible. regards Mark