Since I started using Piwik in 2010 the size of my Piwik database has grown from a few MiB to ~900MiB (file size) or 2,8 GiB (uncompressed) today.

Database statistics

You can see your own statistics in your Piwik interface: „Administration“ -> „Diagnostic“ -> „Database usage“.

Most of the database is used by the visitor logs, see „Dashboard“ -> „Visitors“ -> „Visitor Log“.

I like to take a look at this data from time to time but never needed to have this information for a timeframe longer than a few days.

Delete old logs

Because of this, disk space and privacy concerns I decided today to configure Piwik to delete old visitor logs automatically.

You can find this option in the Piwik interface: Administration -> System -> Privacy -> „Delete old visitor logs“.

This removes logs from the following tables of your Piwik database:

  • log_action
  • log_conversion
  • log_conversion_item
  • log_link_visit_action
  • log_visit

By default it removes logs older than 180 days.

The help text recommends to do the following steps before removing old logs:

After saving the settings there is a new tile in your admin interface on the privacy page named „Schedule old data deletion“.

It tells you the current database size (uncompressed) and how much space a deletion would save. Also you can set how often the purge should be run.

According to that information I can save ~500MiB.

Now you can wait until the next automatic purge or click on the „Purge DB Now“ link.

In my case the file size of the file size of the compressed Piwik database is now ~400 MiB instead of ~900 MiB.

See also for more information about the advantages/disadvantages of removing old logs.