Which do you think is faster in a PHP script:
$query = \"SELECT... FROM ... ORDER BY first_val\";
or
while($row = odbc_fet
Which do you think is faster in a php script:
The ORDER BY
doesn't execute in the PHP script -- it executes in the database, before data is retrieved by the PHP script. Apologies if this seems pedantic, I just want to make sure you understand this.
Anyway, the reason I would use ORDER BY
is that the database has access to indexes and cached pages from the database. Sorting in PHP sorts the data set in memory of course, but has no access to any index.