Re: Efficiency Question - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: Efficiency Question
Date
Msg-id 20020909135731.GA1461@wolff.to
Whole thread Raw
In response to Efficiency Question  ("Colin Fox" <cfox@cfconsulting.ca>)
List pgsql-sql
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.


pgsql-sql by date:

Previous
From: jasondavis19@hotmail.com (Jason Davis)
Date:
Subject: Cross tables Like%
Next
From: Viacheslav N Tararin
Date:
Subject: Re: new calculated column