fio

pg_fio : PostgreSQL File I/O Functions

Overview

ID Extension Package Version Category License Language
5230
fio
pg_fio
1.0
ADMIN
BSD 3-Clause
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
pgfincore
adminpack
file_fdw
pageinspect
pgstattuple
pg_repack
pg_rewrite
pg_squeeze

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.0
18
17
16
15
14
pg_fio -
RPM
PIGSTY
1.0
18
17
16
15
14
pg_fio_$v -
DEB
PIGSTY
1.0
18
17
16
15
14
postgresql-$v-pg-fio -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el8.aarch64
PIGSTY 1.0
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
Package Version OS ORG SIZE File URL
pg_fio_18 1.0 el8.x86_64 pigsty 15.1 KiB pg_fio_18-1.0-1PIGSTY.el8.x86_64.rpm
pg_fio_18 1.0 el8.aarch64 pigsty 15.2 KiB pg_fio_18-1.0-1PIGSTY.el8.aarch64.rpm
pg_fio_18 1.0 el9.x86_64 pigsty 14.5 KiB pg_fio_18-1.0-1PIGSTY.el9.x86_64.rpm
pg_fio_18 1.0 el9.aarch64 pigsty 14.2 KiB pg_fio_18-1.0-1PIGSTY.el9.aarch64.rpm
pg_fio_18 1.0 el10.x86_64 pigsty 14.6 KiB pg_fio_18-1.0-1PIGSTY.el10.x86_64.rpm
pg_fio_18 1.0 el10.aarch64 pigsty 14.4 KiB pg_fio_18-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-fio 1.0 d12.x86_64 pigsty 22.9 KiB postgresql-18-pg-fio_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-fio 1.0 d12.aarch64 pigsty 22.8 KiB postgresql-18-pg-fio_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-fio 1.0 d13.x86_64 pigsty 23.0 KiB postgresql-18-pg-fio_1.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-fio 1.0 d13.aarch64 pigsty 22.9 KiB postgresql-18-pg-fio_1.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-fio 1.0 u22.x86_64 pigsty 24.6 KiB postgresql-18-pg-fio_1.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-fio 1.0 u22.aarch64 pigsty 24.1 KiB postgresql-18-pg-fio_1.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-fio 1.0 u24.x86_64 pigsty 24.0 KiB postgresql-18-pg-fio_1.0-1PIGSTY~noble_amd64.deb
postgresql-18-pg-fio 1.0 u24.aarch64 pigsty 23.9 KiB postgresql-18-pg-fio_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_fio_17 1.0 el8.x86_64 pigsty 15.1 KiB pg_fio_17-1.0-1PIGSTY.el8.x86_64.rpm
pg_fio_17 1.0 el8.aarch64 pigsty 15.2 KiB pg_fio_17-1.0-1PIGSTY.el8.aarch64.rpm
pg_fio_17 1.0 el9.x86_64 pigsty 14.6 KiB pg_fio_17-1.0-1PIGSTY.el9.x86_64.rpm
pg_fio_17 1.0 el9.aarch64 pigsty 14.2 KiB pg_fio_17-1.0-1PIGSTY.el9.aarch64.rpm
pg_fio_17 1.0 el10.x86_64 pigsty 14.5 KiB pg_fio_17-1.0-1PIGSTY.el10.x86_64.rpm
pg_fio_17 1.0 el10.aarch64 pigsty 14.5 KiB pg_fio_17-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-fio 1.0 d12.x86_64 pigsty 23.0 KiB postgresql-17-pg-fio_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-pg-fio 1.0 d12.aarch64 pigsty 22.9 KiB postgresql-17-pg-fio_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-pg-fio 1.0 d13.x86_64 pigsty 22.9 KiB postgresql-17-pg-fio_1.0-1PIGSTY~trixie_amd64.deb
postgresql-17-pg-fio 1.0 d13.aarch64 pigsty 22.9 KiB postgresql-17-pg-fio_1.0-1PIGSTY~trixie_arm64.deb
postgresql-17-pg-fio 1.0 u22.x86_64 pigsty 28.1 KiB postgresql-17-pg-fio_1.0-1PIGSTY~jammy_amd64.deb
postgresql-17-pg-fio 1.0 u22.aarch64 pigsty 27.7 KiB postgresql-17-pg-fio_1.0-1PIGSTY~jammy_arm64.deb
postgresql-17-pg-fio 1.0 u24.x86_64 pigsty 24.1 KiB postgresql-17-pg-fio_1.0-1PIGSTY~noble_amd64.deb
postgresql-17-pg-fio 1.0 u24.aarch64 pigsty 23.9 KiB postgresql-17-pg-fio_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_fio_16 1.0 el8.x86_64 pigsty 15.1 KiB pg_fio_16-1.0-1PIGSTY.el8.x86_64.rpm
pg_fio_16 1.0 el8.aarch64 pigsty 15.2 KiB pg_fio_16-1.0-1PIGSTY.el8.aarch64.rpm
pg_fio_16 1.0 el9.x86_64 pigsty 14.6 KiB pg_fio_16-1.0-1PIGSTY.el9.x86_64.rpm
pg_fio_16 1.0 el9.aarch64 pigsty 14.2 KiB pg_fio_16-1.0-1PIGSTY.el9.aarch64.rpm
pg_fio_16 1.0 el10.x86_64 pigsty 14.5 KiB pg_fio_16-1.0-1PIGSTY.el10.x86_64.rpm
pg_fio_16 1.0 el10.aarch64 pigsty 14.5 KiB pg_fio_16-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-fio 1.0 d12.x86_64 pigsty 22.9 KiB postgresql-16-pg-fio_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-pg-fio 1.0 d12.aarch64 pigsty 22.9 KiB postgresql-16-pg-fio_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-pg-fio 1.0 d13.x86_64 pigsty 23.0 KiB postgresql-16-pg-fio_1.0-1PIGSTY~trixie_amd64.deb
postgresql-16-pg-fio 1.0 d13.aarch64 pigsty 22.9 KiB postgresql-16-pg-fio_1.0-1PIGSTY~trixie_arm64.deb
postgresql-16-pg-fio 1.0 u22.x86_64 pigsty 28.1 KiB postgresql-16-pg-fio_1.0-1PIGSTY~jammy_amd64.deb
postgresql-16-pg-fio 1.0 u22.aarch64 pigsty 27.6 KiB postgresql-16-pg-fio_1.0-1PIGSTY~jammy_arm64.deb
postgresql-16-pg-fio 1.0 u24.x86_64 pigsty 24.0 KiB postgresql-16-pg-fio_1.0-1PIGSTY~noble_amd64.deb
postgresql-16-pg-fio 1.0 u24.aarch64 pigsty 23.9 KiB postgresql-16-pg-fio_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_fio_15 1.0 el8.x86_64 pigsty 15.1 KiB pg_fio_15-1.0-1PIGSTY.el8.x86_64.rpm
pg_fio_15 1.0 el8.aarch64 pigsty 15.3 KiB pg_fio_15-1.0-1PIGSTY.el8.aarch64.rpm
pg_fio_15 1.0 el9.x86_64 pigsty 14.7 KiB pg_fio_15-1.0-1PIGSTY.el9.x86_64.rpm
pg_fio_15 1.0 el9.aarch64 pigsty 14.3 KiB pg_fio_15-1.0-1PIGSTY.el9.aarch64.rpm
pg_fio_15 1.0 el10.x86_64 pigsty 14.6 KiB pg_fio_15-1.0-1PIGSTY.el10.x86_64.rpm
pg_fio_15 1.0 el10.aarch64 pigsty 14.6 KiB pg_fio_15-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-fio 1.0 d12.x86_64 pigsty 23.0 KiB postgresql-15-pg-fio_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-pg-fio 1.0 d12.aarch64 pigsty 22.9 KiB postgresql-15-pg-fio_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-pg-fio 1.0 d13.x86_64 pigsty 23.0 KiB postgresql-15-pg-fio_1.0-1PIGSTY~trixie_amd64.deb
postgresql-15-pg-fio 1.0 d13.aarch64 pigsty 23.0 KiB postgresql-15-pg-fio_1.0-1PIGSTY~trixie_arm64.deb
postgresql-15-pg-fio 1.0 u22.x86_64 pigsty 28.2 KiB postgresql-15-pg-fio_1.0-1PIGSTY~jammy_amd64.deb
postgresql-15-pg-fio 1.0 u22.aarch64 pigsty 27.8 KiB postgresql-15-pg-fio_1.0-1PIGSTY~jammy_arm64.deb
postgresql-15-pg-fio 1.0 u24.x86_64 pigsty 24.1 KiB postgresql-15-pg-fio_1.0-1PIGSTY~noble_amd64.deb
postgresql-15-pg-fio 1.0 u24.aarch64 pigsty 24.0 KiB postgresql-15-pg-fio_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_fio_14 1.0 el8.x86_64 pigsty 15.1 KiB pg_fio_14-1.0-1PIGSTY.el8.x86_64.rpm
pg_fio_14 1.0 el8.aarch64 pigsty 15.3 KiB pg_fio_14-1.0-1PIGSTY.el8.aarch64.rpm
pg_fio_14 1.0 el9.x86_64 pigsty 14.7 KiB pg_fio_14-1.0-1PIGSTY.el9.x86_64.rpm
pg_fio_14 1.0 el9.aarch64 pigsty 14.3 KiB pg_fio_14-1.0-1PIGSTY.el9.aarch64.rpm
pg_fio_14 1.0 el10.x86_64 pigsty 14.6 KiB pg_fio_14-1.0-1PIGSTY.el10.x86_64.rpm
pg_fio_14 1.0 el10.aarch64 pigsty 14.6 KiB pg_fio_14-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-fio 1.0 d12.x86_64 pigsty 23.0 KiB postgresql-14-pg-fio_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-pg-fio 1.0 d12.aarch64 pigsty 22.8 KiB postgresql-14-pg-fio_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-pg-fio 1.0 d13.x86_64 pigsty 23.0 KiB postgresql-14-pg-fio_1.0-1PIGSTY~trixie_amd64.deb
postgresql-14-pg-fio 1.0 d13.aarch64 pigsty 22.9 KiB postgresql-14-pg-fio_1.0-1PIGSTY~trixie_arm64.deb
postgresql-14-pg-fio 1.0 u22.x86_64 pigsty 28.1 KiB postgresql-14-pg-fio_1.0-1PIGSTY~jammy_amd64.deb
postgresql-14-pg-fio 1.0 u22.aarch64 pigsty 27.7 KiB postgresql-14-pg-fio_1.0-1PIGSTY~jammy_arm64.deb
postgresql-14-pg-fio 1.0 u24.x86_64 pigsty 24.1 KiB postgresql-14-pg-fio_1.0-1PIGSTY~noble_amd64.deb
postgresql-14-pg-fio 1.0 u24.aarch64 pigsty 24.0 KiB postgresql-14-pg-fio_1.0-1PIGSTY~noble_arm64.deb

