No index maximum? (was Re: No merge sort?) - Mailing list pgsql-hackers

From Taral
Subject No index maximum? (was Re: No merge sort?)
Date
Msg-id 20030314201946.GA1882@taral.net
Whole thread Raw
In response to No merge sort?  (Taral <taral@taral.net>)
Responses Re: No index maximum? (was Re: No merge sort?)  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-hackers
Same setup, different query:

test=> explain select max(time) from test where id = '1';
NOTICE:  QUERY PLAN:

Aggregate  (cost=5084.67..5084.67 rows=1 width=0) ->  Index Scan using idx on test  (cost=0.00..5081.33 rows=1333
width=0)

Since the index is (id, time), why isn't the index being used to
retrieve the maximum value?

On Thu, Mar 13, 2003 at 03:10:49PM -0600, Taral wrote:
> I have a table "test" that looks like this:
>
> CREATE TABLE test (
>     id BIGINT,
>     time INTEGER
> );
>
> There is an index:
>
> CREATE INDEX idx ON test(id, time);
>
> The table has been loaded with 2M rows, where time ranges sequentially
> from 0 to 1999999 and id is random values from 0 to 49999.

--
Taral <taral@taral.net>
This message is digitally signed. Please PGP encrypt mail to me.
"Most parents have better things to do with their time than take care of
their children." -- Me

pgsql-hackers by date:

Previous
From: Jason Earl
Date:
Subject: Re: SQL99 ARRAY support proposal
Next
From: Joe Conway
Date:
Subject: Re: SQL99 ARRAY support proposal