X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 31CE3329EB8 for ; Thu, 9 Sep 2004 09:28:20 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23644-09 for ; Thu, 9 Sep 2004 08:28:09 +0000 (GMT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id F1923329EBA for ; Thu, 9 Sep 2004 09:28:10 +0100 (BST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 1C5KHp-000BWS-0V; Thu, 09 Sep 2004 08:28:09 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 8885916369; Thu, 9 Sep 2004 09:28:08 +0100 (BST) Message-ID: <41401417.6010400@archonet.com> Date: Thu, 09 Sep 2004 09:28:07 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Theo Galanakis Cc: pgsql-sql@postgresql.org Subject: Re: Query Plan References: <82E30406384FFB44AFD1012BAB230B55037D0584@shiva.au.lpint.net> In-Reply-To: <82E30406384FFB44AFD1012BAB230B55037D0584@shiva.au.lpint.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/60 X-Sequence-Number: 18906 Theo Galanakis wrote: > > Have a question regarding when a Query Plan uses an Index. > > I have a basic statement > > This query uses the Index Scan: > explain analyse select * from tablea where columna_id < 57 > > This query uses Seq Scan: > explain analyse select * from tablea where columna_id < 58 > > There are about 5000 records in this table, and columna_id is the primary > key, which is Indexed... And recently recreated. OK - what does explain analyse say? Each line will have two parts, the expected costs/number of rows and the actual time/number of rows. If PG is expecting say 50 rows in the first query but 150 in the second then it might decide a sequential scan is quicker. Post the outputs of explain analyse and we can compare them. -- Richard Huxton Archonet Ltd