ts_fdw
timeseries · Append-only time-series storage through PostgreSQL foreign tables
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102485 | ts_fdw | timeseries | 0.0.2 | FDW | C++ |
PostgreSQL · 18
Usage
Sources:
ts_fdw 0.0.2 exposes an append-only C++ time-series store through PostgreSQL foreign tables. The documented build target is PostgreSQL 18. This is a source-only, experimental store: inserts are not rolled back, and each table must have at most one writing backend.
Create and Query a Table
Install the FDW and its libts_storage library first. A superuser creates the extension, which installs an FDW and an event trigger. The control file is relocatable and does not require shared preload. Use the server and table privileges appropriate to the application.
Tables need a timestamp without time zone column. The first such column supplies time-range pruning and ordering; the example names it tstamp as in the upstream guide. Supported scalar columns are integer, double precision, timestamp, text, varchar and char. Use non-null input; the insert bridge does not pass a separate null bitmap to the storage engine. UPDATE and DELETE are unsupported.
Durability and Visibility
The sync option belongs to the server or foreign table; a table setting overrides the server. auto writes and fsyncs inserted rows at commit. A positive integer such as 60 limits synchronization to once per interval, triggered by a subsequent commit; off disables commit-time synchronization. Both deferred modes can lose committed rows after a crash. These policies do not supply transaction rollback or multi-writer coordination.
Readers in other backends see new rows only after they are written and the reader reopens the file. The backend maintains its own file cache, so ordinary transaction commit alone does not promise immediate cross-session visibility. Timestamp ranges and selected numeric predicates can skip pages; other predicates still filter rows without the same pruning.
Storage and Maintenance
Files use ts_fdw/<database oid>_<table oid>.ts beneath the PostgreSQL data directory. Protect that location and include the external files in a separately verified backup and restore procedure; the FDW data are not ordinary PostgreSQL heap pages.
The versioned installation SQL already creates ts_drop_trigger, which calls ts_handle_drop_foreign_table() on SQL drops. Do not add the second trigger shown in the older usage example. Dropping a foreign table removes its file, but DROP DATABASE does not fire the event trigger and leaves files for manual cleanup after checking their database identity. File format TFILE3 rejects the earlier formats; recreate tables and re-import old data instead of assuming an in-place format upgrade.