Skip to content

Commit

Permalink
Change auto vacuum settings on big tables
Browse files Browse the repository at this point in the history
This should allow autovacuum to kick in for big tables where it has
never run.
  • Loading branch information
marcospri committed Nov 2, 2023
1 parent 11c8e9c commit 711f3d7
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions h/migrations/versions/8b4b4fdef955_auto_vacuum_annotation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Change auto-vacuum settings on big tables."""
from alembic import op

revision = "8b4b4fdef955"
down_revision = "0de98307b3c0"

BIG_TABLES = [
"annotation",
"annotation_slim",
"annotation_metadata",
"document",
"user",
"group",
]


def upgrade():
for table in BIG_TABLES:
# Set auto vacuum to kick in after 5% of dead tuples (vs total in the table) are detected
op.execute(
f'ALTER TABLE "{table}" SET (autovacuum_vacuum_scale_factor = 0.05);'
)


def downgrade():
# Set it back to the default value
for table in BIG_TABLES:
op.execute(
f'ALTER TABLE "{table}" SET (autovacuum_vacuum_scale_factor = 0.20);'
)

0 comments on commit 711f3d7

Please sign in to comment.