pgtt_rsl
pgtt-rsl · Provide Oracle/DB2-style global temporary tables using unlogged tables, row-level security, views, and a cleanup worker
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100692 | pgtt_rsl | pgtt-rsl | 2.0.0 | SIM | PostgreSQL | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
- Official README
- Version 2.0.0 extension SQL
- Parser-hook implementation
- Background-worker implementation
pgtt_rsl implements Oracle/DB2-style global temporary tables as permanent unlogged backing tables, row-level-security policies, and security-barrier views. Table definitions persist and may live in ordinary schemas, while rows are isolated by session or transaction. Its main tradeoff is avoiding repeated catalog churn at lower data-path performance than native temporary tables.
Core Workflow
Preload both libraries and restart PostgreSQL before creating or using the extension:
The explicit helper is useful when generated SQL cannot use the intercepted syntax:
false gives transaction-scoped rows (ON COMMIT DELETE ROWS behavior); true preserves rows for the session.
Object Index
pgtt_schema.pgtt_create_table(name, definition, preserved DEFAULT false, schema DEFAULT 'public')creates a global temporary table facade.pgtt_schema.pgtt_drop_table(name, schema DEFAULT 'public')removes it.lsidandget_session_id()identify the owning session internally.pgtt_bgw.naptime,pgtt_bgw.analyze, andpgtt_bgw.chunk_sizecontrol obsolete-row cleanup.pgtt_schema.pgtt_maintenance(...)is internal and must be called only by the background worker.
Operational Notes
Version 2.0.0 is non-relocatable and requires PostgreSQL restart-level preloading. The background worker scans every database containing the extension and removes rows for ended sessions or transactions. Monitor worker health, dead tuples, autovacuum, and cleanup lag; row-level security, views, indexes, and deletion make large workloads slower than native temporary tables.
Backing tables are UNLOGGED: their contents are not crash-durable and are not suitable for replicated or recoverable state. The creation helper grants DML on backing tables to PUBLIC and relies on forced RLS plus the facade view for isolation; review grants and never access pgtt_schema.pgtt_* backing tables directly. Test session disconnect, transaction rollback, restart, failover, pooler behavior, and extension upgrades before migration workloads.