Re: Forcing a specific order

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Martin Foster <martin(at)ethereal-realms(dot)org>
Cc: PostgreSQL Novice List <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Forcing a specific order
Date: 2005-10-12 01:17:43
Message-ID: 20051012011743.GA68258@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, Oct 11, 2005 at 08:56:41PM -0400, Martin Foster wrote:
> This may come across as a rather odd question. However, is there a way
> to force PostgreSQL to return rows in a very specific order?

Yes, with ORDER BY. But after reading the rest of your message,
I'm not sure that's what you're after.

> I am currently facing running one three-way-join query which will last 50+
> seconds. Since this is a web-based application this hardly makes for a
> fast browsing experience.

If you post the query, the table definitions, the EXPLAIN ANALYZE
output, and your version of PostgreSQL to pgsql-performance, then
somebody might be able to help tune the query. Making the query
faster might just be a matter of creating the right indexes, making
sure the tables are vacuumed and analyzed, and/or adjusting the
server's configuration settings.

> One solution is to break it up into more manageable pieces. If I can
> specify the sort order then I can run concurrent queries and get things
> settled easily. Otherwise I'll have to fetch for every row returned
> and that seems messy and I would like to avoid it.

It's not clear how you'd use a sort order to run concurrent queries,
nor how that involves how many rows you'd have to fetch. Could you
elaborate? But it might be better to post the query and the EXPLAIN
ANALYZE output and let others take a look: let's examine the problem
before thinking about a solution.

--
Michael Fuhr

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Glaesemann 2005-10-12 01:17:56 Re: Forcing a specific order
Previous Message Martin Foster 2005-10-12 00:56:41 Forcing a specific order