ActiveRecord::Optimizations 0.0.2 20 Jul 2006
After talking on rails-core I was swayed to believe that import would be a better name for multi-value inserts, since the return value is different then ActiveRecord::Base.create. This update renames the create method to import.

It also adds documentation to most of the method in the active record base and mysql_adapter files.

An example of this is: class LogEntry < ActiveRecord::Base ; end

hashes = LogFileReader.read_log_entries( ‘file.log’ ) n = LogEntry.import hashes

puts “That took #{n} database inserts”

The beauty of this is that if your LogFileReader parsed 10 entries or 1,000,000 entries the number of inserts to the database is going to be the minimum number of inserts that is required by your database. It is 20x to 30x faster then ActiveRecord::Base.create

    1. 3 should be out this weekend and it is scheduled to have Postgresql support for ActiveRecord::Base.import and import with validations. Currently all imports all done w/o model validation.
    1. 2 can be downloaded here

blog comments powered by Disqus