I wrote:
> Anyway, it doesn't look like there's much hope of improving this
> aspect without a significant rewrite.
Just to close out this thread: I've now posted such a rewrite at
https://www.postgresql.org/message-id/2273648.1634764485%40sss.pgh.pa.us
regards, tom lane