Thanks much. Didn't know about LATERAL. That's a solution. Seems like the implementation could be improved though. The existence of LATERAL seems to imply that it's possible. Why introduce more complicated syntax? Of course the syntax applies to more situations than this one. But this case seems like it could be improved.
I hate complaining. Especially about my favorite database. But when a composite type has many columns, this inefficiency really adds up. And it's pretty invisible, unless you really look into it.
It's on my list of things to do to buy Tom Lane a beer. It should, in my opinion, be on everyone's list of things to do who is on this list. This problem has nothing to do with it. I'm hoping that, altogether, we buy Tom enough beer that that he considers making this query more efficient. This might involve impairing his better judgement, but I'm willing to drive to the country of Pennsylvania or wherever it is Tom hangs his hat these days to to buy a beer in the cause of improving this query. Maybe two beers. I hope you will all chip in a few beers yourselves, and maybe we can fix this esoteric problem that probably only concerns me.