Re: Why lots of temp schemas are being created

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Walter Coole <WCoole(at)aperiogroup(dot)com>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>, Anirban Pal <anirban(dot)pal(at)newgen(dot)co(dot)in>, pgsql-novice(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: Why lots of temp schemas are being created
Date: 2010-02-04 00:40:36
Message-ID: 20100204004036.GJ3905@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

Walter Coole escribió:

> This didn't seem quite thorough enough, as I found that when a process
> would end (MAX(backendid) went down), the corresponding pg*_temp_
> schema would not go away. I think these were schemas created by a
> previous backend, so would not be cleaned up by a backend that hadn't
> created it.

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.

> I guess these schemas are fairly harmless, but it seems kind of messy
> to have them sloshing around. It seems like when a new backend starts
> up, it would be better to clear out the temp schemas to avoid
> accidentally using stale data, but this doesn't seem to be happening.
> One could also imagine hooking a cleanup in the database startup, but
> I don't see that either.

IIRC the time when the previous temp schema is destroyed is when the
first temp table is created in the new backend.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Wang, Mary Y 2010-02-04 00:57:09 Need to Remove Constraint, but Don't Know How - Previous attempts failed
Previous Message Walter Coole 2010-02-04 00:34:13 Re: Why lots of temp schemas are being created

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2010-02-04 02:35:50 Re: Why lots of temp schemas are being created
Previous Message Walter Coole 2010-02-04 00:34:13 Re: Why lots of temp schemas are being created