Avoid De-TOASTing where Possible
|Reported by:||pramsey||Owned by:||pramsey|
In answer to a query about using Datum as a key in a cache to avoid de-TOASTING overhead, Tom Lane said:
The case where this would actually be worth doing, probably, is where you are receiving a toasted-out-of-line datum. In that case you could legitimately use the toast pointer ID values (va_valueid + va_toastrelid) as a lookup key for a cache, as long as it had a lifespan of a statement or less.
This actually turns out to be a small extra patch that just sits at the detoast step at the top of functions that use caching machinery.