Use a more efficient query for handling id_set queries