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:
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?
Problem: Every “create” generates two(!) INSERTs in MySQL:
Thanks,
Marc
Posted viahttp://www.ruby-forum.com/.
Try something like this. The trick is to use arrays to capture the
data for each iteration. Its fast.
require “rubygems”
require “active_record”
#change the following for your database
ActiveRecord::Base.establish_connection(:adapter => “mysql”, :host =>
“localhost”,:database => “railsspace_development”,
:username => “your use name”, :password => “your password”)
class Spec < ActiveRecord::Base;end
class Spectors < Spec
attr_accessor( :user_id, :first_name, :last_name, :gender, :birthdate,
:zip_code)
end
i =0;test_data = YAML.load_file(‘specs2.yml’)
while i < (test_data.length) #number of players