From: Marnen Laibow-Koser Date: 2009-11-26T05:42:31+09:00 Subject: Re: Pseudo array for Rails migration Ralph Shnelvar wrote: > Wednesday, November 25, 2009, 10:35:06 AM, you wrote: > > RK> On 22.11.2009 17:05, Marnen Laibow-Koser wrote: >>>> >>>> normalizing it slows me down a couple of orders of magnitude. I'm >>>> willing to live with the lack of purity for the sake of performance. >>> >>> A couple orders of magnitude? This suggests to me that your >>> normalization and/or queries are poorly done. What is chewing up so >>> much time, and what does the normalized schema look like? It should be >>> possible to find a solution that performs reasonably and doesn't have 20 >>> repeating fields. > > RK> I second that. Ralph, any information about the slowness? Is it in > the > RK> database or outside? > > I _think_ it is, in part, coming from the logging that is being done. > > Instead of one create ... one can have 21. Then, as I suspected, you are using the DB incorrectly. To create 21 records, use 1 query, not 21. You can use ar-extensions or something similar to do this with ActiveRecord. Rule of thumb: queries don't belong inside loops. If you find yourself putting a query in a loop, you have a design problem. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.