No index maximum? (was Re: No merge sort?)

From: Taral <taral(at)taral(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: No index maximum? (was Re: No merge sort?)
Date: 2003-03-14 20:19:46
Message-ID: 20030314201946.GA1882@taral.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)taral(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-03-14 20:35:27 Re: Non-colliding auto generated names
Previous Message Jason Earl 2003-03-14 20:12:49 Re: SQL99 ARRAY support proposal