instagram风格探索页面mysql随机发布无限滚动

i have a question about instagram style infinite scroll system. I am trying to make that page. They are showing the posts randomizely but i am confused about infinite scroll part. I have created this query:

$morequery=" AND p.post_id<'".$lastpost."' ";

SELECT DISTINCT p.post_id,
                p.user_id, 
                u.username 
FROM  posts p, users Uu 
WHERE u.ustatus='1' AND 
      p.userid_fk =u.user_id AND 
      $morequery ORDER BY p.post_id DESC LIMIT

The query working like when user scroll down the ajax code sending lastpost id and query working with the lastpost. But it is not ramdom system i just use the DESC in this query. If i change the query ORDER BY p.post_id DESC LIMIT to ORDER BY RAND() LIMIT when page open rand() working but scroll is not working.

I have searched some solution on stackoverflow. They said use session like:

$_SESSION['seen_scroll_posts'] = array();
if (!empty($_SESSION['seen_scroll_posts'])) {
  $morequery = " AND post_id NOT IN (" . implode($_SESSION['seen_scroll_posts']) . ") ";
}

This is not a good solution because if user scroll down many times then the page going to be slow. Also the post_id is primary key if i use session solution the page going to be slow.

Is there anyway to show posts randomly like instagram explore? In this regard, do you have a suggestion or solution path ?