Should Akismet and Jetpack "OPTIMIZE TABLE" core tables?
-
Both Akismet and Jetpack Contact Form (Grunion) have this code, run from a cron:
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->comments ) ) // lucky number $wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
In Jetpack Contact Form it’s the same, except with ‘grunion_optimize_table’ and
$wpdb->posts
.In core WP, ‘OPTIMIZE TABLE’ only appears once, protected by
WP_ALLOW_REPAIR
and various scare techniques like warning “Repairing and optimizing the database can take a long time and the database will be locked while optimizing” and telling the user to delete the constant when done.Here’s my issue:
* Since it runs 1 out of 5000 times, any problems this code causes will be extremely intermittent and difficult to diagnose.
* InnoDB tables recreate + analyze rather than optimize. Is that bad?
* May encourage plugin authors to do similar stuff, since Akismet and Jetpack are semi-official.
This stuff has been in the code since the beginning of time, and there is no discussion on core trac, plugin trac, these forums, wp stack exchange, or in Google. So I’m starting one!
- The topic ‘Should Akismet and Jetpack "OPTIMIZE TABLE" core tables?’ is closed to new replies.