redis_fdw

Foreign data wrapper for querying a Redis server

Overview

PackageVersionCategoryLicenseLanguage
redis_fdw1.0FDWPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
8710redis_fdwNoYesNoYesNoYes-
Relatedmongo_fdw redis kafka_fdw wrappers multicorn spat pgmemcache odbc_fdw

multiple branch for different pg major versions

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.01817161514redis_fdw-
RPMPIGSTY1.01817161514redis_fdw_$v-
DEBPIGSTY1.01817161514postgresql-$v-redis-fdw-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
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

Build

You can build the RPM / DEB packages for redis_fdw using pig build:

pig build pkg redis_fdw         # build RPM / DEB packages

Install

You can install redis_fdw directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install redis_fdw;          # Install for current active PG version
pig ext install -y redis_fdw -v 18  # PG 18
pig ext install -y redis_fdw -v 17  # PG 17
pig ext install -y redis_fdw -v 16  # PG 16
pig ext install -y redis_fdw -v 15  # PG 15
pig ext install -y redis_fdw -v 14  # PG 14
dnf install -y redis_fdw_18       # PG 18
dnf install -y redis_fdw_17       # PG 17
dnf install -y redis_fdw_16       # PG 16
dnf install -y redis_fdw_15       # PG 15
dnf install -y redis_fdw_14       # PG 14
apt install -y postgresql-18-redis-fdw   # PG 18
apt install -y postgresql-17-redis-fdw   # PG 17
apt install -y postgresql-16-redis-fdw   # PG 16
apt install -y postgresql-15-redis-fdw   # PG 15
apt install -y postgresql-14-redis-fdw   # PG 14

Create Extension:

CREATE EXTENSION redis_fdw;

Usage

redis_fdw: Foreign data wrapper for querying a Redis server

Create Server

CREATE EXTENSION redis_fdw;

CREATE SERVER redis_server FOREIGN DATA WRAPPER redis_fdw
  OPTIONS (address '127.0.0.1', port '6379');

Server Options: address (default 127.0.0.1), port (default 6379).

Create User Mapping

CREATE USER MAPPING FOR pguser SERVER redis_server
  OPTIONS (password 'secret');

Scalar Key-Value Pairs

CREATE FOREIGN TABLE redis_db0 (
  key text,
  val text
)
SERVER redis_server
OPTIONS (database '0');

SELECT * FROM redis_db0;

Hash Tables (with Key Prefix)

CREATE FOREIGN TABLE redis_hash (
  key text,
  val text[]
)
SERVER redis_server
OPTIONS (database '0', tabletype 'hash', tablekeyprefix 'mytable:');

INSERT INTO redis_hash VALUES ('mytable:r1', '{prop1,val1,prop2,val2}');
UPDATE redis_hash SET val = '{prop3,val3}' WHERE key = 'mytable:r1';
DELETE FROM redis_hash WHERE key = 'mytable:r1';
SELECT * FROM redis_hash;

Hash Tables (Singleton Key)

CREATE FOREIGN TABLE redis_singleton (
  key text,
  val text
)
SERVER redis_server
OPTIONS (database '0', tabletype 'hash', singleton_key 'myhash');

INSERT INTO redis_singleton VALUES ('field1', 'value1');
UPDATE redis_singleton SET val = 'newvalue' WHERE key = 'field1';
DELETE FROM redis_singleton WHERE key = 'field1';

Table Options

OptionDescription
databaseRedis database number (default 0)
tabletypehash, list, set, or zset (omit for scalar key-value)
tablekeyprefixFilter items by key prefix
tablekeysetFetch keys from a specific Redis set
singleton_keyAccess all values from a single Redis key

Use only one of tablekeyset or tablekeyprefix. Do not combine them with singleton_key.

Hash values are returned as alternating key-value pairs in a text[] array. Lists, sets, and sorted sets also return values as arrays.


Last Modified 2026-03-12: add pg extension catalog (95749bf)