Histogram query: be more efficient

Equivalent, but much more efficient, algorithm.
Merge pull request #609 from uwescience/dhalperi-improve-profiler

Histogram query: be more efficient
Merge branch 'master' into hash-expression
reinstate spacing