How to send such a request to the database server from the Rake task without deleting the record by record in "every" cycle?
delete from data where uuid in ( select uuid from data group by uuid, raw, recdate having count(*)>1 );
ActiveRecord has a delete_all method for you. Note that it does not call destroy callbacks. http://api.rubyonrails.org/classes/ActiveRecord/Relation.html#method-i-delete_all
delete_all