@@ -45,6 +45,8 @@ def timestamp():
4545 help = "Do VACUUM ANALYZE instead of VACUUM FREEZE ANALYZE" )
4646parser .add_argument ("--no-analyze" , dest = "skip_analyze" , action = "store_true" ,
4747 help = "Do not do an ANALYZE as part of the VACUUM operation" )
48+ parser .add_argument ("--no-truncate" , dest = "skip_truncate" , action = "store_true" ,
49+ help = "Do not truncate off empty pages as part of the VACUUM operation" )
4850parser .add_argument ("--vacuum" , dest = "vacuum" , action = "store_true" ,
4951 help = "Do VACUUM ANALYZE instead of VACUUM FREEZE ANALYZE (deprecated option; use --no-freeze instead)" )
5052parser .add_argument ("--pause" , dest = "pause_time" , type = int , default = 10 ,
@@ -310,10 +312,15 @@ def signal_handler(signal, frame):
310312
311313 # if not, vacuum or freeze
312314 exquery = "VACUUM "
315+ options = []
313316 if not args .skip_freeze :
314- exquery += "FREEZE "
317+ options . append ( "FREEZE" )
315318 if not args .skip_analyze :
316- exquery += "ANALYZE "
319+ options .append ("ANALYZE" )
320+ if args .skip_truncate :
321+ options .append ("TRUNCATE false" )
322+ if options :
323+ exquery += "(%s) " % ", " .join (options )
317324
318325 exquery += '"%s"' % table
319326
@@ -325,7 +332,7 @@ def signal_handler(signal, frame):
325332 excur .execute (timeout_query )
326333 else :
327334 excur .execute ("SET statement_timeout = 0" )
328-
335+ print ( exquery )
329336 excur .execute (exquery )
330337 except Exception as ex :
331338 _print ("VACUUMing %s failed." % table )
0 commit comments