Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()?

Поиск
Список
Период
Сортировка
От Antonin Houska
Тема Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()?
Дата
Msg-id 36977.1720623613@antos
обсуждение исходный текст
Ответы Re: Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()?
Список pgsql-hackers
I don't quite understand why TransactionIdIsCurrentTransactionId() implements
binary search in ParallelCurrentXids "from scratch" instead of using
bsearch().

If I read the code correctly, the contents of the ParallelCurrentXids is
composed in SerializeTransactionState(), which uses xidComparator:

    qsort(workspace, nxids, sizeof(TransactionId), xidComparator);

so it should be o.k. to use bsearch(..., xidComparator).

For example, ReorderBufferCopySnap() also uses xidComparator to sort the
'subxip' array, and HeapTupleSatisfiesHistoricMVCC() then uses
TransactionIdInArray() (which is effectively bsearch(..., xidComparator)) to
search for particular XID in the array.

-- 
Antonin Houska
Web: https://www.cybertec-postgresql.com


Вложения

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

Предыдущее
От: "David E. Wheeler"
Дата:
Сообщение: Re: jsonpath: Inconsistency of timestamp_tz() Output
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Is it possible to create a cursor with hold using extended query protocol