The plain UNION code supports either sorting or hashing, but we've not gotten around to supporting a sort-based approach to recursive UNION. I'm not convinced that it's worth doing ...
regards, tom lane
Without sorting, isnt the scope of a recursive UNION with custom datatypes pretty restrictive?
As is, even the sorting shall be a bit restrictive due to the costs associated. I feel what David has suggested upthread should be good. Maybe an experimental patch with a workload that should give a load factor 1 for the hash table should prove some performance points.
Even if thats not the case, we should really do something to improve the scope of usability of recursive UNION with custom types.