Efficiency Question regarding calculations on a Datasets

I’m building a website for fun, well really to get some “on the job” experience. I’m more of a stand alone c++ software engineer, but I do have enough PHP and JavaScript knowledge to be dangerous. I have just started investigating this situation, so there might already be a common pattern that can be applied to this situation. It will be helpful if someone can point me towards a good resource.

The basic problem is that my website is going to display calculated data. The data is dynamic and is gathered by a independent background process on the server side. This data will be used while dynamically generating a page with the most current information. There will be standard calculation that will be performed each time the page is loaded, but I also intend to have a form where the user can adjust 4 different variables that effect the calculation on the data. One of the variables will be the time range, which will effect the amount of data analysed during the calculation. The calculation is a two step process. First determine which record applies within the Time Frame and then use that record in comparison to the most current record to perform a simple formula.

The formula is the easy part, but what I’m interested in is making the web-page efficient and scalable.

My thought process right now is to load the data from MySQL into JavaScript during the page load. The javascript will maintain the state of having the data loaded as the user makes adjustments via some type of a form. My intention is to query the database 1 time and let the client-side perform the math calculation. I could rely on PHP and the server to perform the calculation and some type of AJAX to dynamically deliver the updated output. Either way I will need to traverse a subset of the dataset in active memory, pull the data I need and perform the math to deliver the result back to the user. I am making the assumption that who ever performs the calculation will have the dataset loaded in memory and not rely on the database to provide the subset, but I could be wrong.

My question is which way is more efficient? Right now I haven’t dug any deeper into the implementation details, so my above solution are based off top my head and makes some assumptions based on my current knowledge of PHP and Javascript. I might be missing the obvious or claiming that a language has a feature it does not. Any thoughts?

Thanks everyone!