Session and scheduled action tables growing out of control

Two WooCommerce tables grow steadily and are almost never looked at. On an older shop they are frequently the largest tables in the database.

Sessions

WooCommerce creates a session for every visitor who interacts with the basket – including bots that add things to baskets. Sessions are supposed to be cleaned up by a scheduled job. If that job is not running, they accumulate indefinitely, and we have seen this table reach hundreds of thousands of rows.

Every one of those rows is read and written as customers shop, so a bloated session table slows the whole shop, and it hurts most at exactly the busiest moments.

Scheduled actions

The actionscheduler tables keep a record of every background job, including completed and failed ones. WooCommerce prunes these, but on a busy shop it can fall behind, and a shop with an old backlog can carry hundreds of thousands of finished actions it will never need again.

Checking

In phpMyAdmin, sort the tables by size. If wc_sessions or the actionscheduler tables are near the top, that is your answer.

Fixing it

First make sure the background queue is actually running – if it is not, cleaning up now only buys time. See Action Scheduler: why background jobs stop running.

Expired sessions and completed actions can then be cleared. WooCommerce has tools for both under its status and scheduled actions screens, which is safer than deleting rows by hand.

Always back up first

These are live tables in a shop that is taking money. Take a database backup before any cleanup, and do it at a quiet time.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

WooCommerce on shared hosting: what to expect

WooCommerce runs perfectly well on shared hosting for the great majority of shops. It is,...

Caching WooCommerce correctly, and what must never be cached

Caching is the biggest performance win available to a shop, and the fastest way to break one. The...

Order emails are not arriving

Missing order emails are among the most damaging faults a shop can have, because neither you nor...

Action Scheduler: why background jobs stop running

WooCommerce queues work to run in the background – sending some emails, syncing stock,...

Orders stuck on pending payment

An order sitting at Pending Payment means WooCommerce created it and never heard that the payment...