whilerecords.any?records_size=records.sizeprimary_key_offset=records.last.idraise"Primary key not included in the custom select clause"unlessprimary_key_offsetyieldrecordsbreakifrecords_size<batch_sizerecords=relation.where(table[primary_key].gt(primary_key_offset)).to_aend