Thread: sharing temporary tables

sharing temporary tables

From
"Marcus Andree S. Magalhaes"
Date:
Hi guys,

After some tests, I have a couple questions regarding temporary
tables in Postgres... Hope someone more knowledgeable can
drop me a few lines and put some light into my own darkness. ;)

Do temp tables reside on disk or in RAM? Can different connections
access (share) data located in a temporary table created by a
previous connection/process? How?

Any help is grateful.

Thanks.

Re: sharing temporary tables

From
Tom Lane
Date:
"Marcus Andree S. Magalhaes" <marcus.magalhaes@vlinfo.com.br> writes:
> Do temp tables reside on disk or in RAM?

They are files, just like every other table in Postgres.  To the extent
that you have RAM to spare, the kernel will keep the contents of active
files in memory, so it's quite possible for a table to behave as though
it's in RAM (at least in terms of read speed).

> Can different connections
> access (share) data located in a temporary table created by a
> previous connection/process?

No.  Temp tables are local to a single session.  There are a number of
performance optimizations associated with that, which boil down to the
fact that other sessions couldn't see a consistent state of the data in
a temp table even if they looked (which they won't).

            regards, tom lane