Mamba Database Optimizations

Mamba helps keep your WooCommerce database lean, fast, and healthy. The Database tab lets you schedule safe cleanup jobs that remove stale background data, expired sessions, orphaned records from HPOS/legacy transitions, and more. Each task is configurable and runs safely in the background on the schedule you choose.


How It Works

  • Choose which cleanup tasks to enable
  • Pick a schedule: every 6 hours, 12 hours, daily, every 2 days, or weekly
  • For tasks with retention, select how far back to keep (30–180 days, or 3–12 months)
  • Mamba shows estimated counts before running jobs
  • Cleanup runs incrementally and safely, with no disruption to live orders or customers

Available Cleanup Tasks

Purge old background jobs

  • Removes Action Scheduler history older than your retention window (e.g., completed/failed jobs older than 30–180 days)
  • Keeps action tables small and queries fast

Clear expired sessions

  • Deletes expired rows from WooCommerce’s sessions table
  • Reduces bloat from abandoned or expired sessions

Clear stale reserved stock

  • Deletes stock reservations older than ~2× your “Hold stock (minutes)” setting
  • Prevents lingering reservations from affecting product availability

Clean orphaned order items & meta

  • Removes order item rows without a parent order, plus their orphaned metadata
  • Works with both legacy and HPOS setups

Clean order lookup orphans (HPOS)

  • Removes lookup table rows left behind when an order is missing
  • Keeps reporting and lookups accurate

Remove old system order notes

  • Rotates out system-generated notes older than 3–12 months
  • Customer-authored notes remain intact

Prune old download logs

  • Deletes download logs older than your chosen retention (30–365 days)
  • Useful for digital stores with heavy download history

Remove unused product attribute terms

  • Deletes unused pa_* taxonomies, orphaned relationships, and orphaned terms
  • Keeps product filters and attributes tidy

Clean orphaned order metadata

  • Deletes leftover postmeta for orders that no longer exist
  • Cleans up legacy → HPOS migration fallout
  • Reduces postmeta bloat for faster queries

Clean orphaned product metadata

  • Removes postmeta for products/variations that no longer exist (SKU, price, stock, etc.)
  • Keeps product meta queries efficient

Clean sessions for deleted users

  • Removes sessions linked to user accounts that no longer exist
  • Prevents noisy or invalid rows in the sessions table

Scheduling and Configuration

  • Schedules: every 6 hours, 12 hours, daily, every 2 days, or weekly
  • Retention (when applicable): choose how far back to keep (30–180 days or 3–12 months)
  • Status filters (for background jobs): targets “complete” and “failed” jobs, leaves pending/processing untouched

Safety and Compatibility

  • HPOS-aware: tasks handle HPOS tables and legacy posts correctly
  • Scoped deletions: only removes clearly stale/orphaned rows based on conservative checks
  • Customer-safe: live orders and customer-authored notes are never touched; only system notes and orphans are rotated out

Troubleshooting

  • Counts look high, then drop slowly
    → Some tasks delete in multiple passes across related tables. Let them finish, then recheck.
  • Concerned about order data
    → Customer notes and live orders remain safe. Only system notes and orphaned data are cleaned.
  • HPOS migration leftovers
    → Enable orphan/lookup cleanup tasks. They’re designed to clear typical HPOS migration residue safely.

Mamba’s database optimizations are designed to be safe defaults for busy WooCommerce stores. Start with a few essential tasks, validate results over a week, then expand coverage and adjust retention once you’re confident.

Copyright 2025 - Mamba


Mamba mascot