a very naive query planner