There were clauses that weren't needed in the subqueries. These were ORDER BY, SELECT FOR UPDATE and related selections.