Optimizing sum() performance

Moved from GitHub dgraph/5432

Posted by lgalatin:

Based on performance #s in this discuss post: Optimizing sum() performance, Dgraph takes 10s (16 vCPU, 128GB RAM), PostgreSQL takes 1.12s (4vCPU, 16GB RAM) We need to look into what is causing the slowdown.