Optimizing queries with the subquery cache