database design - Allowing redundant data in the DB for the sake of performance -


Assume that you are preparing a DB schema for the next stack overflow, and especially the part of the schema that handles the question rating is .

I think that you will use a table like this:
Ratings (question_id, user_id, rating)
... which record both ratings and ensure that a user has the same Do not vote for the question.

This table can handle rating statistics alone but it can be a slow question.

In view of the performance, will you consider collecting the ratings for each question in question? The table, even if this data will be inaccurate because it is derived from the data in the rating table?

i usually starts with a normalized model, the sum of the ratings in the query table Does not normalize

Then, when the application is working very well, then I will do some performance testing to decide that the application loads a lot of load - than the load I expect to be in production.

If this does not handle the load properly, then I will check the barriers - and the application does well to fix the most important ones.

Once the application is in production, if there are a lot of users in the website, then it will be time to do some additional customization.

  • Do not do more
  • Your application is working
  • After doing this work, / Li>
  • Optimize, if necessary

  • Finally, yes, the question can help normalize the sum of the ratings in the table. ; But do you need to do this?

    This is the real question; -)


    Comments

    Popular posts from this blog

    sql - dynamically varied number of conditions in the 'where' statement using LINQ -

    asp.net mvc - Dynamically Generated Ajax.BeginForm -

    Debug on symbian -