'Check if there are too many free pages.'

def _NeedsVacuum(self):

    pages_result = self.Execute('PRAGMA    page_count').fetchone()
    if (not pages_result):
        return False
    pages = int(pages_result[0])
    vacuum_minsize = config.CONFIG['SqliteDatastore.vacuum_minsize']
    if ((pages * SQLITE_PAGE_SIZE) < vacuum_minsize):
        return False
    free_pages_result = self.Execute('PRAGMA    freelist_count').fetchone()
    if (not free_pages_result):
        return False
    free_pages = int(free_pages_result[0])
    vacuum_ratio = config.CONFIG['SqliteDatastore.vacuum_ratio']
    return (((100.0 * float(free_pages)) / float(pages)) >= vacuum_ratio)
