Re: lazy detoasting - Mailing list pgsql-hackers

From Chapman Flack
Subject Re: lazy detoasting
Date
Msg-id 69d6efa1-0fad-1f44-3d98-3824465a3af0@anastigmatix.net
Whole thread Raw
In response to Re: lazy detoasting  (Chapman Flack <chap@anastigmatix.net>)
Responses Re: lazy detoasting
List pgsql-hackers
On 04/10/2018 05:04 PM, Chapman Flack wrote:
> ... I wonder if
> there's at least a cheap way to check a particular snapshot
> for suitability wrt a given toast pointer. Check a couple usual
> suspects, find one most of the time, fall back to eager detoasting
> otherwise?
> 
> Guess I need to go back for a deeper dive on just what constitutes
> a toast pointer. I was skimming last time....

I see all I have in a toast pointer is a relation id and a value
oid, so probably no way to check that a given snapshot 'works' to
find it, at least no more cheaply than by opening the toast relation
and trying to find it.

Welp, what tuptoaster does to construct its SnapshotToast is to
grab GetOldestSnapshot():

*  since we don't know which one to use, just use the oldest one.
*  This is safe: at worst, we will get a "snapshot too old" error
*  that might have been avoided otherwise.

... which means, I take it, that a more recent snapshot
might work, but this conservative choice would only fail
if the oldest snapshot has really been around for many days,
under typical old_snapshot_threshold settings?

... and if I'm getting a value from a portal that happens to have
a non-null holdSnapshot, then that would be the one to use, in
preference to just conservatively grabbing the oldest?

-Chap


... am I right that the init_toast_snapshot construction is really
making only one change to the snapshot data, namely changing the
'satisfies' condition to HeapTupleSatisfiesToast ?

The lsn and whenTaken seem to be fetched from the original data
and stored right back without change.


pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: pgsql: Validate page level checksums in base backups
Next
From: Michael Paquier
Date:
Subject: Re: Gotchas about pg_verify_checksums