hash_fdw
hash_fdw · Shared-memory hash-table foreign data wrapper for storing and querying rows by a configured key.
Overview
Usage
Sources:
- Official README
- Official extension control file
- Official extension SQL
- Official shared-memory implementation
- Official FDW implementation
hash_fdw 1.0 is a 2016 in-memory FDW experiment that stores foreign-table rows in PostgreSQL shared-memory hash tables. It can scan and insert keyed rows without an external server, but it is not durable storage and does not provide normal PostgreSQL table semantics.
Preload and Basic Workflow
The library allocates shared memory in _PG_init, so add it to shared_preload_libraries, size the store, and restart before creating the extension.
key names the foreign-table column converted to the hash key. hash_idx selects one shared hash table; the public helper functions hard-limit usable indexes to 1–8 in this source.
Installed Surface
hash_fdw_handler()andhash_fdw_validator(text[], oid)implement the FDW.- Foreign scans iterate an entire selected hash table; inserts add or replace entries addressed by the configured key.
hash_insert_hashdata(int, cstring, record)andhash_get_hashdata(int, cstring)expose low-level C-backed helpers, but theirrecordcontract is awkward and tied to internal tuple representation.- GUCs include
hash.shmem_sizeandhash_fdw.hash_idx; shared-memory layout is fixed at server startup, so do not change sizing/count assumptions dynamically.
Data and Safety Boundaries
Rows are not written to heap storage, WAL, or an external service. A restart, crash, failover, or binary incompatibility can lose or invalidate all entries. The code does not implement MVCC visibility, transactional rollback, constraints, indexes, backup, replication, or concurrency guarantees equivalent to a regular table.
The shared hash tables are cluster-wide, while foreign-table definitions are database-local. Reusing the same hash_idx and key across databases or incompatible row layouts can collide or interpret tuple bytes with the wrong descriptor. The delete callback is incomplete and no update path is registered. Use unique isolated indexes, disposable data, and a dedicated test instance only.
The README states it was built for PostgreSQL 9.5.3. Server shared-memory and FDW APIs have changed substantially; do not load this unreviewed binary on a modern server.