index performance question

From: Laurette Cisneros <laurette(at)nextbus(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: index performance question
Date: 2002-09-18 20:09:07
Message-ID: Pine.LNX.4.44.0209181303120.3174-100000@visor.corp.nextbus.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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...

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Bruno Wolff III 2002-09-18 20:21:44 Re: index performance question
Previous Message Tom Lane 2002-09-18 15:06:10 Re: [GENERAL] Still big problems with pg_dump!