Quan Zongliang <quanzongli...@yeah.net> writes: > Now, the varlena type is stored directly in the array. Did not consider > short varlena. If it's like fill_val(), using short varlena saves memory > footprint and disk space.
TBH, I think this is a bad idea and we should reject it. As you have already discovered, the code footprint of such a change is enormous (and I have little confidence that you found all the places to fix). The consequences would be equally dire in extensions, which'd likely be dealing with ensuing bugs for years to come. The reason we didn't do this when we originally invented short varlena headers is that we presumed that array-level compression would remove most of the benefit. Of course that only happens if the array is big enough to get the attention of the tuple toaster, which is why your example with very small arrays shows a benefit. But I'm doubtful that such use-cases justify the pain we'd endure getting to the point where this'd work reliably. The percentage savings drops off drastically as the length of the individual strings grows, so this example with one-byte strings is very much a best-case scenario. In short, I'm afraid this ship sailed a long time ago. Perhaps it was a poor decision but I think we're stuck with it. regards, tom lane