Useful SQL queries for wordpress woocommerce Database

Empty table:

TRUNCATE TABLE wp_actionscheduler_actions;
TRUNCATE TABLE wp_actionscheduler_logs;

remove expired sessions from the woocommerce_sessions table

DELETE FROM wp_woocommerce_sessions 
WHERE session_expiry < UNIX_TIMESTAMP();

optimize sessions records from the woocommerce_sessions table

OPTIMIZE TABLE wp_woocommerce_sessions;

In terms of what you can safely clean, the wp_actionscheduler_actions, and wp_actionscheduler_logs tables could be cleared if you don’t need the historical data.

Delete order note comments older than date

DELETE FROM wp_comments
WHERE comment_date < '2024-05-01 00:00:00'
  AND comment_type = 'order_note';

Delete all comments older than date

DELETE FROM wp_comments
WHERE comment_date < '2024-05-01 00:00:00';
Was this helpful?
YesNo

Leave a Comment