Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4542138
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:20:47+00:00 2026-05-21T15:20:47+00:00

On Facebook, when a wall post has a lot of comments, you see only

  • 0

On Facebook, when a wall post has a lot of comments, you see only the last two comments. Right above them, however, is a link that says something like “View all 15 comments.”

In MySQL, would this require two queries? One to get the total comment count, and the other to get the contents of the last two comments? Then, clicking that “View all” link requires a third in order to get the content of the remaining comments.

If this is the case, wouldn’t it be more efficient to simply get the contents of all the comments in a single MySQL query? This would allow you to find the total number using PHP, and you wouldn’t need to make the third query if you simply output the contents of all the comments to the page, using css to hide those that you don’t want initially shown and JavaScript to show them when the user clicks the “View All” link.

I assume I’m wrong. Surely the Facebook developers are better at this than I am. But I’m developing a site that has a similar requirement and I’m trying to understand the most efficient way to achieve this kind of functionality.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:20:48+00:00Added an answer on May 21, 2026 at 3:20 pm

    In MySQL you could use a limited select to retrieve the latest comments specifying SQL_CALC_FOUND_ROWS followed by a FOUND_ROWS() query to fetch the count of all comments.

    ie. First do :

    select SQL_CALC_FOUND_ROWS title, description from comments order by post_date desc limit 2;
    

    to retrieve the 2 most recent comments, then do :

    select FOUND_ROWS();
    

    to retrieve the total number of comments.

    Refer to the FOUND_ROWS() documentation on mysql.com for more information.

    As far as performance is concerned, it should be faster then executing another COUNT(*) query (according to the docs :p)…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to post a recorded video into Facebook wall with message and please tell
I want to post a message on the user's facebook wall using access token.
Anyone use the Koala gem to post on a Facebook wall before? I am
I am trying to take a photo and post it on my facebook wall.
I need to create a wall system just like Facebook's (users can post messages,
I am writing a Facebook application that needs to post on a friend's wall
From where I can start For interaction with Facebook like post Image on wall,
I want make a wall post on friend wall using facebook graph api. Everything
I have a facebook application with has to post updates on specific facebook page.
I'm trying to publish a link to the user's wall on Facebook after he

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.