Skip to content- Sources: primary
- Summary: Nikolay Samokhvalov's benchmark on Postgres 18.6 with 16 vCPU shows a temp table per transaction at 3783 TPS, a session-kept temp table with ON COMMIT DELETE ROWS at 17866, and a CTE at 86997. Creating and dropping a two-column temp table inserts and deletes 31 catalog rows, unlinks three files, and sends 132 messages through the 4096-slot shared invalidation queue. With 5000 idle sessions, writers spent 91% of active time on LWLock:SInvalWrite and backends hit 457 full cache resets per second.
- Why it matters: Temp tables in hot paths cost catalog bloat always and throughput collapse under many idle connections, so move them out and pool connections.
- Background: Every Postgres backend caches catalog rows and relation descriptors, and DDL tells other backends to drop stale entries through one shared invalidation queue per instance. A slot is reused only after every backend has read it, so idle backends hold the tail and get signalled to catch up or are reset. Temp tables are DDL, so they pay this cost even though their data is session-local.