From: Bruno Wolff III <bruno@wolff.to>
To: Colin Fox <cfox@cfconsulting.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: Efficiency Question
Date: Mon, 9 Sep 2002 08:57:31 -0500
Message-ID: <20020909135731.GA1461@wolff.to> (raw)
In-Reply-To: <pan.2002.09.09.00.12.58.87388@cfconsulting.ca>
References: <pan.2002.09.09.00.12.58.87388@cfconsulting.ca>
On Mon, Sep 09, 2002 at 00:13:04 +0000,
Colin Fox <cfox@cfconsulting.ca> 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.
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-sql@postgresql.org
Cc: bruno@wolff.to, cfox@cfconsulting.ca
Subject: Re: Efficiency Question
In-Reply-To: <20020909135731.GA1461@wolff.to>
* 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