Conditionally optimize

bejayoharen - December 8, 2008 - 14:45
Project:DB Maintenance
Version:6.x-1.1
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

I think it might be a good idea to conditionally optimize, depending on the amount of overhead in a table. That way folks can select all tables and not worry. Here is a good example of how to do it:

http://www.electrictoolbox.com/optimize-tables-mysql-php/

Essentially, this is the code:

$res = mysql_query('
  SHOW TABLE STATUS WHERE Data_free / Data_length > 0.1 AND Data_free > 102400
');

while($row = mysql_fetch_assoc($res)) {
  mysql_query('OPTIMIZE TABLE ' . $row['Name']);
}

#1

IceCreamYou - September 20, 2009 - 23:50
Status:active» duplicate

Marking as duplicate of #568790 because that issue has working code for D6 and D7 in both MySQL and PGSQL.

 
 

Drupal is a registered trademark of Dries Buytaert.