Re: Global temporary tables

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Japin Li <japinli(at)hotmail(dot)com>, Kirk Wolak <wolakk(at)gmail(dot)com>
Subject: Re: Global temporary tables
Date: 2026-09-02 08:08:41
Message-ID: CAEZATCUn-uA2tvmHcBxexZkQYdm0AU4VDW8reRzbcGDFsLypAg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 15 Jul 2026 at 08:57, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> I'll put the patch back to WoA, until I've had a chance to look at these issues.
>

It looks like I'm not going to have any time for Postgres work for at
least the first week of this commitfest, and when I do get back to it,
my focus will probably be on v19 open items, so I might just move this
patch to the next commitfest.

I did, however, do some work on it after the last commitfest, so I'm
attaching that, just as a record of where I got to. As far as I can
remember, I fixed all the outstanding issues, and I also added a few
new tests and documentation, and a new patch implementing DISCARD
GLOBAL TEMP.

The biggest change I made was refactoring the pending inserts queue
into a new cache, which eliminated a lot of code duplication. However,
I'm not happy with where that ended up -- in particular, the flushing
code feels like a fragile hack. Having convinced myself that the
contents of pg_temp_class and pg_temp_index have to be kept in memory
for the duration of the session (or at least, beyond a single
transaction, to support things like rollback of sequence
initialization), I'm now inclined to think that it would be better to
just get rid of pg_temp_class and pg_temp_index, and have SQL-callable
functions to allow users to retrieve that data, if they need it. By
contrast, I still think having pg_temp_statistic and
pg_temp_statistic_ext_data is valuable, because (a) they're likely to
contain much more data (e.g., MCV lists), (b) I think they're much
more likely to be queried by users, and (c) having them in their
current form makes the backend code that uses stats for GTTs very
simple.

Regards,
Dean

Attachment Content-Type Size
v10-0001-Save-temporary-table-ON-COMMIT-actions-to-pg_cla.patch text/x-patch 14.0 KB
v10-0002-Basic-support-for-global-temporary-tables.patch text/x-patch 189.8 KB
v10-0003-Add-support-for-indexes-on-global-temporary-tabl.patch text/x-patch 48.9 KB
v10-0004-Add-support-for-global-temporary-sequences.patch text/x-patch 35.3 KB
v10-0005-Allow-catalog-tables-to-be-global-temporary-and-.patch text/x-patch 125.6 KB
v10-0006-Add-relation-statistics-columns-to-pg_temp_class.patch text/x-patch 72.0 KB
v10-0007-Add-relfrozenxid-and-relminmxid-columns-to-pg_te.patch text/x-patch 70.7 KB
v10-0008-Add-pg_temp_statistic-global-temporary-catalog-t.patch text/x-patch 56.7 KB
v10-0009-Add-pg_temp_statistic_ext_data-global-temporary-.patch text/x-patch 56.3 KB
v10-0010-Add-pg_temp_index-global-temporary-catalog-table.patch text/x-patch 59.7 KB
v10-0011-Add-DISCARD-GLOBAL-TEMP.patch text/x-patch 19.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Geier 2026-09-02 08:09:54 Re: Reducing relcache memory usage: deduping index shapes
Previous Message David Geier 2026-09-02 08:06:13 Re: Reducing relcache memory usage: deduping index shapes