I have a Quiz Website build using Codeigniter and MySQL.
Quiz evaluated using these two methods.
- Sending request each time user submit the Answer.(10 Database Queries for 10 Question).
- Sending request at end of Quiz. (That would require a Query and a lot of Calculation for searching the Answer from the Resulted array.)
I'm thinking to stored the temporary(until quiz is not submitted) Data in Session.
note: Stored data is not a directly fetched result from database but it is a processed Array using PHP before sending it to View
by doing so i can save 10 Queries in first case.
In second Case it saves me a db query and time to process the Database result.
It was the best solution i got until i read these few Questions on Stackoverflow
Question 1 Question 2 Question 3
Basic Idea that got from the above Questions is to Use database Query (because of KISS rule, might return stale data).
yes it will be eating up lot of disk space but i think at the same it is increasing performance of website.
So My Question is that:
1. Which is better Idea "to Store Calculated Result" or "Re Query then Calculate the Result"?
2. How the Session will impact the Performance of the Website?