After reading the logic of removing useless join, I think the comment of this might need to be changed: "Currently, join_is_removable only succeeds if sjinfo's right hand is a single baserel. " could be changed to "Currently, join_is_removable only succeeds if sjinfo's min_righthand is a single baserel. ". Because the useless join in the query "select t1.* from t1 left join (t2 left join t3 on t3.a=t2.b) on t2.a=t1.a;" would also be eliminated. That is, the query will be converted to "select t1.* from t1;"