Hi guys

I have a problem with a fairly standard Rails / mySQL query. I must be
doing something very wrong. I was hoping somebody could shed some
light on this. 

First model: article, has_many comments
Second model: comment, belongs_to article

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. 

Notes:
- I am not using :dependent => :delete since I was thinking doing a
destroy instead of delete on Articles would be too slow (my
understanding is when you "destroy", Rails loads the object first) 
- I have killed all other queries on the DB, just to make sure there
are no locks somewhere. 

Thanks!
Pierre

-- 
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