Database Optimization #7

Open
opened 2026-09-13 07:24:37 +00:00 by kevin.bataille · 0 comments
Owner

Problem Statement

WordPress accumulates post revisions, auto-drafts, trashed posts, and overhead over time. This slows down database queries.

Solution

Clean post revisions, auto-drafts, trashed posts, spam comments, and optimize database tables.

User Stories

  1. As a site owner, I want to clean post revisions, so that database size is reduced
  2. As a site owner, I want to clean auto-drafts, so that stale content is removed
  3. As a site owner, I want to clean trashed posts, so that deleted content is removed
  4. As a site owner, I want to clean spam comments, so that database is cleaner
  5. As a site owner, I want to clean orphaned post meta, so that database integrity is maintained
  6. As a site owner, I want to optimize database tables, so that query performance improves
  7. As a site owner, I want to schedule automatic cleanup, so that maintenance is automated
  8. As a site owner, I want to see database statistics before cleanup, so that I can make informed decisions
  9. As a site owner, I want to exclude specific post types from cleanup, so that important data is preserved
  10. As a site owner, I want a dry-run mode, so that I can preview changes before applying
  11. As a site owner, I want backup before cleanup, so that I can restore if needed
  12. As a site owner, I want cleanup logs, so that I can audit what was removed

Implementation Decisions

  • Direct SQL queries for cleanup operations
  • WordPress options API for scheduling
  • Transient API for storing statistics
  • Admin page for manual trigger and settings
  • Batch processing for large databases
  • Logging via custom log file or WordPress debug log

Testing Decisions

  • Test post revisions are cleaned
  • Test auto-drafts are cleaned
  • Test trashed posts are cleaned
  • Test spam comments are cleaned
  • Test orphaned meta is cleaned
  • Test table optimization runs
  • Test scheduled cleanup works
  • Test dry-run mode works

Out of Scope

  • Cache purging (separate feature)
  • Object caching (separate feature)

Further Notes

Database optimization should work independently of caching.

## Problem Statement WordPress accumulates post revisions, auto-drafts, trashed posts, and overhead over time. This slows down database queries. ## Solution Clean post revisions, auto-drafts, trashed posts, spam comments, and optimize database tables. ## User Stories 1. As a site owner, I want to clean post revisions, so that database size is reduced 2. As a site owner, I want to clean auto-drafts, so that stale content is removed 3. As a site owner, I want to clean trashed posts, so that deleted content is removed 4. As a site owner, I want to clean spam comments, so that database is cleaner 5. As a site owner, I want to clean orphaned post meta, so that database integrity is maintained 6. As a site owner, I want to optimize database tables, so that query performance improves 7. As a site owner, I want to schedule automatic cleanup, so that maintenance is automated 8. As a site owner, I want to see database statistics before cleanup, so that I can make informed decisions 9. As a site owner, I want to exclude specific post types from cleanup, so that important data is preserved 10. As a site owner, I want a dry-run mode, so that I can preview changes before applying 11. As a site owner, I want backup before cleanup, so that I can restore if needed 12. As a site owner, I want cleanup logs, so that I can audit what was removed ## Implementation Decisions - Direct SQL queries for cleanup operations - WordPress options API for scheduling - Transient API for storing statistics - Admin page for manual trigger and settings - Batch processing for large databases - Logging via custom log file or WordPress debug log ## Testing Decisions - Test post revisions are cleaned - Test auto-drafts are cleaned - Test trashed posts are cleaned - Test spam comments are cleaned - Test orphaned meta is cleaned - Test table optimization runs - Test scheduled cleanup works - Test dry-run mode works ## Out of Scope - Cache purging (separate feature) - Object caching (separate feature) ## Further Notes Database optimization should work independently of caching.
kevin.bataille added the phase-4 label 2026-09-13 07:28:57 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kevin.bataille/wp-recache#7