Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 5085B9FB398 for ; Wed, 18 Oct 2006 10:57:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 09572-04 for ; Wed, 18 Oct 2006 10:57:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from edb06.mail01.enterprisedb.com (63-246-7-171.contegix.com [63.246.7.171]) by postgresql.org (Postfix) with ESMTP id 966799FB340 for ; Wed, 18 Oct 2006 10:57:43 -0300 (ADT) thread-index: AcbyvWFl2uDJe4DgRn2ATQ4yIsOLIw== Received: from [192.168.0.20] ([62.232.55.86]) by edb06.mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); Wed, 18 Oct 2006 09:57:42 -0400 Message-ID: <453632C5.50501@enterprisedb.com> Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2757 Date: Wed, 18 Oct 2006 14:57:25 +0100 From: "Heikki Linnakangas" User-Agent: Thunderbird 1.5.0.7 (X11/20060915) MIME-Version: 1.0 To: "Arnaud Lesauvage" Cc: Subject: Re: Index on two columns not used References: <45360E25.9010403@freesurf.fr> <45361295.9050504@enterprisedb.com> <45361A2D.6080702@freesurf.fr> In-Reply-To: <45361A2D.6080702@freesurf.fr> Content-Type: text/plain; format=flowed; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 Oct 2006 13:57:42.0265 (UTC) FILETIME=[6159BE90:01C6F2BD] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.197 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200610/354 X-Sequence-Number: 21483 Arnaud Lesauvage wrote: > I did not know that joins were not using index values, and that > PostgreSQL had to fecth the heap tuples anyway. > Does this mean that this 2-column index is useless ? (I created it for > the join, I don't often filter on both columns otherwise) Well, if no-one is using the index, it is useless.. > This query was taken from my "adminsitrative areas" model (continents, > countries, etc...). Whenever I query this model, I have to join many > tables. > I don't really know what the overhead of reading the heap-tuples is, but > would it be a good idea to add data-redundancy in my tables to avoid > joins ? (adding country_id, continent_id, etc... in the "cities" table) It depends. I would advise not to denormalize unless you really really have to. It's hard to say without more knowledge of the application. Is the query you showed a typical one? It ran in about 160 ms, is that good enough? It's doesn't sound too bad, considering that it returned almost 40000 rows. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com