Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()?

Поиск
Список
Период
Сортировка
Искать
От
Antonin Houska
Тема
Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()?
Дата
Msg-id
36977.1720623613@antos
Список
Дерево обсуждения
Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()? Antonin Houska <ah@cybertec.at>
Re: Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()? Nathan Bossart <nathandbossart@gmail.com>
Re: Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()? Antonin Houska <ah@cybertec.at>
Re: Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()? Nathan Bossart <nathandbossart@gmail.com>
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
Дата:
От: David G. Johnston
Дата:
FAQ