Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 312FC2E0049 for ; Wed, 26 Mar 2008 12:27:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 72427-02 for ; Wed, 26 Mar 2008 12:27:37 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.61.230.242]) by postgresql.org (Postfix) with ESMTP id 45ABB2E004A for ; Wed, 26 Mar 2008 12:27:36 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id A872CD55C9; Thu, 27 Mar 2008 00:27:32 +0900 (WST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id F34371E0435; Thu, 27 Mar 2008 00:27:33 +0900 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id p1JhKVomKByS; Thu, 27 Mar 2008 00:27:32 +0900 (WST) Received: from [203.161.97.213] (203.161.97.213.static.amnet.net.au [203.161.97.213]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTP id 4D1EF1E0434; Thu, 27 Mar 2008 00:27:32 +0900 (WST) Message-ID: <47EA6B5C.4020908@postnewspapers.com.au> Date: Thu, 27 Mar 2008 00:27:24 +0900 From: Craig Ringer User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Marinos Yannikos Cc: pgsql-performance@postgresql.org Subject: Re: 1-/2-dimensional indexes for common columns, rationale? References: <47EA5B4D.5000300@geizhals.at> <20080326150208.GH27264@a-kretschmer.de> <47EA6888.2050506@geizhals.at> In-Reply-To: <47EA6888.2050506@geizhals.at> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/488 X-Sequence-Number: 29442 Marinos Yannikos wrote: >> >> Which version do you have? Since 8.1 pg can use a so called 'bitmap >> index scan', because of this feature i guess you don't need the index >> foo3. (if you have 8.1 or higher) > > 8.3.1 - foo3 is being used though in presence of both foo1 and foo2, > so I'd suppose that it's a better choice even with bitmap index scan > available... > PostgreSQL can also partially use a multi-column index. For example, if you dropped your index on (a) Pg could use index (a,b) to help with queries for `a'. However, the index would be slower than an index on a alone would be. See: http://www.postgresql.org/docs/8.3/interactive/indexes-multicolumn.html As usual, the best answer is really "do some testing with your queries, and with EXPLAIN ANALYZE, and see what works best". Test with inserts too, because it's likely that the cost of updating each of the three indexes isn't equal. It might also be worth looking into using partial indexes if some of your data is "hotter" than others and perhaps more worth the index update cost. -- Craig Ringer