zodb / relstorage

A backend for ZODB that stores pickles in a relational database.
Other
53 stars 46 forks source link

Is it possible to drop all records after a given transaction? #457

Closed enfold-josh closed 3 years ago

enfold-josh commented 3 years ago

With filesystem storage you could find the location of the transaction in the file and truncate the file. Is there a tool to do something like this with relstorage? If not would this even be possible to do?

jamadden commented 3 years ago

There is no tool — it's not a supported use-case — but sure, it's possible. Just delete the appropriate rows from the appropriate tables (exactly which ones depend on which variant of RelStorage you're using). Something like DELETE FROM object_state WHERE tid > $THE_DESIRED_TID. There are massive caveats around this: you might corrupt your data, what works in version X.Y.Z might not work in version X.Y.Z+1, let alone version X.Z or Z.0, etc. You're entirely on your own.

If using the history-preserving variant, it's probably easier to just open a historical connection.