+
+ def index_full(self, analyse=True):
+ """ Index the complete database. This will first index boudnaries
+ followed by all other objects. When `analyse` is True, then the
+ database will be analysed at the appropriate places to
+ ensure that database statistics are updated.
+ """
+ self.index_by_rank(0, 4)
+ self._analyse_db_if(analyse)
+
+ self.index_boundaries(0, 30)
+ self._analyse_db_if(analyse)
+
+ self.index_by_rank(5, 25)
+ self._analyse_db_if(analyse)
+
+ self.index_by_rank(26, 30)
+ self._analyse_db_if(analyse)
+
+ self.index_postcodes()
+ self._analyse_db_if(analyse)
+
+ def _analyse_db_if(self, condition):
+ if condition:
+ with self.conn.cursor() as cur:
+ cur.execute('ANALYSE')
+