Skip site navigation (1) Skip section navigation (2)

Re:

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: Lengyel Ferenc <lengyel(at)hell(dot)ditec(dot)sk>, "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>
Subject: Re:
Date: 2000-10-30 14:31:20
Message-ID: 3.0.5.32.20001031013120.028dd500@mail.rhyme.com.au (view raw or flat)
Thread:
Lists: pgsql-sql
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   |/

pgsql-sql by date

Next:From: Vadim GovorovDate: 2000-10-30 14:39:21
Subject: unsubscribe
Previous:From: Petr JezekDate: 2000-10-30 14:20:36
Subject:

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group