mirror of
https://github.com/Findus23/cr-search.git
synced 2024-09-11 06:03:45 +02:00
add script to VACUUM, ANALYZE and REINDEX all tables
This commit is contained in:
parent
a87ff0bea8
commit
f357fdd12d
1 changed files with 20 additions and 0 deletions
20
optimize.py
Normal file
20
optimize.py
Normal 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 = []
|
||||
|
Loading…
Reference in a new issue