I need to import large amounts of data records into a database with my
rails application. The problem: It''s REALLY SLOW.
I found Zach Dennis'' ActiveRecord-extensions to be extremely
interesting:
http://www.rubyinside.com/advent2006/17-extendingar.html#import
Quote:"Benchmarks with MySQL''s MyISAM and InnoDb table types
without
validations show up to a 48x performance increase."
BUT: How can I use this with joined tables?
Example:
Supposed "Parent" and "Child" have a has_and_belongs_to_many
relation,
i.e. they are linked with a join table "childrens_parents". Now, I
want
to use the import functionality from ar-extension to optimize this:
1000.times {
parent.children.create(:par0 => 42)
}
Problem: Every "create" generates two(!) INSERTs in MySQL:
...
INSERT INTO children_parents (child_id, parent_id) VALUES (325648,
480)
INSERT INTO children (par0) VALUES(42)
...
Is there a way to optimize this with "import" from the AR extensions?
Or
is there any other way to do this fast?
Any help is appreciated!
Thanks,
Marc
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---