Re: BUG #16373: Behavior of Temporary table creation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hritik Gupta <hritik122(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16373: Behavior of Temporary table creation
Date: 2020-04-17 18:05:36
Message-ID: 18686.1587146736@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hritik Gupta <hritik122(at)gmail(dot)com> writes:
> Q=> So does that mean postgres does not have *only* “in memory” temporary
> tables in any case?
> At best, what it is going to do is to cache the temp. table pages in the
> temp buffer, but the blocks are still there on the storage, its just cached
> in memory for the time being, no matter how small the temporary table is.
> is it correct?

No. We *reserve space* on disk, typically by writing zeroes. But actual
data would only get spilled there if we run out of temp buffer space.
It's entirely possible for a temp table's data to stay in memory for
its whole existence.

For regular tables, there are effects such as checkpoints that would
cause data to get written out from shared buffers periodically, even
if there's plenty of buffer space. That doesn't apply to temp tables.

The reason for reserving space is to try to avoid having to deal with
ENOSPC failures during buffer spills. On newer filesystems that
can happen anyway, of course, but it's still useful on non-COW
filesystems.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-04-17 18:33:25 BUG #16375: Error in pgAdmin 4.20 when trying to script a function to Query Tool
Previous Message Hritik Gupta 2020-04-17 17:44:27 Re: BUG #16373: Behavior of Temporary table creation