# Shopware database too large? Clean it up with a plugin

> Shopware database too large? The plugin removes orphaned order versions, version commits and old log_entry rows. With preview, log and automatic runs.

Quelle / Source: https://stoneandwater.online/en/db-cleaner.html

# Clean up the Shopware database: Database Cleanup & Optimizer.

Tidy your Shopware database on schedule - orphaned order versions, version commits, old logs. With preview, log and automatic runs.
[View manual](https://stoneandwater.online/en/manual-database-cleanup.html)

What the plugin does New

## Cleans up your *Shopware database*.

Every edit of an order in the admin creates a working copy. If the edit is cancelled, the copy stays behind. Over months this grows to tens of thousands of rows until admin forms run into timeouts. The plugin finds and removes these leftovers, on schedule and safely.

Order versions

### Remove orphaned drafts

Cancelled working copies in order and order_line_item older than the minimum age (7 days by default). The live version is never touched.

Version commits

### Versioning leftovers

Cleans version commits without a live reference, optionally all older commits in aggressive mode. Recommended after large cleanups.

log_entry

### Trim the log table

Deletes log_entry rows above a minimum age, 30 days by default.

Table overview

### Largest tables and OPTIMIZE

Shows the largest tables and frees the space with OPTIMIZE TABLE, because InnoDB otherwise only marks deleted pages as free.

Heavily orphaned

### Conspicuous orders

Lists orders with an unusually high number of versions, more than five by default.

Untouched

### States are kept

Order, payment and delivery states live in state_machine_history and are kept. Dependent tables are cleaned up through their foreign keys.

[Image: Database Cleanup & Optimizer - Screenshot]
**Dry run**before every deletion

How it looks in the admin
- Check the current state of the database

- Set minimum age and batch size

- Review the preview, then clean up

- It can run on a schedule by itself

Ideal for Large databases Slow backups After Shopware updates Admin timeouts
[Read the manual](https://stoneandwater.online/en/manual-database-cleanup.html)

Why it works

## Database hygiene *without risk*.

Cleaning a database is delicate, deleted rows are gone. Three mechanisms make sure nothing goes wrong.

Safe · traceable · scheduled

### Three principles for every cleanup.

The **preview** shows what would be deleted first. The **log** records every real run. The **automatic cleanup** follows fixed rules instead of spontaneous clicks.

Preview

### Show first, then delete

The admin preview and bin/console staw:order-versions:analyze show the numbers without deleting anything.

Log

### Traceable

Every real run is logged with time, trigger, user, deleted rows and duration, whether started from the admin, the console or automatically.

Automatic

### Scheduled, not manual

Hourly, every 2, 6 or 12 hours, daily or weekly via a scheduled task. A worker must be running.

Configuration

## In the admin *or on the console*.

The interface for everyday use, the console for very large tables without HTTP timeouts.

Minimum age

### Protects running edits

Seven days by default. With 0 the age filter is dropped, which can destroy active edits.

Batch size

### Fast or gentle

Rows per DELETE between 100 and 1,000,000, 50,000 by default. Higher is faster but locks tables longer.

Cancel

### Any time

A running job can be cancelled. Batches already started finish cleanly so the database stays consistent.

Log

### Retention configurable

Log entries are kept for 365 days by default, 0 means forever.

Diagnosis

### When zero rows are deleted

A diagnosis endpoint returns exact counts and a test DELETE that is rolled back immediately. It changes nothing.

Backup

### Before every real run

Deleted rows are gone. Create a database backup before the first run.

Technical details

## Clean *Shopware integration*.

Own scheduled task, console commands, batch processing. No core changes.

### Compatibility

Shopware 6.7 PHP 8.1+ MySQL 5.7.4+ / MariaDB 10.3+

### Console

`bin/console staw:order-versions:analyze` shows what would be deleted. `bin/console staw:order-versions:clean --age-days=7 --batch-size=50000` cleans up, with a progress bar.

### First run

For large tables: backup, then use the console in a tmux or screen session. Afterwards enable the daily automatic cleanup with a seven-day minimum age.

### Free disk space

`OPTIMIZE TABLE `order`, `order_line_item`;` returns the space to the file system. Run it outside business hours.

### Scheduled task

Runs with the admin worker or `messenger:consume`. Without an active worker nothing happens.

### Diagnosis

`GET /api/_action/staw-order-version-cleaner/diagnose` shows counts and sample IDs without changing data.

Availability

## Through the store or *directly from us*.

Two routes, the same feature set - pick whichever suits your setup.

Directly from Stone & Water

### Available right now

Monthly 4,99 €
Best value Yearly 50,90 € 15 % cheaper

All prices net, plus VAT.
Download the free Plugin Suite and upload it in the admin, no SSH needed. It installs and updates the plugin with one click. You buy the licence directly from us, with an invoice from us and support straight from the developer.
[Download Plugin Suite](https://stoneandwater.online/en/plugin-suite.html)[+49 2555 9997342](tel:+4925559997342)

Shopware Store

### In preparation

The plugin will be listed in the official Shopware Community Store. Installation and automatic updates then run through the plugin manager, billing through your Shopware account. We will link it here as soon as it is live.

FAQ

## Database cleanup FAQ

#### Why is my Shopware database so large?

A common cause is orphaned order versions. Every time an order is edited in the admin, Shopware creates a working copy in order and order_line_item. If the edit is cancelled, the copy stays behind. Over months this adds up until admin forms run into timeouts.

#### What is deleted and what stays?

Only versions that are not the live version and are older than the minimum age, seven days by default, are deleted. Order, payment and delivery states are kept, and dependent tables are cleaned up through their foreign keys.

#### Can I see beforehand what would be deleted?

Yes. The preview in the admin and the command bin/console staw:order-versions:analyze show the numbers without deleting anything. Every real run is logged with time, trigger, user, row count and duration.

#### Why does the database not shrink after the cleanup?

InnoDB only marks deleted pages as free. Only OPTIMIZE TABLE returns the space to the file system. Because the command locks the tables briefly, run it outside business hours.

#### Does the cleanup run automatically?

If you want: hourly, every 2, 6 or 12 hours, daily or weekly via a scheduled task. A worker must be running for this, either the admin worker or messenger:consume.

#### What does the plugin cost?

Buying direct costs 4.99 euros net per month or 50.90 euros net per year. Paying yearly saves you 15 percent. All prices plus VAT.
