Re: SELECT min(id) FROM test; uses seqscan - Mailing list pgsql-bugs

From Philip Warner
Subject Re: SELECT min(id) FROM test; uses seqscan
Date
Msg-id 3.0.5.32.20010503125005.02dad200@mail.rhyme.com.au
Whole thread Raw
In response to SELECT min(id) FROM test; uses seqscan  (pgsql-bugs@postgresql.org)
Responses Re: SELECT min(id) FROM test; uses seqscan
List pgsql-bugs
At 09:08 2/05/01 -0400, pgsql-bugs@postgresql.org wrote:
>SELECT min(id) FROM test; uses sequential scan even if an index on "id"
exists. VACUUM ANALYZE doesn't help.
>

This is a known stupidity of PG, and will probably be fixed in a relatively
distant future release (when index entries are updated to match row
status). The simple workaround is:

    Select id from test order by id as limit 1;


----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.B.N. 75 008 659 498)          |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|
                                 |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/

pgsql-bugs by date:

Previous
From: Chris Storah
Date:
Subject: Re: 7.1 euro-style dates insert error
Next
From: Tom Lane
Date:
Subject: Re: SELECT min(id) FROM test; uses seqscan