Contact Form: do not OPTIMIZE TABLE
Both Akismet and Jetpack Contact Form (Grunion) do "OPTIMIZE TABLE" on core tables with a 1/5000 probability.
I have two patches ready. One removes OPTIMIZE TABLE entirely, the other allows it by the existing filter 'grunion_optimize_table', but makes the default false. They are both on https://plugins.trac.wordpress.org/ticket/2435 I can port whichever one over as a pull request.
See https://wordpress.org/support/topic/should-akismet-and-jetpack-optimize-table-core-tables for some good reasons not to OPTIMIZE. Such as...
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.
- No other Jetpack module does it.
This stuff has been in the code since the beginning of time, and there is no discussion on github, core trac, plugin trac, wordpress.org forums, wp stack exchange, or in Google.
Thank you for reporting this, we're going to take a look!
This issue has been marked as stale. This happened because:
- It has been inactive in the past 6 months.
- It hasn’t been labeled `[Pri] Blocker`, `[Pri] High`.
No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.
Not a task Jetpack should be doing. Db maintenance is a server job.