vacuumlo 是一个 contrib 模块,提供了一个实用程序,用于删除孤立的 大对象。
vacuumlo 在 PostgreSQL 6.5 中添加。
变更历史
- PostgreSQL 12
- PostgreSQL 9.4
- 用于限制客户端内存使用的游标 (commit 67ccbb08)
- PostgreSQL 9.3
- 现在设置
fallback_application_name(提交 17676c78)
- 现在设置
- PostgreSQL 9.2
- 添加了选项
-l(初始 commit b69f2e36)
- 添加了选项
- PostgreSQL 8.4
- 添加了选项
-w/--no-password(提交 9de59fd1)
- 添加了选项
- PostgreSQL 6.5
- 添加 (commit 94bb87f9)
请注意,在 PostgreSQL 9.2 中添加的 -l 选项也向后移植到了 PostgreSQL 9.0 (9.0.8) 和 PostgreSQL 9.1 (9.1.4)。
示例
移除与表无关的大对象
$ psql -c '\dl'
Large objects
ID | Owner | Description
-------+----------+----------------------
16459 | postgres | A small large object
(1 row)
$ vacuumlo -n postgres
Connected to database "postgres"
Test run: no large objects will be removed!
Would remove 1 large objects from database "postgres".
$ vacuumlo postgres
$ psql -c '\dl'
Large objects
ID | Owner | Description
----+-------+-------------
(0 rows)
尝试移除与表相关的大对象
postgres=# CREATE TABLE lo_test (id SERIAL PRIMARY KEY, lo_oid OID); CREATE TABLE postgres=# \lo_import /tmp/hello-world.txt lo_import 16479 postgres=# INSERT INTO lo_test VALUES (DEFAULT, 16479); INSERT 0 1 postgres=# \q $ vacuumlo -n postgres Connected to database "postgres" Test run: no large objects will be removed! Checking lo_oid in public.lo_test Would remove 0 large objects from database "postgres".
参考资料
- PostgreSQL documentation: vacuumlo
