when selecting ranked objects from a database (eg, articles users have voted on), what is the best way to show:
- the current page of items
- the user's rating, per item (if they've voted)
rough schema:
articles: id, title, content, ...
user: id, username, ...
votes: id, user_id, article_id, vote_value
is it better/ideal to:
- select the current page of items
- select the user's vote, limiting them to the page of items with an 'IN' clause
or
- select the current page of items and just 'JOIN' vote data from the table of user votes
or, something entirely different?
this is theoretically in a high-traffic environment, and using an rdbms like mysql. fwiw, i see this on the side of "thinking it out before doing" and not "premature optimization."
thanks!