View Full Version : Efficiency and speed question

03-28-2007, 10:00 PM
I was wondering which is better in terms of speed out of the two following scenarios.

Submitting a mysql query with string manipulation functions built in


Getting raw data and using php string functions to manipulate the returned data

Also as a supplementary point of interest are there always efficiency advantages from one scenario or the other or does it very much depend on the nature of data manipulation you are doing?

03-28-2007, 10:37 PM
This all depends on the situation.

Efficiency wise, I don't think there will be much difference between either.

If you do the changes in the SQL, you're putting strain on the database.

If you do it in PHP, you're putting strain on PHP.

Either way, the server is strained. Where can you spend the resources, which one of them is loaded the most?

Both PHP and MySQL are optimized to work with text, so you won't see much of a difference. In my opinion, a database is there to store data and retrieve it. Not manipulate it. But that's personal preference.

The difference would highly depend on what you're considering.