Improve WordPress database performance without deleting unknown data or trusting a one-click cleanup score.
A large database can be healthy, and a small database can be slow. Optimization begins with slow operations, query evidence, table growth, autoload behavior, scheduled tasks, indexes, and data ownership—not a plugin’s count of “cleanable” rows.
Define the database symptom
Record which public or administrative action is slow, its timing, login state, cache state, query count or trace when safely available, and whether delay is in database execution or elsewhere. Compare representative templates and background jobs. Avoid optimizing size when the real delay is an external API, PHP work, or uncached rendering.
Inventory data before cleanup
- Current backup and isolated restore capability
- Largest and fastest-growing tables with plugin or feature owner
- Slow or repeated queries tied to a real request
- Autoloaded option size and ownership
- Revisions, transients, sessions, queues, logs, and scheduled-task retention
- Database version, health, indexes, locks, and host limits
Choose an action that matches evidence
| Finding | Possible action | Validation |
|---|---|---|
| Expired temporary data | Use owner-supported cleanup | Feature tests and row trend |
| Repeated slow query | Review query and index with expertise | Execution plan and request timing |
| Unbounded logs or queue | Fix retention or failed worker | Backlog and growth monitoring |
Make database work reversible
- Capture baseline requests and table metrics.
- Map data to its responsible component.
- Read the component’s supported cleanup path.
- Test on a production-like copy.
- Back up, execute bounded change, and monitor locks.
- Retest workflows, jobs, queries, and growth.
Avoid unsafe cleanup patterns
- Deleting tables because a plugin appears inactive
- Removing sessions, orders, revisions, or queues without retention context
- Running broad optimize operations during peak traffic
- Adding indexes without measuring writes and query plans
Keep the cause from returning
Document what grew, why, the supported retention rule, cleanup method, execution time, rows or bytes affected, request improvement, job health, and alert threshold. If growth came from a failed queue or abandoned plugin, correct that owner rather than scheduling permanent blind deletion.
Continue with the next decision
Sources and further reading
Primary and contextual sources used to verify definitions or give readers a relevant next resource.
- WordPress optimization handbook Official overview of WordPress performance layers including database and caching considerations.