Re: Implementation of global temporary tables?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Zhaomo Yang <zhy001(at)cs(dot)ucsd(dot)edu>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: Implementation of global temporary tables?
Date: 2015-07-15 13:30:06
Message-ID: CAFj8pRD21Q=Yeakh_tHZeJDEA3KaFyNWakDRkp=Px_E3Jaab9Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-07-15 15:21 GMT+02:00 Zhaomo Yang <zhy001(at)cs(dot)ucsd(dot)edu>:

> > Sounds fine in general. I'm a bit curious to know what are the locking
> implications of > vivifying the table on access.
>
> The locking implications depend on how we interpret the existing commands
> in the context of global temp tables and I think we should discuss and
> agree on the behaviors of the commands with global temp tables, but I think
> in general we can follow these rules:
>
> If the command executes on the global temp table's metadata, for example
> an ALTER TABLE command, then we lock the global copy at the same level as
> we do a regular table.
>

there is other question - what is effect of ALTER TABLE of global temp
table on instances of this table in active sessions?

>
> If the command executes on the global temp table's data (which is actually
> stored in the session copy), for example an DML command, then the global
> copy is locked at the AccessShareLock level to prevent concurrent
> modifications to the global temp table's definition from other sessions.
>
> Thanks,
> Zhaomo
>
> On Wed, Jul 15, 2015 at 4:26 AM, Andrew Dunstan <andrew(at)dunslane(dot)net>
> wrote:
>
>>
>> On 07/15/2015 07:58 AM, Simon Riggs wrote:
>>
>>
>>> For me the design summary is this
>>>
>>> * CREATE GLOBAL TEMP TABLE creates catalog entries like a normal table
>>> but with different relkind
>>> * When we see a request to INSERT, DEL, UPD, SEL from the temp table, if
>>> it does not exist we create it as a TEMP table of the same name, using the
>>> Global's pg_class entry as a template
>>>
>>> That meets the SQL Standard and doesn't contain any visibility problems
>>> or need for new internals.
>>>
>>> The purpose of this feature is to automatically create a temp table with
>>> the same definition whenever needed. The discussion of "bloat" is just
>>> wrong. We create exactly the same amount of bloat as if we had typed CREATE
>>> TEMP TABLE. Optimising temp table entries in the catalog is another,
>>> separate patch, if we care.
>>>
>>>
>>>
>> Sounds fine in general. I'm a bit curious to know what are the locking
>> implications of vivifying the table on access.
>>
>> cheers
>>
>> andrew
>>
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeevan Chalke 2015-07-15 13:40:45 Grouping Sets: Fix unrecognized node type bug
Previous Message Zhaomo Yang 2015-07-15 13:21:45 Re: Implementation of global temporary tables?