Improve response time for drawing histogram

This change reduces a query with the same data from 1m7s to 11s
Merge pull request #39 from cglewis/master

Improve response time for drawing histogram