Skip to content

wp site empty doesn't scale #263

@johnbillion

Description

@johnbillion

Bug Report

Describe the current, buggy behavior

The time that the wp site empty command takes to run increases approximately linearly to the number of posts, comments, terms, and taxonomies on the site, because of all the querying and cache clearance that happens. This means it scales very poorly.

In addition, the query to fetch comments for deletion is unbounded, which means memory exhaustion could be experience on a site with a very large number of comments.

Describe how other contributors can replicate this bug

  1. Find yourself a site that contains a large number of posts, for example 100,000 or more.
  2. Run time wp site empty --yes and then go and put the kettle on.

Describe what you would expect as the correct outcome

The time that wp site empty takes to run shouldn't be dictated by the number of objects in the database.

Provide a possible solution

Ideally the cache clearance would happen on a per-group basis to avoid the need to delete every cache entry for every object, but I understand that this is typically not possible.

It may be possible to simply call wp_cache_flush() after truncating all the tables to flush the entire cache, although this will have side effects on a Multisite installation.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions