On 30 July 2015 at 14:26, Alexander Korotkov <a.korot...@postgrespro.ru>
wrote:


> As I mentioned in CSN thread, it would be nice to replace XID with CSN
> when setting hint bits for tuple. In this case when hint bits are set we
> don't need any additional lookups to check visibility.
>
> http://www.postgresql.org/message-id/CAPpHfdv7BMwGv=ofug3s-jgvfkqhi79pr_zk1wsk-13oz+c...@mail.gmail.com
> Introducing 32-bit CSN doesn't seem reasonable for me, because it would
> double our troubles with wraparound.
>

Your idea to replace XIDs with CSNs instead of hinting them was a good one.
It removes the extra-lookup we thought we needed to check visibility with
CSN snapshots.

I agree 32-bit CSNs would not be a good idea though, a 64-bit CSN is needed.

If we break a CSN down into an Epoch and a 32-bit value then it becomes
more easily possible. The Epoch for XID and CSN can be the same - whichever
wraps first we just increment the Epoch.

By doing this we can reuse the page-level epoch for both XID and CSN. Now
hinting a tuple is just replacing a 32-bit XID with a 32-bit CSN.

We would probably need an extra flag bit for the case where the CSN is one
epoch later than the XID.

-- 
Simon Riggs                http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Reply via email to