From: Tim Pease Date: 2007-05-24T07:31:05+09:00 Subject: Re: optimizing for speed - Array#each On 5/23/07, Stefan Rusterholz wrote: > > No. I don't think you can speed up Array#each at all. What's far more > promising is improving your algorithm in a way that it has to run less > loops. You most likely have one or even several O(n^x) algorithms with x > >= 2 in your app. Maybe you're not even aware. E.g. if you have an each > with a select in the loop you're already in O(n^2) realm. > The database comparison probably can be handled best with hashtables of > the primary keys. > I was going to suggest something even more primitive -- query each database table in some sorted fashion and dump it as a CSV file. Use diff to compare CSV files. Obviously this won't work for tables with blobs, but it might be a fun experiment. Failing that, how can the database do the work for you? Let it find the records you're interested in (it will do it faster). Put modification timestamps in your tables to reduce the number of records you need to search. Or use triggers to log all transactions to a separate table so you can run those same transactions on the other database. Just some thoughts. Blessings, TwP