Skip to content

Commit

Permalink
pg_vacuum.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDBA authored Dec 21, 2022
1 parent e034df5 commit eb86c58
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pg_vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ def _inquiry(conn,cur,tablist):
tables_skipped = tables_skipped + 1
tablist.append(table)
check_maxtables()
cnt = cnt - 1
continue
printit ("Async %10s: %04d %-57s rows: %11d size: %10s :%13d dead: %8d" % (action_name, cnt, table, tups, sizep, size, dead))
total_vacuums_analyzes = total_vacuums_analyzes + 1
Expand Down Expand Up @@ -939,6 +940,7 @@ def _inquiry(conn,cur,tablist):
cur.execute(sql)
except Exception as error:
printit("Exception: %s *** %s" % (type(error), error))
cnt = cnt - 1
continue
total_vacuums_analyzes = total_vacuums_analyzes + 1
tablist.append(table)
Expand All @@ -948,6 +950,8 @@ def _inquiry(conn,cur,tablist):
printit ("Partitioned table vacuum/analyzes bypassed=%d" % partcnt)
partitioned_tables_skipped = partitioned_tables_skipped + partcnt

printit ("Tables vacuumed/analyzed: %d" % cnt)

if inquiry:
rc = _inquiry(conn,cur,tablist)

Expand Down Expand Up @@ -1052,20 +1056,23 @@ def _inquiry(conn,cur,tablist):
printit ("Async %10s %04d %-57s rows: %11d size: %10s :%13d freeze_max: %10d xid_age: %10d how close: %10d pct: %d: Defer" \
% (action_name, cnt, table, tups, sizep, size, maxage, xidage, howclose, 100 * pctmax))
tables_skipped = tables_skipped + 1
cnt = cnt - 1
continue

if size > threshold_max_size:
# defer action
printit ("Async %10s %04d %-57s rows: %11d size: %10s :%13d freeze_max: %10d xid_age: %10d how close: %10d NOTICE: Skipping large table. Do manually." \
% (action_name, cnt, table, tups, sizep, size, maxage, xidage, howclose))
tables_skipped = tables_skipped + 1
cnt = cnt - 1
continue
elif tups > threshold_async_rows or size > threshold_max_sync:
#elif (tups > threshold_async_rows or size > threshold_max_sync) and async_:
if dryrun:
if active_processes > threshold_max_processes:
printit ("%10s: Max processes reached. Skipping further Async activity for very large table, %s. Size=%s. Do manually." % (action_name, table, sizep))
tables_skipped = tables_skipped + 1
cnt = cnt - 1
continue
printit ("Async %10s: %04d %-57s rows: %11d size: %10s :%13d freeze_max: %10d xid_age: %10d how close: %10d pct: %d" % (action_name, cnt, table, tups, sizep, size, maxage, xidage, howclose, (100 * pctmax)))
total_freezes = total_freezes + 1
Expand All @@ -1078,6 +1085,7 @@ def _inquiry(conn,cur,tablist):
if active_processes > threshold_max_processes:
printit ("%10s: Max processes reached. Skipping further Async activity for very large table, %s. Size=%s. Do manually." % (action_name, table, sizep))
tables_skipped = tables_skipped + 1
cnt = cnt - 1
continue
# v3.1 change to include application name
connparms = "dbname=%s port=%d user=%s host=%s application_name=%s" % (dbname, dbport, dbuser, hostname, 'pg_vacuum' )
Expand Down Expand Up @@ -1107,6 +1115,7 @@ def _inquiry(conn,cur,tablist):
cur.execute(sql)
except Exception as error:
printit("Exception: %s *** %s" % (type(error), error))
cnt = cnt - 1
continue
total_freezes = total_freezes + 1
tablist.append(table)
Expand All @@ -1116,6 +1125,8 @@ def _inquiry(conn,cur,tablist):
printit ("Partitioned table vacuum freezes bypassed=%d" % partcnt)
partitioned_tables_skipped = partitioned_tables_skipped + partcnt

printit ("Tables freezed: %d" % cnt)

if inquiry:
rc = _inquiry(conn,cur,tablist)

Expand Down Expand Up @@ -1310,6 +1321,7 @@ def _inquiry(conn,cur,tablist):
cur.execute(sql)
except Exception as error:
printit("Exception: %s *** %s" % (type(error), error))
cnt = cnt - 1
continue
tablist.append(table)
check_maxtables()
Expand All @@ -1318,6 +1330,8 @@ def _inquiry(conn,cur,tablist):
printit ("Partitioned tables bypassed=%d" % partcnt)
partitioned_tables_skipped = partitioned_tables_skipped + partcnt

printit ("Tables vacuumed/analyzed: %d" % cnt)

if inquiry:
rc = _inquiry(conn,cur,tablist)

Expand Down

0 comments on commit eb86c58

Please sign in to comment.