My completely empty model (no validation callbacks etc etc) takes an average of 0.05 seconds to create, at least according to Benchmark.realtime{200.times{Message.create(:from => "me@here.com", :message_type => ''email'', :subject => "hello", :body => "goodbye", :sent_at => Time.now)}}/200 That''s a little slower than I''m comfortable with for our needs. Is there anything I can do to improve this? I''m running Edge Rails, mysql 4.1 on FedoraCore 4 with a 3GHz Pentium 4. Jon
Jonathan del Strother wrote:> My completely empty model (no validation callbacks etc etc) takes an > average of 0.05 seconds to create, at least according to > > Benchmark.realtime{200.times{Message.create(:from => "me@here.com", > :message_type => ''email'', > :subject => "hello", :body => "goodbye", :sent_at => Time.now)}}/200 > > > That''s a little slower than I''m comfortable with for our needs. Is > there anything I can do to improve this? > > I''m running Edge Rails, mysql 4.1 on FedoraCore 4 with a 3GHz Pentium 4. > > > Jon > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >If you are really going to create a lot of records right next to each other put the whole set in a transaction. -- Jack Christensen jackc@hylesanderson.edu
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jack Christensen wrote:> Jonathan del Strother wrote: > >> My completely empty model (no validation callbacks etc etc) takes an >> average of 0.05 seconds to create, at least according to >> >> Benchmark.realtime{200.times{Message.create(:from => "me@here.com", >> :message_type => ''email'', >> :subject => "hello", :body => "goodbye", :sent_at => Time.now)}}/200 >> >> >> That''s a little slower than I''m comfortable with for our needs. Is >> there anything I can do to improve this? >> >> I''m running Edge Rails, mysql 4.1 on FedoraCore 4 with a 3GHz Pentium 4. >> >> >> Jon >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > If you are really going to create a lot of records right next to each > other put the whole set in a transaction.If you are worried about the speed of many creations, check out: http://blogs.mktec.com/zdennis/articles/2006/07/15/activerecord-optimizations-0-0-1 http://blogs.mktec.com/zdennis/articles/2006/07/20/activerecord-optimizations-0-0-2 http://blogs.mktec.com/zdennis/articles/2006/08/03/activerecord-optimizations-er-extensions-0-0-3\ It is a way to do multivalue inserts in an optimized fashion for MySQL, based on the max number of allowed packets that the server allows. If you are just worried about the creation of a single record then you may want to determine what your validations are (if any) and if you want to save_without_validation which will bypass some of the callbacks. If any questions or comments feel free to let me know. Zach -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE3ItdMyx0fW1d8G0RArKQAJ9SI6cYoPQJSDIYxsGxiE1B25ggJwCeNWWg 8aWvv6otr1IHHD5dmzXv9J0=OB9g -----END PGP SIGNATURE-----
Check out http://blogs.mktec.com/zdennis/articles/2006/08/03/activerecord-optimizations-er-extensions-0-0-3 On 8/10/06, Jack Christensen <jackc@hylesanderson.edu> wrote:> > Jonathan del Strother wrote: > > > My completely empty model (no validation callbacks etc etc) takes an > > average of 0.05 seconds to create, at least according to > > > > Benchmark.realtime{200.times{Message.create(:from => "me@here.com", > > :message_type => ''email'', > > :subject => "hello", :body => "goodbye", :sent_at => Time.now)}}/200 > > > > > > That''s a little slower than I''m comfortable with for our needs. Is > > there anything I can do to improve this? > > > > I''m running Edge Rails, mysql 4.1 on FedoraCore 4 with a 3GHz Pentium 4. > > > > > > Jon > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > If you are really going to create a lot of records right next to each > other put the whole set in a transaction. > > -- > Jack Christensen > jackc@hylesanderson.edu > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Mark Van Holstyn mvette13@gmail.com http://lotswholetime.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060811/065aec37/attachment.html
On 11 Aug 2006, at 03:49, Jack Christensen wrote:> Jonathan del Strother wrote: > >> My completely empty model (no validation callbacks etc etc) takes >> an average of 0.05 seconds to create, at least according to >> >> Benchmark.realtime{200.times{Message.create(:from => >> "me@here.com", :message_type => ''email'', >> :subject => "hello", :body => "goodbye", :sent_at => Time.now)}}/200 >> >> >> That''s a little slower than I''m comfortable with for our needs. >> Is there anything I can do to improve this? >> >> I''m running Edge Rails, mysql 4.1 on FedoraCore 4 with a 3GHz >> Pentium 4. >> >> >> Jon >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > If you are really going to create a lot of records right next to > each other put the whole set in a transaction.Unfortunately, I can''t. I''m only receiving 1 new message on each incoming request. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2114 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060811/62761d90/smime-0001.bin