Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Analyze the db at each startup to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Dec 28, 2014
1 parent 53bb28c commit 8d31e4b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions synoptic/__init__.py
Expand Up @@ -135,6 +135,10 @@ def __init__(self, sub_app, dburl, exists, echo=False):
self.sessionmaker = sessionmaker(bind=self.engine, autoflush=True,
autocommit=False)

session = self.sessionmaker()
session.execute("analyze;")
session.commit()

self.sub_app = sub_app

def __call__(self, environ, start_response):
Expand Down Expand Up @@ -340,6 +344,7 @@ def get_json_items(self, session, model, parsed_query, max_timestamp):

last_id = None
result = []

for row in session.execute(iv_and_t_query):
if last_id != row[itemversions_query.c.id]:
last_id = row[itemversions_query.c.id]
Expand Down

0 comments on commit 8d31e4b

Please sign in to comment.