On 14 September 2011 12:16, PierreW <[email protected]> wrote:
> The number of articles and comments can be big (one to two millions).
> Every once in a while, I "clean" the DB and remove older articles and
> comments:
>
> Articles.delete_all(["a_date < ?", xxxx]
> Comments.delete_all("comments.article_id not in (select id from
> articles)")
>
> The first query is executed with no problems. But the second one hangs
> and completely loads my database server.

Delete the comments first?
 Comments.delete_all("comments.article_id in (select id from articles
where a_date < ?)", xxxx)

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to