Re: lazy detoasting - Mailing list pgsql-hackers

From Chapman Flack
Subject Re: lazy detoasting
Date
Msg-id d4169595-6aba-5741-48a2-3202eb8fe971@anastigmatix.net
Whole thread Raw
In response to Re: lazy detoasting  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: lazy detoasting  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On 04/10/2018 10:06 AM, Tom Lane wrote:
> Chapman Flack <chap@anastigmatix.net> writes:

>> Am I right in thinking that, for my original purpose of
>> detoasting something later in a transaction, all that matters
>> is that I registered a snapshot from the time at which I copied
>> the toasted datum, and the resource owner I registered it to
>> has not been released yet, ...
> 
> I believe so.

Ok.

I see I have about half a dozen choices for the snapshot that
I choose to squirrel away at the same time as the copied datum.
(That's not counting SnapshotToast, which I didn't know was a thing
until Pavan's thread this morning, but it's not a thing I can get,
just something constructed on the fly in the tuptoaster.)

Out of the six GetFooSnapshot()s, would I want to squirrel away
Active? Oldest? Transaction? This should be happening in a PL
function not doing anything arcane; the datum in question might
be passed to it as a parameter or retrieved from a query done
within the function.

GetOldestTransaction() is what the tuptoaster will eventually use
to construct SnapshotToast when looking for the data, but it's
probably overkill for me to save the oldest one in sight at the
time I save the datum. Or is it? Should I be confident that, at
the time I'm handed this datum, its toasted content must be
retrievable through the (Active? Transaction?) snapshot at that
moment, and it's enough to register that, while to register the
Oldest would be to pin something unnecessarily far back?

> Wouldn't be a bad idea to test this, of course ;-)

Mm-hmm. (Thunderbird has just corrected my spelling of mm-hmm.)
I'm still not sure I know enough to construct a meaningful test...

I assume that, while I'm doing this for a backend PL at the
moment, some of the same considerations will apply if a future
wire protocol is to support Craig's "v4 protocol TODO item -
Lazy fetch/stream of TOASTed valued" suggestion in
https://www.postgresql.org/message-id/53FF0EF8.100@2ndquadrant.com

-Chap


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: 2018-03 CF Cleanup
Next
From: David Steele
Date:
Subject: Re: [PATCH][PROPOSAL] Refuse setting toast.* reloptions when TOASTtable does not exist