Revert "Performance fix, don't re-calculate the query"

This reverts commit d03c39d2f56e500b1a287a419380c8593b2fbe2a.