X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CE8CB4799B5 for ; Fri, 31 Jan 2003 21:10:54 -0500 (EST) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id 531FA479702 for ; Fri, 31 Jan 2003 19:49:33 -0500 (EST) Received: (qmail 14693 invoked by uid 500); 1 Feb 2003 01:02:29 -0000 Date: Fri, 31 Jan 2003 19:02:29 -0600 From: Bruno Wolff III To: Don Bowman Cc: "'pgsql-performance@postgresql.org'" Subject: Re: not using index for select min(...) Message-ID: <20030201010229.GA14084@wolff.to> Mail-Followup-To: Don Bowman , "'pgsql-performance@postgresql.org'" References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/408 X-Sequence-Number: 1055 On Fri, Jan 31, 2003 at 16:12:38 -0500, Don Bowman wrote: > I have a table which is very large (~65K rows). I have > a column in it which is indexed, and I wish to use for > a join. I'm finding that I'm using a sequential scan > for this when selecting a MIN. > > I've boiled this down to something like this: > > => create table X( value int primary key ); > => explain select min(value) from x; Use the following instead: select value from x order by value limit 1;