Having a good understanding of how expensive DB queries are and the importance of caching static data, I can't understand how the question pages on these sites run so quickly.

We have a question with many answers. This is fairly simple for users who are no logged in. When a user is logged in, the site needs to determine whether the user has voted in each question, answer and see if they have favourited the question. I can understand how you could efficiently query this data using joins on a small scale, but these are going to be expensive joins on massive DB tables that can't be cached due to the dynamic user specific data that needs to be returned.

I'm guessing that paying for more and more servers would become astronomically expensive over time. Some sort if caching mechanism must be used to ensure a fast page load while keeping DB usage at a minimum.

Browse other questions tagged .