Re: nested query on last n rows of huge table - Mailing list pgsql-performance

From Michael Glaesemann
Subject Re: nested query on last n rows of huge table
Date
Msg-id DF8206DD-3B0F-41DA-BA21-4D14945EB7BF@myrealbox.com
Whole thread Raw
In response to nested query on last n rows of huge table  ("jcfischer" <jcfischer.lists@gmail.com>)
List 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




pgsql-performance by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Large Table With Only a Few Rows
Next
From: PFC
Date:
Subject: Re: wal sync method