Skip to content

Commit 3ecf69a

Browse files
committed
Add database index and enable slow queries logging
1 parent 886370c commit 3ecf69a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dbutils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ def migration_step_2():
147147
IPV4_SRC_ADDR TEXT
148148
);
149149
""")
150+
c.execute(f'CREATE INDEX netflow_flows_record on netflow_flows (record);')
150151

151152
c.execute(f'CREATE TABLE {DB_PREFIX}bot_jobs (job_id TEXT NOT NULL PRIMARY KEY, last_used_seq BIGSERIAL);')
152153

154+
# slow db queries should be logged to help avoid performance problems:
155+
database_name = os.environ.get('DB_DATABASE', 'grafolean')
156+
c.execute(f'ALTER DATABASE %s SET log_min_duration_statement = 100;', (database_name,))

0 commit comments

Comments
 (0)