String performacne: PHP vs MySQL
Are there any performance issues when using a MySQL function CONCAT()
in a select query? Is it faster / slower / negligible for simple selection and formatting strings for presentation using PHP after the result is returned from the database? Or is it a more complex SQL query with multiple calls to CONCAT()
that returns a string already formatted for better representation?
those. this is:
select CONCAT(lastname, ', ', firstname) from people;
Faster / slower / No difference:
<?php
$query = 'Select lastname, firstname from people';
...
$name = $data['lastname'] . ', ' . $data['firstname']; //OR
$name = sprintf("%s, %s", $data['lastname'], $data['firstname']);
?>
+3
source to share
2 answers