Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> One idea is to take a copy of the state datum after each row. Then,
> instead of initializing the aggregate from scratch, you can "roll back"
> to an earlier copied state. It doesn't always help, but might be a part
> of the solution.
That requires that you know how to copy the aggregate's state. You do
not. (In some cases the aggregate function has extra state besides the
nominal transition datum...)
regards, tom lane