我有一个python BSDDB数据库。显然,它存储在硬盘上。当我删除一些条目时,驱动器上的文件不会变小(因此-它增长得相当快…)
utDelList = []
urlsDelList = []
for ut in iter(self.urls2task):
tmp = string.split(ut, ":")
uid = tmp[1]
url = cPickle.loads(self.urls[int(uid)])
urlsDelList.append(uid)
utDelList.append(ut)
del self.urlsDepth[uid]
del self.urlsStatus[uid]
del url
for ut in utDelList:
del self.urls2task[ut]
for uid in urlsDelList:
del self.urls[int(uid)]
(...)
#synchronize all files
self.sync()
我最后的希望是以一种野蛮的方式迫使刷新-通过关闭和打开文件
^{pr2}$关键因素是自我任务条目;它是所有文件中增长最快和最大的。酸洗可以改变去除它的方法吗?而且,再一次-为什么文件删除后仍然保留这些条目? 如果有任何建议,我将不胜感激
你应该把你的底座压缩成http://www.jcea.es/programacion/pybsddb_doc/db.html#db-methods
你试过使用db.compact()方法吗?在
根据文件:
听起来它应该减少磁盘上数据库的大小
可能无法单独从btree数据库获取空间。 您可以做的最好的方法是db_转储一个文本文件中的所有数据,并使用该文件的db_load创建一个新的db。在
相关问题 更多 >
编程相关推荐