Alvaro Herrera <alvhe...@2ndquadrant.com> writes: > On the other hand, I'm not clear on why do we need four copies of > number_of_ones.
Yeah, it might be time to move something like that into a common location. Not sure where the threshold of pain is, though. regards, tom lane