Re: How to speed up min/max(id) in 50M rows table?

From: henk de wit <henk53602(at)hotmail(dot)com>
To: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: How to speed up min/max(id) in 50M rows table?
Date: 2007-10-12 21:40:54
Message-ID: BAY124-W50228E83905C05AA18AF57F5A00@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> select payment_id from transactions order by payment_id desc limit 1;

This one is indeed instant! Less than 50ms. In my case I can't use it for max though because of the fact that payment_id can be null (which is an unfortunate design choice). The other variant however didn't become instant. I.e. I tried:

select time from transactions where payment_id = 67 order by time asc limit 1;

But this one is still really slow.

Regards

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message henk de wit 2007-10-12 21:48:59 Re: Huge amount of memory consumed during transaction
Previous Message Erik Jones 2007-10-12 21:39:26 Re: Huge amount of memory consumed during transaction