aggregate improvements on Postgres