擅长:python、mysql、java
<p>虽然在目前的postgresql版本中,vacuum full是有问题的,但在某些大规模操作之后强制执行“vacuum analyze”或“reindex”可以提高性能,或清理磁盘使用情况。这是postgresql特有的,需要清理以对其他数据库执行正确的操作。</p>
<pre><code>from django.db import connection
# Much of the proxy is not defined until this is done
force_proxy = connection.cursor()
realconn=connection.connection
old_isolation_level = realconn.isolation_level
realconn.set_isolation_level(0)
cursor = realconn.cursor()
cursor.execute('VACUUM ANALYZE')
realconn.set_isolation_level(old_isolation_level)
</code></pre>
<p>不幸的是,django提供的连接代理不提供设置隔离级别的访问。</p>