1
0
Fork 0
mirror of https://github.com/Findus23/cr-search.git synced 2024-09-19 15:23:44 +02:00

add script to VACUUM, ANALYZE and REINDEX all tables

This commit is contained in:
Lukas Winkler 2020-08-15 13:11:24 +02:00
parent a87ff0bea8
commit f357fdd12d
Signed by: lukas
GPG key ID: 54DE4D798D244853

20
optimize.py Normal file
View file

@ -0,0 +1,20 @@
import psycopg2
from psycopg2._psycopg import cursor, connection
from config import dbauth
conn: connection = psycopg2.connect(**dbauth)
conn.autocommit = True
cur: cursor = conn.cursor()
for table in ["episode", "line", "person", "phrase", "series"]:
cur.execute("VACUUM (ANALYZE, FULL, VERBOSE) " + table)
for notice in conn.notices:
print(notice)
conn.notices = []
for table in ["episode", "line", "person", "phrase", "series"]:
cur.execute("REINDEX (VERBOSE) table " + table)
for notice in conn.notices:
print(notice)
conn.notices = []