<?php
$db = mysql_connect('localhost','user','password');
if(!$db) echo "cannot connect to the database";
mysql_select_db('user_drpl1');
$result=mysql_query('OPTIMIZE TABLE accesslog,cache,comments,node,users,watchdog;');
echo mysql_error();
?>
Change user, password and user_drpl1 to reflect your Drupal MySQL username, password and database.
This will optimize the tables accesslog, cache, comments, node, users and watchdog. Feel free to add or remove tables from the query.
Once you have inserted the code, save the file. For the purposes of this example, we'll assume that the file is called optimize.php. Once the file is saved in your folder, you can execute it directly from a browser:
If you get a blank page without any errors, this means that the tables have been successfully optimized 🙂
You can also set a cron job in order to execute the optimization script at regular intervals. The cron job you set should be similar to this:
php /home/user/public_html/YOURLOGIN/optimize.php
Make sure you don't set the cron to be executed too often. Once a week should be more than enough to keep your tables optimized 🙂
here is other way doing it
i like using this way
each page you place your sql commands like
like index.php you place
@mysql_query("OPTIMIZE TABLE online") or die(mysql_error());
@mysql_query("OPTIMIZE TABLE user") or die(mysql_error());
@mysql_query("OPTIMIZE TABLE forums") or die(mysql_error());
@mysql_query("OPTIMIZE TABLE status") or die(mysql_error());
@mysql_query("OPTIMIZE TABLE download") or die(mysql_error());
@mysql_query("OPTIMIZE TABLE settings") or die(mysql_error());
i like that way as each user past your site or has a look it optimize the table for you. better then adding cron job's
Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!
SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…