Source

pig build pkg pg_fio;		# 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_fio;		# install via package name, for the active PG version
pig install fio;		# install by extension name, for the current active PG version

pig install fio -v 18;   # install for PG 18
pig install fio -v 17;   # install for PG 17
pig install fio -v 16;   # install for PG 16
pig install fio -v 15;   # install for PG 15
pig install fio -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION fio;

Usage

fio: PostgreSQL File I/O Functions

The fio extension provides file system I/O functions accessible from SQL, enabling reading, writing, and managing files and directories directly from PostgreSQL.

File Operations

-- Read file contents (returns bytea)
SELECT fio_readfile('/etc/hostname');

-- Write content to file
SELECT fio_writefile('/tmp/output.txt', 'Hello World'::bytea);

-- Write with auto-create directory and overwrite
SELECT fio_writefile('/tmp/newdir/output.txt', 'data'::bytea, true, true);

-- Remove a file
SELECT fio_removefile('/tmp/output.txt');

-- Rename / move a file
SELECT fio_renamefile('/tmp/old.txt', '/tmp/new.txt');

Directory Operations

-- List directory contents
SELECT fio_readdir('/usr/', '*');

-- List with pattern filter
SELECT fio_readdir('/var/log/', '*.log');

-- Create a directory with permissions
SELECT fio_mkdir('/tmp/mydir', '0755');

-- Create nested directories recursively
SELECT fio_mkdir('/tmp/a/b/c', '0755', true);

-- Change file/directory permissions
SELECT fio_chmod('/tmp/mydir', '0700');

Function Reference

Function Description
fio_readfile(path) Read file contents as bytea
fio_writefile(path, content, mkdir, overwrite) Write bytea content to file
fio_removefile(path) Delete a file
fio_renamefile(old, new) Rename or move a file
fio_readdir(path, pattern) List directory entries matching pattern
fio_mkdir(path, mode, recursive) Create directory with permissions
fio_chmod(path, mode) Change file/directory permissions
Last updated on