Here is the patch in its "final" state after my minor additions, edits and review.
Performance tests for me show that the patch is effective; my results match Jesper's roughly in relative numbers.
My robustness review is that the approach and implementation are safe.
It's clear there are various additional tuning opportunities, but the objective of the current patch to improve performance is very, very clearly met, so I'm aiming to commit *this* patch soon.
--
Simon Riggs http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services