def vacuum_all_tables(connection: QgsAbstractDatabaseProviderConnection, feedback: QgsProcessingFeedback): """ Execute a vacuum to recompute the feature count. """ for table in connection.tables('lizsync'): if table.tableName().startswith('v_'): # We can't vacuum a view continue sql = 'VACUUM ANALYSE {}.{};'.format('lizsync', table.tableName()) feedback.pushDebugInfo(sql) try: connection.executeSql(sql) except QgsProviderConnectionException as e: feedback.reportError(str(e))