Re: Global temporary tables

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Kirk Wolak <wolakk(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Global temporary tables
Date: 2026-06-26 19:37:07
Message-ID: CAEZATCUqP6iu0QcuZ+718iz630hsfQLdqZdhW=B3+vz6iOuq9Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 26 Jun 2026 at 04:52, Kirk Wolak <wolakk(at)gmail(dot)com> wrote:
>
> + 1 for the idea. I will try to review this over the weekend. We could use this.

Thanks. Any reviews will be very helpful.

In the meantime, comparing the 2 patchsets, I realised that there was
a bug in mine -- ON COMMIT DELETE ROWS wasn't working properly in all
cases.

More specifically, it was working for a global temporary table created
in the current session, but disconnecting and then reconnecting caused
it to stop working, because I hadn't realised that the ON COMMIT
action of a temporary table is not saved to the database.

Not saving the ON COMMIT action to the database kind-of made sense for
old-style temporary tables, since they disappear at the end of the
session. However, even then, it can be useful to have it in the
database so that psql's \d meta-command can display it, and of course,
for global temporary tables, saving it to the database is essential so
that new sessions can pick it up.

So here's a new patchset, where 0001 is new -- it saves a temporary
table's ON COMMIT action to pg_class, and updates psql's \d to display
it. I think we could commit that independently of the global temporary
tables feature, since it seems somewhat useful by itself.

(I chose to do it as a new column "reloncommit" in pg_class, rather
than as a reloption, because a reloption didn't seem quite right for
this, but that's a matter of opinion.)

Regards,
Dean

Attachment Content-Type Size
v5-0001-Save-temporary-table-ON-COMMIT-actions-to-pg_clas.patch text/x-patch 12.9 KB
v5-0002-Basic-support-for-global-temporary-tables.patch text/x-patch 138.5 KB
v5-0003-Support-indexes-on-global-temporary-tables.patch text/x-patch 36.2 KB
v5-0004-Support-global-temporary-sequences.patch text/x-patch 17.7 KB
v5-0005-Support-global-temporary-catalog-tables-and-add-p.patch text/x-patch 86.3 KB
v5-0006-Add-relation-statistics-columns-to-pg_temp_class.patch text/x-patch 42.4 KB
v5-0007-Add-relfrozenxid-and-relminmxid-columns-to-pg_tem.patch text/x-patch 33.1 KB
v5-0008-Add-pg_temp_statistic-global-temporary-catalog-ta.patch text/x-patch 33.2 KB
v5-0009-Add-pg_temp_statistic_ext_data-global-temporary-c.patch text/x-patch 36.7 KB
v5-0010-Add-pg_temp_index-global-temporary-catalog-table.patch text/x-patch 60.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2026-06-26 19:42:14 Re: Bypassing cursors in postgres_fdw to enable parallel plans
Previous Message Florents Tselai 2026-06-26 18:28:42 Re: More jsonpath methods: translate, split, join