Reduce query count in getcomparisondata
Reduce query count in getcomparisondata

Benchmarks and environments don't have to be queried inside the loop,
query them once outside.
Also don't retrieve benchmark results one by one, but get them all for a
specific revision/environment/executable combination.

For the testdata fixture, this decreases query count from 47 to 24
queries. With data from speed.pypy.org query count goes from 1893
queries down to 75. Instead of 2.8s processing time, the data is
collected in 100ms. Measured on SQLite, but other databases should
benefit too.

nomeata/codespeed,nomeata/codespeed,alex/codespeed,alex/codespeed,cykl/codespeed,cykl/codespeed