initial draft of a select query - too slow to be usuable atm

This works, but at the current speed, reading a day of (our) data would take ~16 years.

So stopping it here. Still didn't want to waste the code, so putting it up as a PR