Re: Global temporary tables

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Global temporary tables
Date: 2026-07-06 09:43:42
Message-ID: CAEZATCUhknD0kAkXVJeehvP10sEAwV8LCCNecrRvbBLm2vavCQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 5 Jul 2026 at 10:58, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> On Sun, 5 Jul 2026 at 09:17, John Naylor <johncnaylorls(at)gmail(dot)com> wrote:
> >
> > I'm starting to think the queue mechanism needs serious attention, if
> > not a complete re-think.
>
> Yes, you're right. In that example, the pg_temp_class tuple gets lost
> entirely. It really needs the same sort of sub XID tracking as the
> usage/storage code

Attached is v7, doing that.

Locally, I have been stress-testing this using a hacked-together
python script that does random sequences of CREATE, DROP, BEGIN,
SAVEPOINT, RELEASE, ROLLBACK TO, INSERT, SELECT, COMMIT, ROLLBACK, and
TRUNCATE. I'm somewhat disappointed that it didn't pick up the
original problem, so I'll go back and look at it again.

v7 now also includes tempfrozenxid and tempminmxid in the
pg_stat_activity view, allowing those to be monitored.

Regards,
Dean

Attachment Content-Type Size
v7-0001-Save-temporary-table-ON-COMMIT-actions-to-pg_clas.patch text/x-patch 12.8 KB
v7-0002-Basic-support-for-global-temporary-tables.patch text/x-patch 139.1 KB
v7-0003-Support-indexes-on-global-temporary-tables.patch text/x-patch 36.2 KB
v7-0004-Support-global-temporary-sequences.patch text/x-patch 17.6 KB
v7-0005-Support-global-temporary-catalog-tables-and-add-p.patch text/x-patch 90.1 KB
v7-0006-Add-relation-statistics-columns-to-pg_temp_class.patch text/x-patch 52.9 KB
v7-0007-Add-relfrozenxid-and-relminmxid-columns-to-pg_tem.patch text/x-patch 55.9 KB
v7-0008-Add-pg_temp_statistic-global-temporary-catalog-ta.patch text/x-patch 32.7 KB
v7-0009-Add-pg_temp_statistic_ext_data-global-temporary-c.patch text/x-patch 36.7 KB
v7-0010-Add-pg_temp_index-global-temporary-catalog-table.patch text/x-patch 71.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-07-06 09:57:37 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Amit Kapila 2026-07-06 09:37:24 Re: Re-read subscription state after lock in AlterSubscription