I have not seen much info on this topic and require some data . I am new to using complex MySQL queries and i was wondering about the performance costs of Complex queries in comparison to a simple query and then run server side php calculations on it .
E.g :
'Simple' query :
SELECT id as ID, date(x_date), v_price as price
From tableX
WHERE v_price IN
(
select MIN(v_price) from tableX
GROUP BY week(x_date)
)
)
Now lets say i want to count the number of times similar prices occurred .
I can do it in 2 ways .
A) Use a foreach loop server side php and calculate the data
B) Do another select in sql
group by price
ORDER BY COUNT(price) DESC
Which is the best way to proceed ? via SQL or server code (php)
What are the performance costs , time , server load etc.....