The hidden costs of CREATE TEMP TABLE: catalog bloat and LWLock:SInvalWrite | PostgresAI
Creating temporary tables in hot PostgreSQL code causes catalog bloat, file creation overhead, and shared invalidation queue contention. Benchmarks show that a CTE or keeping a temp table per session with truncation performs significantly better than creating and dropping a temp table in every transaction. Open article →