@domcleal, I prefer to re-factor this after the merge.  Plus, there is already issue #4329 to optimize the SQL in this method