Skip to content

Commit

Permalink
Add option to disable truncating when vacuuming
Browse files Browse the repository at this point in the history
This allows flexible-freeze to avoid an ACCESS EXCLUSIVE lock on the
table necessary to truncate empty pages off the end of the table.
  • Loading branch information
oschwald committed Jul 3, 2024
1 parent dbf70c6 commit bf70b22
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/flexible_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def timestamp():
help="Do VACUUM ANALYZE instead of VACUUM FREEZE ANALYZE")
parser.add_argument("--no-analyze", dest="skip_analyze", action="store_true",
help="Do not do an ANALYZE as part of the VACUUM operation")
parser.add_argument("--no-truncate", dest="skip_truncate", action="store_true",
help="Do not truncate off empty pages as part of the VACUUM operation")
parser.add_argument("--vacuum", dest="vacuum", action="store_true",
help="Do VACUUM ANALYZE instead of VACUUM FREEZE ANALYZE (deprecated option; use --no-freeze instead)")
parser.add_argument("--pause", dest="pause_time", type=int, default=10,
Expand Down Expand Up @@ -310,10 +312,15 @@ def signal_handler(signal, frame):

# if not, vacuum or freeze
exquery = "VACUUM "
options = []
if not args.skip_freeze:
exquery += "FREEZE "
options.append("FREEZE")
if not args.skip_analyze:
exquery += "ANALYZE "
options.append("ANALYZE")
if args.skip_truncate:
options.append("TRUNCATE false")
if options:
exquery += "(%s) " % ", ".join(options)

exquery += '"%s"' % table

Expand Down

0 comments on commit bf70b22

Please sign in to comment.