Re: lifetime of the old CTID

Поиск
Список
Период
Сортировка
От Karsten Hilbert
Тема Re: lifetime of the old CTID
Дата
Msg-id YsVaWIma6SrZNGEo@hermes.hilbert.loc
обсуждение исходный текст
Ответ на Re: lifetime of the old CTID  (Laurenz Albe <laurenz.albe@cybertec.at>)
Список pgsql-general
Am Wed, Jul 06, 2022 at 08:41:58AM +0200 schrieb Laurenz Albe:

> Using the primary key is the proper solution.  To be safe from concurrent
> modifications, use a logic like in this pseudo-code:
>
> FOR b IN SELECT pk, other_columns FROM books WHERE condition
>    UPDATE books SET ... WHERE pk = ... AND condition
>
> Checking the condition again on the inner UPDATE will detect concurrent
> data modifications.  If the UPDATE changes nothing, then a book has been
> removed or updated by a concurrent transaction, and you ignore it.

UPDATEing conditional on XMIN not having changed might be
another solution for detecting concurrent transacations if
one is bent on using system columns for that.

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B



В списке pgsql-general по дате отправления:

Предыдущее
От: Karsten Hilbert
Дата:
Сообщение: Re: lifetime of the old CTID
Следующее
От: Florents Tselai
Дата:
Сообщение: Re: ADD COLUMN ts tsvector GENERATED too slow