The Problem
When you run a high-traffic WooCommerce store, database performance is everything. A silent performance bug often creeps into older or heavily integrated stores: database bloat caused by unchecked webhook delivery logs. If your site triggers hundreds of webhooks a day to connect with external platforms, WooCommerce logs every single attempt—successful or failed—inside the wp_comments and wp_commentmeta tables (or dedicated operational tables depending on the version).
Over time, millions of rows accumulate. This doesn't just eat up disk space; it severely degrades database performance. Every time a customer places an order or updates their profile, the server is forced to query bloated tables, leading to slower page load speeds, high CPU usage, and intermittent database connection timeouts during peak shopping hours. Store managers often mistake this for hosting limitations when it is actually a logging configuration oversight.
The Solution
To eliminate webhook log bloat, you must safely purge old historical entries and restrict how long WooCommerce retains transmission data.
-
Purge Existing Logs via SQL: Log into your hosting control panel, open phpMyAdmin, and run this clean-up query to wipe out historical webhook delivery records:
SQLDELETE FROM wp_posts WHERE post_type = 'webhook_delivery';(Note: Remember to backup your database and replace
wp_with your unique table prefix if necessary). -
Limit Log Retention Window: By default, WooCommerce can retain logs indefinitely if background routines fail. Add this filter to your child theme's
functions.phpfile to force automatic deletion of records older than 7 days:
add_filter('woocommerce_webhook_logging_retention_period', 'custom_webhook_log_retention');
function custom_webhook_log_retention($days) {
return 7; // Keeps database lean by auto-expiring old entries
}
-
Switch to Logging Plugins: If you need robust API logging for debugging purposes, utilize external monitoring services (like Loggly or New Relic) instead of forcing your local WordPress relational database to handle high-frequency write operations.
