TOAST vs arrays

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Wieck <JanWieck(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: TOAST vs arrays
Date: 2000-07-17 23:14:58
Message-ID: 5234.963875698@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

If I understand the fundamental design of TOAST correctly, it's not
allowed to have multiple heap tuples containing pointers to the same
moved-off TOAST item. For example, if one tuple has such a pointer,
and we copy it with INSERT ... SELECT, then the new tuple has to be
constructed with its own copy of the moved-off item. Without this
you'd need reference counts and so forth for moved-off values.

It looks like you have logic for all this in tuptoaster.c, but
I see a flaw: the code doesn't look inside array fields to see if
any of the array elements are pre-toasted values. There could be
a moved-off-item pointer inside an array, copied from some other
place.

Note the fact that arrays aren't yet considered toastable is
no defense. An array of a toastable data type is sufficient
to create the risk.

What do you want to do about this? We could have heap_tuple_toast_attrs
scan through all the elements of arrays of toastable types, but that
strikes me as slow. I'm thinking the best approach is for the array
construction routines to refuse to insert toasted values into array
objects in the first place --- instead, expand them before insertion.
Then the whole array could be treated as a toastable object, but there
are no references inside the array to worry about.

If we do that, should compressed-in-place array items be expanded back
to full size before insertion in the array? If we don't, we'd likely
end up trying to compress already-compressed data, which is a waste of
effort ... but OTOH it seems a shame to force the data back to full
size unnecessarily. Either way would work, I'm just not sure which
is likely to be more efficient.

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tim Dunnington 2000-07-17 23:20:47 libpgtcl on aix
Previous Message Chris Bitmead 2000-07-17 23:09:44 Re: Should PG backend know how to representmetadata?