仅限 SQLite 和 PostgreSQL
from django.db import connection, transaction cursor = connection.cursor() cursor.execute('VACUUM') transaction.commit()