跳转到主要内容

pg_orphaned

Deal with orphaned files

pg_orphaned : Deal with orphaned files

Overview

ID Extension Package Version Category License Language
5200 pg_orphaned pg_orphaned 1.0 ADMIN PostgreSQL C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r No Yes No Yes yes no

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 1.0 19 18 17 16 15 pg_orphaned -
RPM PIGSTY 1.0 19 18 17 16 15 pg_orphaned_$v -
DEB PIGSTY 1.0 19 18 17 16 15 postgresql-$v-pg-orphaned -
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el8.aarch64 N/A PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el9.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el9.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el10.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el10.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
d12.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
d12.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
d13.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
d13.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u22.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u22.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u24.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u24.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u26.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u26.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
Package Version OS ORG SIZE File URL
pg_orphaned_19 1.0 el9.x86_64 pigsty 39.2 KiB pg_orphaned_19-1.0-2.git20260427.4e23c9cPGSTY.el9.x86_64.rpm
pg_orphaned_19 1.0 el9.aarch64 pigsty 39.3 KiB pg_orphaned_19-1.0-2.git20260427.4e23c9cPGSTY.el9.aarch64.rpm
pg_orphaned_19 1.0 el10.x86_64 pigsty 39.5 KiB pg_orphaned_19-1.0-2.git20260427.4e23c9cPGSTY.el10.x86_64.rpm
pg_orphaned_19 1.0 el10.aarch64 pigsty 39.4 KiB pg_orphaned_19-1.0-2.git20260427.4e23c9cPGSTY.el10.aarch64.rpm
postgresql-19-pg-orphaned 1.0 d12.x86_64 pigsty 29.8 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-orphaned 1.0 d12.aarch64 pigsty 29.5 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-orphaned 1.0 d13.x86_64 pigsty 29.6 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~trixie_amd64.deb
postgresql-19-pg-orphaned 1.0 d13.aarch64 pigsty 29.6 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~trixie_arm64.deb
postgresql-19-pg-orphaned 1.0 u22.x86_64 pigsty 31.6 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~jammy_amd64.deb
postgresql-19-pg-orphaned 1.0 u22.aarch64 pigsty 31.7 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~jammy_arm64.deb
postgresql-19-pg-orphaned 1.0 u24.x86_64 pigsty 30.9 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~noble_amd64.deb
postgresql-19-pg-orphaned 1.0 u24.aarch64 pigsty 31.1 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~noble_arm64.deb
postgresql-19-pg-orphaned 1.0 u26.x86_64 pigsty 30.5 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~resolute_amd64.deb
postgresql-19-pg-orphaned 1.0 u26.aarch64 pigsty 30.5 KiB postgresql-19-pg-orphaned_1.0+git20260427-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_orphaned_18 1.0 el8.x86_64 pigsty 38.6 KiB pg_orphaned_18-1.0-2.git20260427.4e23c9cPGSTY.el8.x86_64.rpm
pg_orphaned_18 1.0 el8.aarch64 pigsty 38.4 KiB pg_orphaned_18-1.0-2.git20260427.4e23c9cPGSTY.el8.aarch64.rpm
pg_orphaned_18 1.0 el9.x86_64 pigsty 39.2 KiB pg_orphaned_18-1.0-2.git20260427.4e23c9cPGSTY.el9.x86_64.rpm
pg_orphaned_18 1.0 el9.aarch64 pigsty 39.3 KiB pg_orphaned_18-1.0-2.git20260427.4e23c9cPGSTY.el9.aarch64.rpm
pg_orphaned_18 1.0 el10.x86_64 pigsty 39.6 KiB pg_orphaned_18-1.0-2.git20260427.4e23c9cPGSTY.el10.x86_64.rpm
pg_orphaned_18 1.0 el10.aarch64 pigsty 39.4 KiB pg_orphaned_18-1.0-2.git20260427.4e23c9cPGSTY.el10.aarch64.rpm
postgresql-18-pg-orphaned 1.0 d12.x86_64 pigsty 29.8 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-orphaned 1.0 d12.aarch64 pigsty 29.5 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-orphaned 1.0 d13.x86_64 pigsty 29.6 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~trixie_amd64.deb
postgresql-18-pg-orphaned 1.0 d13.aarch64 pigsty 29.6 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~trixie_arm64.deb
postgresql-18-pg-orphaned 1.0 u22.x86_64 pigsty 31.5 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~jammy_amd64.deb
postgresql-18-pg-orphaned 1.0 u22.aarch64 pigsty 31.7 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~jammy_arm64.deb
postgresql-18-pg-orphaned 1.0 u24.x86_64 pigsty 30.9 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~noble_amd64.deb
postgresql-18-pg-orphaned 1.0 u24.aarch64 pigsty 31.1 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~noble_arm64.deb
postgresql-18-pg-orphaned 1.0 u26.x86_64 pigsty 30.5 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~resolute_amd64.deb
postgresql-18-pg-orphaned 1.0 u26.aarch64 pigsty 30.6 KiB postgresql-18-pg-orphaned_1.0+git20260427-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_orphaned_17 1.0 el8.x86_64 pigsty 38.5 KiB pg_orphaned_17-1.0-2.git20260427.4e23c9cPGSTY.el8.x86_64.rpm
pg_orphaned_17 1.0 el8.aarch64 pigsty 38.3 KiB pg_orphaned_17-1.0-2.git20260427.4e23c9cPGSTY.el8.aarch64.rpm
pg_orphaned_17 1.0 el9.x86_64 pigsty 39.1 KiB pg_orphaned_17-1.0-2.git20260427.4e23c9cPGSTY.el9.x86_64.rpm
pg_orphaned_17 1.0 el9.aarch64 pigsty 39.3 KiB pg_orphaned_17-1.0-2.git20260427.4e23c9cPGSTY.el9.aarch64.rpm
pg_orphaned_17 1.0 el10.x86_64 pigsty 39.5 KiB pg_orphaned_17-1.0-2.git20260427.4e23c9cPGSTY.el10.x86_64.rpm
pg_orphaned_17 1.0 el10.aarch64 pigsty 39.4 KiB pg_orphaned_17-1.0-2.git20260427.4e23c9cPGSTY.el10.aarch64.rpm
postgresql-17-pg-orphaned 1.0 d12.x86_64 pigsty 29.8 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-orphaned 1.0 d12.aarch64 pigsty 29.5 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-orphaned 1.0 d13.x86_64 pigsty 29.5 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~trixie_amd64.deb
postgresql-17-pg-orphaned 1.0 d13.aarch64 pigsty 29.6 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~trixie_arm64.deb
postgresql-17-pg-orphaned 1.0 u22.x86_64 pigsty 35.5 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~jammy_amd64.deb
postgresql-17-pg-orphaned 1.0 u22.aarch64 pigsty 35.7 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~jammy_arm64.deb
postgresql-17-pg-orphaned 1.0 u24.x86_64 pigsty 30.8 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~noble_amd64.deb
postgresql-17-pg-orphaned 1.0 u24.aarch64 pigsty 31.0 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~noble_arm64.deb
postgresql-17-pg-orphaned 1.0 u26.x86_64 pigsty 30.5 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~resolute_amd64.deb
postgresql-17-pg-orphaned 1.0 u26.aarch64 pigsty 30.5 KiB postgresql-17-pg-orphaned_1.0+git20260427-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_orphaned_16 1.0 el8.x86_64 pigsty 38.6 KiB pg_orphaned_16-1.0-2.git20260427.4e23c9cPGSTY.el8.x86_64.rpm
pg_orphaned_16 1.0 el8.aarch64 pigsty 38.3 KiB pg_orphaned_16-1.0-2.git20260427.4e23c9cPGSTY.el8.aarch64.rpm
pg_orphaned_16 1.0 el9.x86_64 pigsty 39.1 KiB pg_orphaned_16-1.0-2.git20260427.4e23c9cPGSTY.el9.x86_64.rpm
pg_orphaned_16 1.0 el9.aarch64 pigsty 39.2 KiB pg_orphaned_16-1.0-2.git20260427.4e23c9cPGSTY.el9.aarch64.rpm
pg_orphaned_16 1.0 el10.x86_64 pigsty 39.5 KiB pg_orphaned_16-1.0-2.git20260427.4e23c9cPGSTY.el10.x86_64.rpm
pg_orphaned_16 1.0 el10.aarch64 pigsty 39.4 KiB pg_orphaned_16-1.0-2.git20260427.4e23c9cPGSTY.el10.aarch64.rpm
postgresql-16-pg-orphaned 1.0 d12.x86_64 pigsty 29.8 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-orphaned 1.0 d12.aarch64 pigsty 29.5 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-orphaned 1.0 d13.x86_64 pigsty 29.6 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~trixie_amd64.deb
postgresql-16-pg-orphaned 1.0 d13.aarch64 pigsty 29.6 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~trixie_arm64.deb
postgresql-16-pg-orphaned 1.0 u22.x86_64 pigsty 35.1 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~jammy_amd64.deb
postgresql-16-pg-orphaned 1.0 u22.aarch64 pigsty 35.3 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~jammy_arm64.deb
postgresql-16-pg-orphaned 1.0 u24.x86_64 pigsty 30.8 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~noble_amd64.deb
postgresql-16-pg-orphaned 1.0 u24.aarch64 pigsty 31.0 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~noble_arm64.deb
postgresql-16-pg-orphaned 1.0 u26.x86_64 pigsty 30.5 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~resolute_amd64.deb
postgresql-16-pg-orphaned 1.0 u26.aarch64 pigsty 30.5 KiB postgresql-16-pg-orphaned_1.0+git20260427-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_orphaned_15 1.0 el8.x86_64 pigsty 38.5 KiB pg_orphaned_15-1.0-2.git20260427.4e23c9cPGSTY.el8.x86_64.rpm
pg_orphaned_15 1.0 el8.aarch64 pigsty 38.3 KiB pg_orphaned_15-1.0-2.git20260427.4e23c9cPGSTY.el8.aarch64.rpm
pg_orphaned_15 1.0 el9.x86_64 pigsty 39.1 KiB pg_orphaned_15-1.0-2.git20260427.4e23c9cPGSTY.el9.x86_64.rpm
pg_orphaned_15 1.0 el9.aarch64 pigsty 39.2 KiB pg_orphaned_15-1.0-2.git20260427.4e23c9cPGSTY.el9.aarch64.rpm
pg_orphaned_15 1.0 el10.x86_64 pigsty 39.5 KiB pg_orphaned_15-1.0-2.git20260427.4e23c9cPGSTY.el10.x86_64.rpm
pg_orphaned_15 1.0 el10.aarch64 pigsty 39.4 KiB pg_orphaned_15-1.0-2.git20260427.4e23c9cPGSTY.el10.aarch64.rpm
postgresql-15-pg-orphaned 1.0 d12.x86_64 pigsty 29.8 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-orphaned 1.0 d12.aarch64 pigsty 29.5 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-orphaned 1.0 d13.x86_64 pigsty 29.6 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~trixie_amd64.deb
postgresql-15-pg-orphaned 1.0 d13.aarch64 pigsty 29.6 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~trixie_arm64.deb
postgresql-15-pg-orphaned 1.0 u22.x86_64 pigsty 35.0 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~jammy_amd64.deb
postgresql-15-pg-orphaned 1.0 u22.aarch64 pigsty 35.2 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~jammy_arm64.deb
postgresql-15-pg-orphaned 1.0 u24.x86_64 pigsty 30.8 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~noble_amd64.deb
postgresql-15-pg-orphaned 1.0 u24.aarch64 pigsty 31.0 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~noble_arm64.deb
postgresql-15-pg-orphaned 1.0 u26.x86_64 pigsty 30.5 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~resolute_amd64.deb
postgresql-15-pg-orphaned 1.0 u26.aarch64 pigsty 30.5 KiB postgresql-15-pg-orphaned_1.0+git20260427-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_orphaned;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_orphaned;		# install via package name, for the active PG version

