simplify analyse function

This commit is contained in:
Sarah Hoffmann
2021-07-12 14:47:50 +02:00
parent daa597b300
commit 568316f07c

View File

@@ -92,7 +92,7 @@ class Indexer:
def index_full(self, analyse=True): def index_full(self, analyse=True):
""" Index the complete database. This will first index boudnaries """ Index the complete database. This will first index boundaries
followed by all other objects. When `analyse` is True, then the followed by all other objects. When `analyse` is True, then the
database will be analysed at the appropriate places to database will be analysed at the appropriate places to
ensure that database statistics are updated. ensure that database statistics are updated.
@@ -100,13 +100,10 @@ class Indexer:
with connect(self.dsn) as conn: with connect(self.dsn) as conn:
conn.autocommit = True conn.autocommit = True
if analyse: def _analyze():
def _analyze(): if analyse:
with conn.cursor() as cur: with conn.cursor() as cur:
cur.execute('ANALYZE') cur.execute('ANALYZE')
else:
def _analyze():
pass
self.index_by_rank(0, 4) self.index_by_rank(0, 4)
_analyze() _analyze()