pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
To: PostgreSQL Performance <pgsql-performance@postgresql.org>
Subject: Re: Query question
Date: Wed, 12 Nov 2003 21:20:28 -0800
Message-ID: <200311122120.28882.josh@agliodbs.com> (raw)
In-Reply-To: <3FB303E9.20903@familyhealth.com.au>
References: <3FB303E9.20903@familyhealth.com.au>

Chris,

> SELECT * FROM (arbitrary subquery) AS sub ORDER BY 1,3;
>
> Now, this all works fine, but I want to know if this is efficient or not.
>
> Does doing a select of a select cause serious performance degradation?

It would be better if you could strip out the inner sort, but I can understand 
why that might not be possible in all cases.

The only thing you're adding to the query is a second SORT step, so it 
shouldn't require any more time/memory than the query's first SORT did.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco



view thread (5+ messages)  latest in thread

Message-ID: <200311122120.28882.josh@agliodbs.com>
Permalink:  ../200311122120.28882.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200311122120.28882.josh@agliodbs.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: josh@agliodbs.com, chriskl@familyhealth.com.au
  Subject: Re: Query question
  In-Reply-To: <200311122120.28882.josh@agliodbs.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