postgresql - Loading a timeline from a social network efficiently -


i tried attack problem using classical join operation: have table posts , table followings, given user_id retrieve followings , posts of followings joining both tables. until here it's fine.

since it's timeline, need establish number of posts retrieve, let's 30. there button retrieve previous 30 posts , on, means need retrieve timeline in chunks of 30 posts.

the problems comes when thinking efficiency. i'm not expert on dbs remember on mysql can (i don't know how it's in postgresql though):

select * [... join ...] limit 0,30 select * [... join ...] limit 30,60 select * [... join ...] limit 60,90 

i guess internally it's performing join operation, consequently obtaining rows later retrieve limited number of rows. problem in example repeating same join operation 3 times , wondering if there way force database store in cache join result join operation performed once , result limited afterwards, or, on other hand, know if there no way can avoid performing joins time in each query.

edit: i'm interested in postgresql solution.

thanks.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -