redis_fdw_rs
redis_fdw_rs · This extension allows PostgreSQL to directly query and manipulate Redis data as if it were regular PostgreSQL tables.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101221 | redis_fdw_rs | redis_fdw_rs | 0.6.0 | FDW | Apache-2.0 | Rust |
PostgreSQL · 14, 15, 16, 17, 18
Usage
Sources:
- Official README
- FDW setup example
- Option and credential loading
- FDW option validator
- Connection-pool implementation
- Extension control file
redis_fdw_rs 0.6.0 is a Rust foreign data wrapper for reading and modifying Redis strings, hashes, lists, sets, sorted sets, and streams through PostgreSQL foreign tables. It supports PostgreSQL 14 through 18, Redis Cluster, TLS, connection pooling, predicate pushdown, batch inserts, TTLs, schema import, and selected join pushdown.
Create the Wrapper and a Table
Installing the extension creates the handler and validator functions, but not a named foreign-data wrapper or server. Create those explicitly, then map each table to one Redis key or key pattern:
The hash predicate can be pushed to HGET. Use EXPLAIN (VERBOSE) to confirm pushdown instead of assuming it. Column shapes are position-based: string has one value column, hash has field/value, list has element or index/element, set has member, sorted set has member/score, and stream has an ID plus field/value columns.
Redis Types and Options
table_type: one ofstring,hash,list,set,zset, orstream; streams are append-only for updates.table_key_prefix: an exact key or a glob pattern. Pattern tables add a leading key column and may require a RedisSCAN.database: logical Redis database 0 through 15; Redis Cluster effectively uses database 0.ttl: default expiration in seconds. An optionalttl bigintcolumn supplies a per-row value;-1persists a key.batch_sizeandjoin_batch_size: bound pipelined insert and parameterized-join batches.IMPORT FOREIGN SCHEMA: samples up to 10,000 Redis keys, groups prefixes, and generates foreign-table definitions.
The FDW implements SELECT, INSERT, DELETE, and most UPDATE operations for all six types, except stream UPDATE. Same-server single-column equality joins have limited pushdown; multi-key patterns and streams have additional restrictions. Check the official matrix for the exact operation before designing a write path.
TLS, Credentials, and Pooling
Use rediss:// in host_port to require TLS certificate verification. The documented #insecure suffix disables verification and is appropriate only for isolated testing.
At the reviewed commit, the runtime combines wrapper, server, and table options but has PostgreSQL user-mapping option loading commented out. Consequently username and password must be server options to take effect, where privileged catalog readers and DDL viewers may see them. Restrict ownership and visibility, prefer a narrowly scoped Redis ACL identity, and test a credential rotation procedure. The per-backend pool cache key distinguishes the username or the presence of a password but does not include the password value, so a changed secret can reuse an old pool until connections or backends are recycled.
Consistency and Destructive Operations
Redis commands take effect remotely and are not rolled back as part of a PostgreSQL transaction. Design writes to be idempotent and expect partial effects after statement errors, client cancellation, failover, or retries.
TRUNCATE unlinks the exact Redis key. On a pattern table it performs SCAN plus batched UNLINK and can remove every matching key; multi-key TRUNCATE is unsupported in cluster mode. Review table_key_prefix and Redis ACL scope before granting truncation. Full pattern scans, schema import, and pushed-down same-server joins can consume substantial Redis, network, or PostgreSQL memory, so test production key cardinalities and enforce query timeouts.