rewrite query9, to see if expand is better than hash join