At 13:36 30/10/00 +0100, Lengyel Ferenc wrote:
>Hello everybody!
>I need some help with a simple query.
>I've got a problem with getting a maximum value from a very large table
>(10000000+ rows):
Unfortunately PGSQL does not use indexes for min & max. One approach that
should work is:
select col1 from TABLE_A WHERE COL2 = 1 order by col2, col1 desc limit 1;
and you will need an index on (col2, col1).
----------------------------------------------------------------
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 |/