I'm interested in point 4: use SQL. Is there a way of doing a find that only returns the primary key value and then do a delete only based on this value without using SQL and only via Active Record?
Person.delete_all("created_at < '2012-01-01'")
will generate the sql command "delete from persons where created_at < '2012-01-01'"
You can use normal AR conditions of course. For example: Person.delete_all(["created_at < ?", Time.now.beginning_of_year])
That will not run any callbacks of course since the data is never being pulled back into your code and AR objects are not instantiated. If you need callbacks to run (for example to delete or update related objects) then look at the much slower ActiveRecord::Base#destroy_all. ids = Post.where(:published => true).pluck(:id)
Post.where(:id => ids).delete_all
or this Post.where(:published => true).delete_all
?Does the second query translate to a straight DELETE?