My piece of code is below, (consider Country is subclass ActiveReocrd::Base) File.open("country.list").each do | line | line.strip! name, code = line.split("\t") c = Country.new c.name <http://c.name> = name c.code = code c.save end This piece of code is inserting rows in countries table. and the number of insert statement is equal to the number of lines in country.list Is there any way to save those rows by one method. What I want is not to send 100 insert statement to database server, I want to send only one insert statement in database server. Thanks Mohammad Khan _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hi ! Mohammad Khan said the following on 2005-09-24 01:28:> Is there any way to save those rows by one method. > What I want is not to send 100 insert statement to database server, I > want to send only one insert statement in database server.Nothing you can do, except build the SQL statement yourself, and sending that using ActiveRecord::Base.connection.execute. If it''s performance you''re looking for, you might want to try wrapping this in a transaction, it might help. Or else, look at disabling indexes (MySQL) to help speed up the insertion. Bye ! François
If I use the MemoryStore for caching fragments, what happens when the FastCGI processes are restarted? I assume that the cache is lost. Thanks, Steve
> If I use the MemoryStore for caching fragments, what happens when the > FastCGI processes are restarted? I assume that the cache is lost.You would be assuming correctly. Also, the memory store is only suitable for use with FCGI if you have only 1 process running. Otherwise each FCGI process will have its own cache, which doesn''t work since expiration can''t be consistent, then. In that case, you should use one of the other stores. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework
Thanks for the clarification. Steve David Heinemeier Hansson wrote:>>If I use the MemoryStore for caching fragments, what happens when the >>FastCGI processes are restarted? I assume that the cache is lost. >> >> > >You would be assuming correctly. Also, the memory store is only >suitable for use with FCGI if you have only 1 process running. >Otherwise each FCGI process will have its own cache, which doesn''t >work since expiration can''t be consistent, then. > >In that case, you should use one of the other stores. >-- >David Heinemeier Hansson >http://www.loudthinking.com -- Broadcasting Brain >http://www.basecamphq.com -- Online project management >http://www.backpackit.com -- Personal information manager >http://www.rubyonrails.com -- Web-application framework >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > > >