Is there a that I can make this algorithm faster?
I'm fetching all documents for this Model (Artifact) and for each document I would like to know if there is duplicate and if so I delete it.
Artifact.all.to_a.each do |n|
image = n.image_original
thumb = n.image_thumbnail
count_value = Artifact.where(:image_original => image,
:image_thumbnail => thumb).all.to_a.count
if count_value > 1
n.destroy!
end
end