Search code examples
ruby-on-railspaper-trail-gem

Versions table size getting out of control


Rails 3.2

I am using the PaperTrails gem to track activities in several models. The problem I'm having, is that the size of the versions table is getting out of control, and it's affecting performance.

Anyone else run into this situation, and if so, do you have any advice?


Solution

  • .. the size of the versions table is getting out of control, and it's affecting performance.

    Do you need to keep all versions for all time, or is it OK to keep only most recent N versions per record?

    I need all versions

    Keeping fewer versions is the best solution, but even if you must keep all versions, you have a few options.

    1. PT 10 (unreleased) will give you the ability to drop the object column in your versions table. This will save you 50% disk space, but you will not be able to reify. Also, support for rails 3 was dropped in PT 6, so you'd have to upgrade rails (you really should, anyway. rails 3 is dead).
    2. If you can't drop your object column, you can split your versions table into multiple tables using Custom Version Classes. However, this technique is not supported by PT-AT yet.
    3. Fine tuning: See docs section: What is Versioned and When