Re: [Proposal] Global temporary tables

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, 曾文旌(义从) <wenjing(dot)zwj(at)alibaba-inc(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, 蔡松露(子嘉) <zijia(at)taobao(dot)com>, "Cai, Le" <le(dot)cai(at)alibaba-inc(dot)com>, 萧少聪(铁庵) <shaocong(dot)xsc(at)alibaba-inc(dot)com>
Subject: Re: [Proposal] Global temporary tables
Date: 2020-01-30 09:44:39
Message-ID: e78afd0d-124c-11f3-e320-de3089fa5c3b@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 30.01.2020 12:23, Pavel Stehule wrote:
>
> Building regular index requires two kinds of lock:
> 1. You have to lock pg_class to make changes in system catalog.
> 2. You need to lock heap relation  to pervent concurrent updates
> while building index.
>
> GTT requires 1)  but not 2).
> Once backend inserts information about new index in system
> catalog, all other sessions may use it. pg_class lock prevents any
> race condition here.
> And building index itself doesn't affect any other backends.
>
>
> It is true. The difference for GTT, so any other sessions have to
> build index (in your proposal) as extra operation against original plan.
>
What is "index"?
For most parts of Postgres it is just an entry in system catalog.
And only executor deals with its particular implementation and content.

My point is that if we process GTT index metadata in the same way as
regular index metadata,
then there will be no differences for the postgres between GTT and
regular indexes.
And we can provide the same behavior.

Concerning actual content of the index - it is local to the backend and
it is safe to construct it a t any point of time (on demand).
It depends only on private data and can not be somehow affected by other
backends (taken in account that we preserve locking policy of regular
tables).

--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2020-01-30 09:52:56 Re: [Proposal] Global temporary tables
Previous Message Konstantin Knizhnik 2020-01-30 09:33:22 Re: [Proposal] Global temporary tables