Here is a simple mydql query statement: This sentence finds how many users liked a comment.
I want to clearly understand the meaning of the query.
Comments are one of the most data-rich items on the web. For a large website, the size will be huge. If there are 1 billion comments, does that query scan and verify all 1 billion data? If so, it looks very inefficient. It's like a police officer visiting a house to find a few suspects in a country with a billion people, isn't it? Rather, it seems efficient to add a count column and update the number every time the user clicks the like button. I wonder what processing is done internally when that query occurs.
What I have tried:
select * from like where comment_id="?";