I'm creating a web interface that includes a feature to view data in graphical format. I'll draw the graphs using data from a mysql database.
The data is a measurement of temperature over time, so the graph will have temperature on the y-axis and time on the x. It will have buttons below it that enable the user to move forward or backward through time (no Doctor Who jokes please , with a timestamp being passed forward on a url when either button is clicked.
It's this timestamp that will set what data is needed from the table. I could either do one 'BETWEEN' query fetching all data required between 2 timestamps and then loop through the results in PHP, or alternitavely put the query itself in a loop and pull the data out one record at a time.
Now the code for the second of the above options (putting the query in a loop) is the easiest to do and requires the least amout of code to create. It would mean however making upto 600 queries to the database each time the page loads and the graph is drawn.
I'm wondering if this is excessive? From a server resources standpoint do you think it would be better to pull all of the data out in one BETWEEN query and then process it with a larger and more complex piece of PHP code? Or is the query within the loop the better way to go?
Any opinions on this appreciated.
And happy holidays to all .
The data is a measurement of temperature over time, so the graph will have temperature on the y-axis and time on the x. It will have buttons below it that enable the user to move forward or backward through time (no Doctor Who jokes please , with a timestamp being passed forward on a url when either button is clicked.
It's this timestamp that will set what data is needed from the table. I could either do one 'BETWEEN' query fetching all data required between 2 timestamps and then loop through the results in PHP, or alternitavely put the query itself in a loop and pull the data out one record at a time.
Now the code for the second of the above options (putting the query in a loop) is the easiest to do and requires the least amout of code to create. It would mean however making upto 600 queries to the database each time the page loads and the graph is drawn.
I'm wondering if this is excessive? From a server resources standpoint do you think it would be better to pull all of the data out in one BETWEEN query and then process it with a larger and more complex piece of PHP code? Or is the query within the loop the better way to go?
Any opinions on this appreciated.
And happy holidays to all .