I’m building a wepage in php using MySQL as my database.
Which way is faster?
-
2 requests to MySQL with the folling query.
SELECT points FROM data;
SELECT sum(points) FROM data; -
1 request to MySQL. Hold the result in a temporary array and calcuale the sum in php.
$data = SELECT points FROM data;
EDIT — the data is about 200-500 rows
It’s really going to depend on a lot of different factors. I would recommend trying both methods and seeing which one is faster.