Re #1692 prevent query repeats and not fetch rows which are not required

@jonpday please review
This query deserves a `LIMIT` statement to reduce the scope and severity of catastrophically bad data. Something like `LIMIT 1000` would provide a decent fallback, if we can assume this should never return more than 1000 rows.