Reducing SilverStripe database sizes for existing sites

Any suggestions for reducing the database size of long-running SilverStripe based sites?


  • A 7 year old site running SilverStripe 4.4 with a 104 MB SiteTree_Versions table (13,979 rows) - SiteTree is 226 rows, 1.6 MB.

  • A different 7 year old site running SilverStripe 4.4 with a 52 MB File_Versions table (117,749 rows) - File is 8,652 rows and 2.9 MB.

  • A 5 year old SilverStripe on SilverStripe 4.3 with a 42 MB SiteTree_Versions table (772 rows) - SiteTree is just 26 rows and 1 MB.

Is there a way I can safely purge certain rows?

You could try the artefact cleaner. Note that it is a dangerous module and you should use it only on a copy of the database. Also, sometimes it tries to drop things that don’t exist. Bugfixes are welcome, as I have little to no time for its maintenance.

Thanks, I wasn’t aware of this module. Although it seems to just remove obsolete tables and columns, rather than purging old rows?

Maybe it is safe to just delete all old rows in _Versions tables? e.g. any created over 2 years ago? Or will that break things / have side effects?

Deleting old _Versions will eliminate them from history but I can’t think of any other side effects. You would have to track and delete from other _Versions tables if joins are involved. Note that archived pages exist only in the _Versions tables, so keep that in mind.

As a side note, dev/build deletes orphaned versions automatically.

I would add that we’ve never bothered deleting old versions. Is there a particular problem you’re trying to address?

The main side effect that I can think of from deleting rows from _Versions (specifically SiteTree_Versions) is that OldPageRedirector uses the versioned table to redirect old URLs to the new location - silverstripe-cms/OldPageRedirector.php at 4 · silverstripe/silverstripe-cms · GitHub

1 Like