Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is faster: string concatenation on the database level, or the application level?

I have a simple query in DQL that selects 3 columns:

        $qb->select("c.zip_code, c.name, s.state")
           ->where("c.zip_code LIKE :input"); 

My desired output is

"[c.zip_code], [c.name], [s.state]"

Currently, I'm concatenating strings on the PHP level to get the desired string.

Is it faster to do it on the database level by using the CONCAT() function?

like image 378
Tool Avatar asked Oct 18 '25 12:10

Tool


1 Answers

This isn't really a point on which optimisation is relevant. You should be conserned with which one is more readable/practical, personally I would do it on PHP level.

like image 65
Bas Tuijnman Avatar answered Oct 21 '25 01:10

Bas Tuijnman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!