pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Glaesemann <grzm@myrealbox.com>
To: jcfischer <jcfischer.lists@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: nested query on last n rows of huge table
Date: Wed, 1 Mar 2006 12:44:25 +0900
Message-ID: <DF8206DD-3B0F-41DA-BA21-4D14945EB7BF@myrealbox.com> (raw)
In-Reply-To: <1140790410.923941.261250@p10g2000cwp.googlegroups.com>
References: <1140790410.923941.261250@p10g2000cwp.googlegroups.com>


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






view thread (3+ messages)

Message-ID: <DF8206DD-3B0F-41DA-BA21-4D14945EB7BF@myrealbox.com>
Permalink:  ../DF8206DD-3B0F-41DA-BA21-4D14945EB7BF@myrealbox.com/
Also on:    postgresql.org/message-id/DF8206DD-3B0F-41DA-BA21-4D14945EB7BF@myrealbox.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: grzm@myrealbox.com, jcfischer.lists@gmail.com
  Subject: Re: nested query on last n rows of huge table
  In-Reply-To: <DF8206DD-3B0F-41DA-BA21-4D14945EB7BF@myrealbox.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox