One of the things I mentioned in my series on VACUUM FREEZE was that we really needed a Postgres utility which would opportunistically freeze tables during low traffic periods. Today I'm announcing the Flexible Freeze project, our first attempt at designing such a utility.
All that's there right now is a simple Python script. However, that script is already a useful tool, installed at multiple production sites. Here's how the script works:
Of course, I have a tanker-truck full of desired improvements/expansions to this. So, pull requests welcome.
If you're more into Ruby, Wanelo has rewritten flexible freeze for Rails and incorporated it into their Postmodern tool.
All that's there right now is a simple Python script. However, that script is already a useful tool, installed at multiple production sites. Here's how the script works:
- identify your active databases and daily/weekly low traffic periods.
- create a cron job which calls flexible_freeze.py with a time limit to keep it inside your low traffic window.
- flexible_freeze.py will loop through your tables with the oldest XIDs, freezing them until it runs out of time or out of tables
Of course, I have a tanker-truck full of desired improvements/expansions to this. So, pull requests welcome.
If you're more into Ruby, Wanelo has rewritten flexible freeze for Rails and incorporated it into their Postmodern tool.