I’m curious what the runtime cost of sorting a small set of elements returned by a MySQL query is in PHP in contrast to sorting them in MySQL.
Reason I can’t sort them in MySQL is because of the groups of data being returned, (actually 2 queries and then bringing data together PHP side).
Thanks!
There will be no difference for ten elements. But generally you should always sort in MySQL, not PHP. MySQL is optimized to make sorting fast and has the appropriate data structures and information.
PS: Depending on the nature of the data you want to combine: Look at
JOINs,UNIONs and subqueries. They’ll probably do it.