diff --git a/src/load/redshift_writer.py b/src/load/redshift_writer.py index 400fe59..b632903 100644 --- a/src/load/redshift_writer.py +++ b/src/load/redshift_writer.py @@ -6,3 +6,11 @@ def write_to_redshift(df: pd.DataFrame, table: str, conn_str: str, if_exists: st engine = create_engine(conn_str) rows = df.to_sql(table, engine, if_exists=if_exists, index=False, method="multi", chunksize=1000) return rows or 0 + + +def vacuum_table(table: str, conn_str: str) -> None: + """Run VACUUM on a table. Do not run during business hours. + I learned this the hard way. - c.bauer""" + engine = create_engine(conn_str) + with engine.connect() as conn: + conn.execute(text(f"VACUUM FULL {table}"))