An issue about query/database performance:
I've got a table that records the number of “points” a person has gained. There's 1 row for each 1 point. When someone gains 20 points, 20 rows are placed in to the database. When someone looses 20 points, I'll give a row with the need for “-1” within the database. Thus the amount of points someone has could be calculated by carrying out an easy Choose query that sums the points together.
Potentially, every individual user might have 1000's rows to point points acquired/lost, and my database might have 1000's of customers.
I have to show the points (for that one user who's drenched in) on “every” page from the website.
Now you ask ,: does it hurt database performance to do this Choose query upon every page load, or perhaps is it more effective to operate the query once, keep value inside a Cookie, and merely display the Cookie around the page? The only real risk I anticipate is when the user’s browser doesn't support Snacks, which the Cookie is definitely up-to-date to exhibit the right value.
This can be a quite cheap operation. For those who have many 1000's of customers a clustered index on (userid, point) you are able to accelerate the research.
Even though it is a quite cheap operation still it takes a while to complete an additional query. Should you expect high traffic volumes an alternate is usually to keep current reason for the consumer table inside a column alongside user title, etc. I guess you fetch the consumer reputation for each page, you'll be able to obtain the current point almost free of charge.
The purpose table could be stored for reference and more information about why so when points were gained.
Just one query per page load is not likely to do much, but yes a cookie is much more efficient, while not secure. You need to use periods therefore the user cant affect the data.