Re: Efficiently query for the most recent record for a given user - Mailing list pgsql-performance

From Tom Lane
Subject Re: Efficiently query for the most recent record for a given user
Date
Msg-id 9813.1375900452@sss.pgh.pa.us
Whole thread Raw
In response to Re: Efficiently query for the most recent record for a given user  (Claudio Freire <klaussfreire@gmail.com>)
Responses Re: Efficiently query for the most recent record for a given user
List pgsql-performance
Claudio Freire <klaussfreire@gmail.com> writes:
> On Wed, Aug 7, 2013 at 3:12 PM, Robert DiFalco <robert.difalco@gmail.com> wrote:
>> I want to get the last call_activity record for a single user.

> Create an index over (user_id, called desc), and do
> select * from call_activity where user_id = blarg order by called desc limit 1

Note that there's no particular need to specify "desc" in the index
definition.  This same index can support searches in either direction
on the "called" column.

            regards, tom lane


pgsql-performance by date:

Previous
From: Claudio Freire
Date:
Subject: Re: Efficiently query for the most recent record for a given user
Next
From: Igor Neyman
Date:
Subject: Re: Efficiently query for the most recent record for a given user