I wrote:
> ...probably have some cases like that in your real application. But I'd
> expect 8.2.4 to be equally slow because it also contains the code that
> is slow in that scenario. I'm hoping to get some time today to think
> about how that could be fixed.
Please try the attached patch (in addition to the one I sent earlier).
regards, tom lane