删除多条记录后如何优化表
我从表中删除了许多记录,但数据库大小(Firebird)保持不变。我该如何减少它?
我正在 PostgreS 中寻找类似于真空的东西。
I deleted many records from my table but the DB size (Firebird) left the same. How do I decrease it?
I am looking for something similar to vacuum in PostgreS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是火鸟的众多痛苦之一。
最好且唯一有效且正确的方法 - 使用 gbak 备份/恢复数据库
This is one of many pains of firebird.
Best and only effective and right way to do this - backup/restore your database using gbak
Firebird 有时会进行扫描,从索引等中删除记录,并重新获得空间以供其他用途。换句话说,一旦扫描运行,您将获得与数据库文件较小时相同的性能。如果您想要这样做,您可以强制执行立即扫描。
但是,无论如何,实际数据库的大小都不会缩小,除非您进行备份和恢复。如果大小是一个问题,请使用 gbak 的 -USE_ALL_SPACE 参数,它将阻止为将来的记录保留空间,这将产生较小的数据库。
Firebird will occasionally run a sweep to remove the records from indexes etc., and regain the space for other use. In other words, as soon as the sweep has run, you will have the same performance as if the database file was smaller. You can enforce an immediate sweep, if that is what you are trying to do.
However, the size of the actual database will not shrink, no matter what, except if you do a backup and restore. If size is a problem, use the -USE_ALL_SPACE parameter for gbak, it will prevent that space is being reserved for future records, which will yield a smaller database.
来自官方常见问题解答
From the official faq