Re: Transactions and indexes

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Chris Cleveland <ccleveland(at)dieselpoint(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Transactions and indexes
Date: 2021-07-19 23:57:45
Message-ID: CAH2-Wz=6ecGQ8wnwj=au9_+CLw4m9K4nsfBLnuPxGrn6u+9ySg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 19, 2021 at 4:31 PM Chris Cleveland
<ccleveland(at)dieselpoint(dot)com> wrote:
> I'm confused on how to handle transactions and visibility.

In Postgres, indexes are not considered to be part of the logical
database. They're just data structures that point to TIDs in the
table. To an index, each TID is just another object -- it doesn't
possess any built-in idea about MVCC.

In practice the indexes may be able to surmise certain things about
MVCC and versioning, as an optimization -- but that is all speculative
and relies on cooperation from the table AM side. Also, the
implementation of unique indexes knows more than zero about versions,
since that's just necessary. These two cases may or may not be
considered exceptions to the general rule. I suppose that it's a
matter of perspective.

> So... how do I handle this? Is there some way for me to implement my own storage manager that manages visibility?

This is the responsibility of a table AM, not any one index AM. In
general we assume that each table AM implements something very much
like heapam's VACUUM implementation. Index AMs may also have
opportunistic cleanup of their own, as an optimization (actually this
is what I was referring to).

Theoretically index AMs and table AMs are orthogonal things. How true
that will be in a world with more than one mature table AM remains to
be seen.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-07-20 00:00:12 Re: [PoC] Improve dead tuple storage for lazy vacuum
Previous Message Andres Freund 2021-07-19 23:49:15 Re: [PoC] Improve dead tuple storage for lazy vacuum