Re: nested query on last n rows of huge table

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: "jcfischer" <jcfischer(dot)lists(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: nested query on last n rows of huge table
Date: 2006-03-01 03:44:25
Message-ID: DF8206DD-3B0F-41DA-BA21-4D14945EB7BF@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


On Feb 24, 2006, at 23:13 , jcfischer wrote:

> Is there a way to limit the expensive query to only those last 1000
> (or
> whatever) results?

>
> I have tried to nest SELECTS but my SQL-fu is to limited to get
> anything through the SQL processor :-)

The basics of a subquery are:

SELECT <expensive query>
FROM (
SELECT *
FROM table
ORDER eventtime DESC
LIMIT 1000
) as most_recent_1000

Don't know enough about the other parts, but hopefully this can get
you started. :)

Michael Glaesemann
grzm myrealbox com

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Bruno Wolff III 2006-03-01 06:55:56 Re: Large Table With Only a Few Rows
Previous Message Tom Lane 2006-02-28 23:45:06 Re: wal sync method