index performance question - Mailing list pgsql-admin

From Laurette Cisneros
Subject index performance question
Date
Msg-id Pine.LNX.4.44.0209181303120.3174-100000@visor.corp.nextbus.com
Whole thread Raw
Responses Re: index performance question  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-admin
Not sure the right forum to post this...

I have a table that has 20 million rows and growing.  One of the columns is a
timestamptz column.

If I do:

explain select * from bigtable where tscol > '2002-09-17';

I see:
NOTICE:  QUERY PLAN:

Index Scan using pos_timeidx on positions_plus  (cost=0.00..46519.71
rows=1425978 width=108)

EXPLAIN

But, when I do:
explain select min(evtime) from positions_plus;

I see:
NOTICE:  QUERY PLAN:

Aggregate  (cost=548394.90..548394.90 rows=1 width=8)
  ->  Seq Scan on positions_plus  (cost=0.00..499146.92 rows=19699192
width=8)

EXPLAIN

Aren't aggregates smart enough to use an index on the column?  This takes 8
minutes to run!  I can't see that I should have to build a functional index
(is it possible for an aggregate?) to get this to run faster?

Thanks,

--
Laurette Cisneros
The Database Group
(510) 420-3137
NextBus Information Systems, Inc.
www.nextbus.com
----------------------------------
A wiki we will go...



pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] Still big problems with pg_dump!
Next
From: Bruno Wolff III
Date:
Subject: Re: index performance question