Alvaro Herrera <alvherre@commandprompt.com> writes:
> Temp schemas are not destroyed on session shutdown; they are rather
> destroyed the next time the backend ID is reused. Normally that's not a
> problem, because a backend ID is reused pretty soon. It's only a
> problem when you use so high a backend ID due to high load, that a very
> long time passes before it's reused. Those temp tables linger and can
> cause Xid wraparound problems.
Not correct --- ordinarily temp tables are removed at backend shutdown.
The only time that wouldn't happen is in event of a backend crash. In
which case cleanup would happen at next use, as you describe.
The schemas are indeed left around, but they're empty in the normal case.
regards, tom lane