From: | Antonin Houska <ah(at)cybertec(dot)at> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()? |
Date: | 2024-07-10 15:00:13 |
Message-ID: | 36977.1720623613@antos |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
Attachment | Content-Type | Size |
---|---|---|
use_bsearch_for_ParallelCurrentXids.diff | text/x-diff | 1007 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2024-07-10 15:04:15 | Re: Is it possible to create a cursor with hold using extended query protocol |
Previous Message | David E. Wheeler | 2024-07-10 14:54:27 | Re: jsonpath: Inconsistency of timestamp_tz() Output |