If you toggle the value for generate_read_methods, you should see there
is a significant processing hit:
# Setting the generate_read_methods
require 'rubygems'
require_gem 'activerecord'
require 'benchmark'
ActiveRecord::Base.establish_connection(:adapter => "mysql",
:database => "testdb", :username => "root", :password => "", :host => "localhost")
ActiveRecord::Base.generate_read_methods = false
class Account < ActiveRecord::Base
end
2.times do |x|
Account.benchmark("starting benchmark") do
temp = Account.find_by_username("Kevin")
puts temp.created_at
end
end
This setting primarily has to do with performance issues, because when you choose not to
generate read methods, Active Record is forced to call the method_missing method each time
you attempt to access an attribute??”and calling the method_missing method is resource intensive.
Again, this attribute has little to do directly with legacy schema, but we include it here,
because it is a configuration option you can set.
schema_format
This is also an attribute that you set directly on the ActiveRecord::Base class; it tells Active
Record what format to use when dumping the database schema to flat files.
Pages:
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386