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