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