38055 metric data points in 186426 ms (4.89ms/metric)
New code:
32882 metric data points in 118316 ms (3.59ms/metric)
So, roughly 36% faster. Note that my tests were done with a local instance of postgres, so the big win (fewer roundtrips to the database) was not captured here. The speedup is probably much higher with remote instance due to the network latency.