Re: Efficiently searching for the most recent rows where a column matches any result from a different query

From: Nandakumar M <m(dot)nanda92(at)gmail(dot)com>
To: mkslaf(at)keemail(dot)me
Cc: Hellmuth Vargas <hivs77(at)gmail(dot)com>, Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: Efficiently searching for the most recent rows where a column matches any result from a different query
Date: 2018-02-19 10:10:37
Message-ID: CANcFUu5sbDrAEu47nhWcwe7uJ_MxxtVSkP_9ED8SXb4swh2tjw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi,

Correction in the query. I missed to add limit 10 in the outer most query..

> select * from posts where posts.author_id in (select id from users
> where id in (select friend_id from user_friend where user_id = 1) and
> last_posted_time is not null order by last_posted_time desc limit 10);
>

select * from posts where posts.author_id in (select id from users
where id in (select friend_id from user_friend where user_id = 1) and
last_posted_time is not null order by last_posted_time desc limit 10)
order by post_id desc limit 10;

Regards,
Nanda

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Rick Otten 2018-02-21 15:53:18 blending fast and temp space volumes
Previous Message Nandakumar M 2018-02-19 10:04:44 Re: Efficiently searching for the most recent rows where a column matches any result from a different query