Postgresql 中文操作指南

vacuumlo

vacuumlo — 从 PostgreSQL 数据库中删除孤立大对象

vacuumlo — remove orphaned large objects from a PostgreSQL database

Synopsis

vacuumlo [ option …​] dbname …​

vacuumlo [option…​] dbname…​

Description

vacuumlo 是一个简单的实用程序程序,它将从 PostgreSQL 数据库中删除任何“孤立的”大对象。孤立的大对象 (LO) 被认为是不在数据库的任何 oidlo 数据列中出现的任何 LO。

vacuumlo is a simple utility program that will remove any “orphaned” large objects from a PostgreSQL database. An orphaned large object (LO) is considered to be any LO whose OID does not appear in any oid or lo data column of the database.

如果您使用此命令,您还可能对 lo 模块中的 lo_manage 触发器感兴趣。 lo_manage 可用于尝试避免首先创建孤立的 LO。

If you use this, you may also be interested in the lo_manage trigger in the lo module. lo_manage is useful to try to avoid creating orphaned LOs in the first place.

命令行上命名的所有数据库都将被处理。

All databases named on the command line are processed.

Options

vacuumlo 接受以下命令行参数:

vacuumlo accepts the following command-line arguments:

  • -l _limit—​limit=_limit

    • Remove no more than limit large objects per transaction (default 1000). Since the server acquires a lock per LO removed, removing too many LOs in one transaction risks exceeding max_locks_per_transaction. Set the limit to zero if you want all removals done in a single transaction.

  • -n_—​dry-run_

    • Don’t remove anything, just show what would be done.

  • -v_—​verbose_

    • Write a lot of progress messages.

  • -V_—​version_

    • Print the vacuumlo version and exit.

  • -?_—​help_

    • Show help about vacuumlo command line arguments, and exit.

vacuumlo 还接受以下用于连接参数的命令行参数:

vacuumlo also accepts the following command-line arguments for connection parameters:

  • -h _host—​host=_host

    • Database server’s host.

  • -p _port—​port=_port

    • Database server’s port.

  • -U _username—​username=_username

    • User name to connect as.

  • -w_—​no-password_

    • Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.

  • -W_—​password_

    • Force vacuumlo to prompt for a password before connecting to a database.

    • This option is never essential, since vacuumlo will automatically prompt for a password if the server demands password authentication. However, vacuumlo will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt.

Environment

  • PGHOST_PGPORT_PGUSER

    • Default connection parameters.

此实用程序与大多数其他 PostgreSQL 实用程序一样,还使用 libpq 支持的环境变量(请参阅 Section 34.15 )。

This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15).

环境变量 PG_COLOR 指定是否在诊断消息中使用颜色。可能的值是 alwaysautonever

The environment variable PG_COLOR specifies whether to use color in diagnostic messages. Possible values are always, auto and never.

Notes

vacuumlo 根据以下方法进行工作:首先,vacuumlo 创建一个临时的表,其中包含了选中数据库中的所有大对象中的 OID。然后再扫描数据库中所有为类型 oidlo 的列,并从临时表中移除匹配的条目。(注意:只考虑带有这些名称的类型;特别地,不考虑它们上的域。)临时表中的剩余条目识别出孤立的 LO。它们被移除。

vacuumlo works by the following method: First, vacuumlo builds a temporary table which contains all of the OIDs of the large objects in the selected database. It then scans through all columns in the database that are of type oid or lo, and removes matching entries from the temporary table. (Note: Only types with these names are considered; in particular, domains over them are not considered.) The remaining entries in the temporary table identify orphaned LOs. These are removed.