Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DC9CA4762B5 for ; Mon, 9 Sep 2002 09:49:44 -0400 (EDT) Received: from wolff.to (wolff.to [66.92.219.49]) by postgresql.org (Postfix) with SMTP id 023394762AD for ; Mon, 9 Sep 2002 09:49:44 -0400 (EDT) Received: (qmail 1494 invoked by uid 500); 9 Sep 2002 13:57:31 -0000 Date: Mon, 9 Sep 2002 08:57:31 -0500 From: Bruno Wolff III To: Colin Fox Cc: pgsql-sql@postgresql.org Subject: Re: Efficiency Question Message-ID: <20020909135731.GA1461@wolff.to> Mail-Followup-To: Colin Fox , pgsql-sql@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/45 X-Sequence-Number: 9322 On Mon, Sep 09, 2002 at 00:13:04 +0000, Colin Fox wrote: > > select > * > from > motm > order by > creation_date desc > limit 1; > > So in the first case I select the record that has the largest date. In the > second case, I order all the records, and then return only one. If you have an index on creation_date an index scan can be used which will make the second form run a lot faster if there are lots of records.