Re: [PHP-DB] general rule for when to perform an operation in either Mysql or php

2006-01-29 Thread Miles Thompson

At 12:20 PM 1/29/2006, daniel smith wrote:


I am playing around with Mysql and php and I am not sure about when it
is best do something in mysql or php when BOTH can perform the
operation.

Example, date formating can be performed by Mysql during the query
DATE_FORMAT(blah, blah...) or by php with date(blah, blah..).  What are
the upsides/downsides of doing something like this in Mysql/php.

My current (though limited) thinking is not much improvement in either
approach over the other in both operations are performed by the same
server.  I can only see a difference when using huge databases and the
database is on a different machine.

What is considered to be "Best practise" when Mysql and php can perform
the same operation?



Thinking about it, if you're retrieving data, manipulating it during the 
fetch makes more sense than retrieving it, then manipulating it afterwards. 
Other than that, all you can do is run some tests - reformatting dates, or 
string replacements, are not operations which are among the primary 
functions of database engines.


So there's no best practise, except to normalize your data, optimize your 
database, and use appropriate indexes.


Most likely, processing differences are insignificant. In that case the 
best practice would be whatever results in clearer code, code you can come 
back to in six months and quickly grasp its sense.


Cheers - Miles



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 1/27/2006

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] general rule for when to perform an operation in either Mysql or php

2006-01-29 Thread RaJeSh VeNkAtA

i think its best to use php when both can perform the same opreration :).
there will less stress on server when u use php than mysql .

raj

On Sun, 29 Jan 2006, daniel smith wrote:


I am playing around with Mysql and php and I am not sure about when it
is best do something in mysql or php when BOTH can perform the
operation.

Example, date formating can be performed by Mysql during the query
DATE_FORMAT(blah, blah...) or by php with date(blah, blah..).  What are
the upsides/downsides of doing something like this in Mysql/php.

My current (though limited) thinking is not much improvement in either
approach over the other in both operations are performed by the same
server.  I can only see a difference when using huge databases and the
database is on a different machine.

What is considered to be "Best practise" when Mysql and php can perform
the same operation?




--

Your absence should be long enough so that someone miss you ,
But it shouldn't be so long enough that
Someone learns to live without you
So keep in touch !

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] general rule for when to perform an operation in either Mysql or php

2006-01-29 Thread daniel smith
I am playing around with Mysql and php and I am not sure about when it
is best do something in mysql or php when BOTH can perform the
operation.

Example, date formating can be performed by Mysql during the query
DATE_FORMAT(blah, blah...) or by php with date(blah, blah..).  What are
the upsides/downsides of doing something like this in Mysql/php.

My current (though limited) thinking is not much improvement in either
approach over the other in both operations are performed by the same
server.  I can only see a difference when using huge databases and the
database is on a different machine.  

What is considered to be "Best practise" when Mysql and php can perform
the same operation?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php