Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2F6059FBA4C for ; Fri, 9 Mar 2007 12:00:02 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 19507-10 for ; Fri, 9 Mar 2007 11:59:57 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id D09259FB85B for ; Fri, 9 Mar 2007 11:59:56 -0400 (AST) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 3D5FE758CF; Fri, 9 Mar 2007 15:59:48 +0000 (GMT) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 94A1827401E; Fri, 9 Mar 2007 15:59:48 +0000 (GMT) Message-ID: <45F18474.4000207@archonet.com> Date: Fri, 09 Mar 2007 15:59:48 +0000 From: Richard Huxton User-Agent: IceDove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: Gerardo Herzig Cc: pgsql-sql@postgresql.org Subject: Re: index not being used. Why? References: <45F176CA.3050107@fmed.uba.ar> In-Reply-To: <45F176CA.3050107@fmed.uba.ar> 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=0.201 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200703/113 X-Sequence-Number: 27751 Gerardo Herzig wrote: > -> Seq Scan on pages (cost=0.00..9.08 rows=408 width=55) > Watch the last row of the explain command. It makes a sequential scan on > the pages table, like it is not using the index on the "id" field. You only have 408 rows in the table - it's probably not worth the trouble of using an index and *then* fetching the rows. Especially since it's going to match most of the pages anyway. Try adding a few thousand rows, analyse and see if it decides to use the index then. -- Richard Huxton Archonet Ltd