From: Daniel Waite Date: 2007-11-03T04:14:23+09:00 Subject: Re: Database speed issues Jeremy Woertink wrote: > So, I have a bit of a design problem. I have an application that work, > but not as well as I would like it to. My problem is that I had to > write an application that checks millions of records against hundreds > of millions of records to see if there are any duplicates. The only > way I could think to do this is pretty much select from the different > tables where the specific column matches my search string. This is > really slow! Obviously if it returns something, then there is a dup, > if not, then YAY! > > I know there has to be a better way then just doing a SQL select > statement. Any ideas? I dunno how fast it is compared to your select statement, but if you can build arrays out of the data you want to compare you call the % method on them. Example... irb> [ 5, 10 ] & [ 10, 15 ] => [10] It works with more complex arrays, too... irb> [ [ 5, 10 ], [ 15, 20 ] ] & [ [ 10, 15 ], [ 5, 10] ] => [[5, 10]] Hope that helps... -- Posted via http://www.ruby-forum.com/.