Re: TRUNCATE memory leak with temporary tables?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vijaykumar Jain <vijaykumarjain(dot)github(at)gmail(dot)com>
Cc: Nick Muerdter <stuff(at)nickm(dot)org>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: TRUNCATE memory leak with temporary tables?
Date: 2021-05-28 13:22:13
Message-ID: 1976587.1622208133@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vijaykumar Jain <vijaykumarjain(dot)github(at)gmail(dot)com> writes:
> I too see growth when text type is used, but not when int or even fixed
> size char(10) is used.
> ...
> but then i still do not understand how a col type *text* which is dynamic
> results in mem growth (coz there are no rows inserted, i understand for
> long strings db does work to compress, move them to toast tables etc) but
> these are empty rows.

The text column would cause the table to have an associated toast table [1],
which in turn would have an index. Both of those would be reallocated as
new files on-disk during TRUNCATE, just like the table proper.

A plausible theory here is that TRUNCATE leaks some storage associated
with an index's relcache entry, but not any for a plain table.

regards, tom lane

[1] https://www.postgresql.org/docs/current/storage-toast.html

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vijaykumar Jain 2021-05-28 13:36:04 Re: TRUNCATE memory leak with temporary tables?
Previous Message Alban Hertroys 2021-05-28 13:21:51 WARNING: oldest xmin is far in the past