pig install pg_orphaned -v 19;   # install for PG 19
pig install pg_orphaned -v 18;   # install for PG 18
pig install pg_orphaned -v 17;   # install for PG 17
pig install pg_orphaned -v 16;   # install for PG 16
pig install pg_orphaned -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_orphaned;

Usage

pg_orphaned: Deal with orphaned files

pg_orphaned provides functions to detect and manage orphaned data files in PostgreSQL. It handles corner cases like in-progress transactions that could cause false positives by using a dirty snapshot.

List Orphaned Files

-- List orphaned files (default: older than 1 day marked as "older")
SELECT * FROM pg_list_orphaned();

-- Custom age threshold
SELECT * FROM pg_list_orphaned('10 seconds');
SELECT * FROM pg_list_orphaned('1 minute');

Returns: dbname, path, name, size, mod_time, relfilenode, reloid, older (boolean).

Move Orphaned Files to Backup

-- Move files older than the threshold to orphaned_backup directory
SELECT pg_move_orphaned('1 minute');

List Moved Files

SELECT * FROM pg_list_orphaned_moved();

Move Files Back (if still orphaned)

SELECT pg_move_back_orphaned();

Remove Moved Files

SELECT pg_remove_moved_orphaned();

Typical Workflow

-- 1. Check for orphaned files
SELECT * FROM pg_list_orphaned('1 minute');

-- 2. Move them to backup (only those older than threshold)
SELECT pg_move_orphaned('1 minute');

-- 3. Verify what was moved
SELECT * FROM pg_list_orphaned_moved();

-- 4. After confirming, remove the backup files
SELECT pg_remove_moved_orphaned();

Note: functions operate on orphaned files for the database you are connected to. Always double-check carefully before moving or removing files.

表格阅读器