Nikolay Samokhvalov: The hidden costs of CREATE TEMP TABLE: catalog bloat and LWLock:SInvalWrite
Nikolay Samokhvalov examined the performance costs of using CREATE TEMP TABLE in PostgreSQL, pointing to system catalog bloat and contention on the LWLock:SInvalWrite lock. In tests on Postgres 18, a common table expression delivered 23 times the transactions per second of creating a temp table in each transaction. With 5,000 idle sessions connected, a workload running temp-table DDL reached only 127 and 249 TPS against a 500 TPS target across two runs.
AI-written summary, checked against the cited sources. How summaries work