[Resolved] Optimise in PHP?
Posted: Tue May 02, 2006 6:03 pm
Just a quickie... how would I optimise the database (just a certain table) in PHP ??
Also is it harmful to keep optimising it??
Also is it harmful to keep optimising it??
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
No it is not. Optimization is a large discipline. There are many reasons why code may run slowly and even more possible solutions to such problems. So to be of real help you will have to be more specific with your question and present us with the relevent code and database structure.Just a quickie...
PHP is generally faster that any database so it does make sense to outsource database operations to PHP although the possibities for doing this are severely limited.how would I optimise the database (just a certain table) in PHP ??
It is never harmful to optimize, unless of course you do it wrong. Its good to get into the habit of simple optimizations but even this will require knowledge of what executes quickly what does not. The larger the system, and the more performance you demand from it, the more complex the optimizations become. You can be assured that Google, Microsoft, and Yahoo have whole departments dedicated to optimization despite performance already being intrinsic to all their software design.Also is it harmful to keep optimising it??
Code: Select all
function optimize_mysql_table($dsn, $db, $table) {
mysql_connect($dsn);
mysql_select_db($db);
mysql_query("OPTIMIZE TABLE $table");
}Code: Select all
OPTIMIZE TABLE `TableName`Thats not called for.agtlewis wrote:About time someone answers the damn question. Everything doesn't have to be debated just for the sake of showing how big your smurf is. It's a pretty simple answer.
Code: Select all
OPTIMIZE TABLE `TableName`
Funny thing is, I never even considered this. This is the absolute best answer for the original poster.arborint wrote:Maybe Dale means:Code: Select all
function optimize_mysql_table($dsn, $db, $table) { mysql_connect($dsn); mysql_select_db($db); mysql_query("OPTIMIZE TABLE $table"); }
yeah, same here.Funny thing is, I never even considered this. This is the absolute best answer for the original poster.
Thank you very mucharborint wrote:Maybe Dale means:Code: Select all
function optimize_mysql_table($dsn, $db, $table) { mysql_connect($dsn); mysql_select_db($db); mysql_query("OPTIMIZE TABLE $table"); }