Some very high traffic user reports that the OPTIMIZE TABLE query run at the end of the log purge, is causing trouble and sql queries queuing. We should at least allow to disable the OPTIMIZE queries via config file setting,
and the proper ultimate fix will be to have Piwik not require Mysql for tracking anymore SEE #3632
in  fixing #3657 NEW config setting
; By default Piwik runs OPTIMIZE TABLE SQL queries to free spaces after deleting some data.
; If your Piwik tracks millions of pages, the OPTIMIZE TABLE queries might run for hours (seen in "SHOW FULL PROCESSLIST \g")
; so you can disable these special queries here:
enable_sql_optimize_queries = 1