in reply to mysql's join too slow; using Perl to compare two tables

Do a SELECT for all the existing data. Convert the fields to some standard format (in this case, lowercase tab delimited is probably fine) and create a hash for fields => id, or fields hash => id. Now all you have to do is take the new data, convert it also to the same format, and check to see if each item is in the hash. If it is, UPDATE using the id. If it isn't, do an INSERT. If memory use is a problem, create a dump of the existing data, do the above processing on your own computer rather than the server, and split the new data into two files, one for UPDATE and one for INSERT. The server will then be able to process the result with minimum effort.
  • Comment on Re: mysql's join too slow; using Perl to compare two tables