X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9F66747A271 for ; Fri, 31 Jan 2003 18:16:26 -0500 (EST) Received: from mail.sandvine.com (sandvine.com [199.243.201.138]) by postgresql.org (Postfix) with ESMTP id 017CE47F877 for ; Fri, 31 Jan 2003 16:12:47 -0500 (EST) Received: by mail.sandvine.com with Internet Mail Service (5.5.2653.19) id ; Fri, 31 Jan 2003 16:12:48 -0500 Message-ID: From: Don Bowman To: "'pgsql-performance@postgresql.org'" Subject: not using index for select min(...) Date: Fri, 31 Jan 2003 16:12:38 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/405 X-Sequence-Number: 1052 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; Aggregate (cost=22.50..22.50 rows=1 width=4) -> Seq Scan on x (cost=0.00..20.00 rows=1000 width=4) => \d x Table "public.x" Column | Type | Modifiers --------+---------+----------- value | integer | not null Indexes: x_pkey primary key btree (value) Why wouldn't I be doing an index scan on this table? --don